diff --git a/assets/style.css b/assets/style.css index b0abfd0..85bbc74 100644 --- a/assets/style.css +++ b/assets/style.css @@ -1,5 +1,20 @@ -.messages { - background: #333333; - color: white; - padding: 10px; +body { + background: #333333; + color: white; + padding: 0; + margin: 0; +} + +.container { + display: flex; + flex-direction: column-reverse; +} + +.messages { + max-height: 100%; + display: flex; + flex-direction: column; + overflow-y: auto; + justify-content: flex-end; + flex-wrap: nowrap; } diff --git a/pages/index.html b/pages/index.html index 9898354..a123aaa 100644 --- a/pages/index.html +++ b/pages/index.html @@ -3,4 +3,6 @@ -
+
+
+
diff --git a/server.js b/server.js index 5fc8869..0be6f81 100644 --- a/server.js +++ b/server.js @@ -11,8 +11,13 @@ let channel; app.use(express.static("assets")); -app.get("/channels/:channel", (req, res) => { - channel = req.params.channel; +app.get("/send", async (req, res) => { + res.redirect(req.headers.referer); + channel.send(req.query.content); +}); + +app.get("/channels/:channel", async (req, res) => { + channel = await client.channels.fetch(req.params.channel); resStream = res; resStream.writeHead(200, { @@ -20,6 +25,9 @@ app.get("/channels/:channel", (req, res) => { }); resStream.write(readFileSync("pages/index.html")); + (await channel.messages.search()).messages.reverse().each(msg => { + resStream.write(constructMessage(msg)); + }); }); function constructMessage(msg) { @@ -29,7 +37,7 @@ function constructMessage(msg) { } client.on("messageCreate", (msg) => { - if(!resStream || !channel || msg.channel.id !== channel) return; + if(!resStream || !channel || msg.channel.id !== channel.id) return; resStream.write(constructMessage(msg)); });