made it semi usable
This commit is contained in:
parent
c35e4d1526
commit
af0b68eadc
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -3,4 +3,6 @@
|
|||
<link rel="stylesheet" href="/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="messages">
|
||||
<div class="container">
|
||||
<form action="/send"><input type="text" name="content" /></form>
|
||||
<div class="messages">
|
||||
|
|
14
server.js
14
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));
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue