actually fix tabs

This commit is contained in:
sam 2024-02-29 17:05:40 +13:00
parent af0b68eadc
commit 1cc5508506
2 changed files with 16 additions and 16 deletions

View file

@ -1,8 +1,8 @@
<head> <head>
<title>noscript discord</title> <title>noscript discord</title>
<link rel="stylesheet" href="/style.css"> <link rel="stylesheet" href="/style.css">
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<form action="/send"><input type="text" name="content" /></form> <form action="/send"><input type="text" name="content" target="_blank" /></form>
<div class="messages"> <div class="messages">

View file

@ -17,28 +17,28 @@ app.get("/send", async (req, res) => {
}); });
app.get("/channels/:channel", async (req, res) => { app.get("/channels/:channel", async (req, res) => {
channel = await client.channels.fetch(req.params.channel); channel = await client.channels.fetch(req.params.channel);
resStream = res; resStream = res;
resStream.writeHead(200, { resStream.writeHead(200, {
"Content-Type": "text/html", "Content-Type": "text/html",
}); });
resStream.write(readFileSync("pages/index.html")); resStream.write(readFileSync("pages/index.html"));
(await channel.messages.search()).messages.reverse().each(msg => { (await channel.messages.search()).messages.reverse().each(msg => {
resStream.write(constructMessage(msg)); resStream.write(constructMessage(msg));
}); });
}); });
function constructMessage(msg) { function constructMessage(msg) {
return `<div> return `<div>
<span>${msg.author.username}</span>: ${msg.content} <span>${msg.author.username}</span>: ${msg.content}
</div>`; </div>`;
} }
client.on("messageCreate", (msg) => { client.on("messageCreate", (msg) => {
if(!resStream || !channel || msg.channel.id !== channel.id) return; if(!resStream || !channel || msg.channel.id !== channel.id) return;
resStream.write(constructMessage(msg)); resStream.write(constructMessage(msg));
}); });
app.listen(cfg.port); app.listen(cfg.port);