37 lines
837 B
JavaScript
37 lines
837 B
JavaScript
const express = require("express")
|
|
const { Client } = require("discord.js-selfbot-v13");
|
|
const { readFileSync } = require("node:fs");
|
|
const cfg = require("./config.json");
|
|
|
|
const client = new Client();
|
|
const app = express();
|
|
|
|
let resStream;
|
|
let channel;
|
|
|
|
app.use(express.static("assets"));
|
|
|
|
app.get("/channels/:channel", (req, res) => {
|
|
channel = req.params.channel;
|
|
resStream = res;
|
|
|
|
resStream.writeHead(200, {
|
|
"Content-Type": "text/html",
|
|
});
|
|
|
|
resStream.write(readFileSync("pages/index.html"));
|
|
});
|
|
|
|
function constructMessage(msg) {
|
|
return `<div>
|
|
<span>${msg.author.username}</span>: ${msg.content}
|
|
</div>`;
|
|
}
|
|
|
|
client.on("messageCreate", (msg) => {
|
|
if(!resStream || !channel || msg.channel.id !== channel) return;
|
|
resStream.write(constructMessage(msg));
|
|
});
|
|
|
|
app.listen(cfg.port);
|
|
client.login(cfg.token);
|