Quick and dirty way to get the bot on the page.

master
Zed A. Shaw 3 years ago
parent 6c9f7336ef
commit 0d045b74df
  1. 1
      .gitignore
  2. 34
      ljsthw-bot.js

1
.gitignore vendored

@ -21,3 +21,4 @@ tags
# secrets
secrets
node_modules

@ -1,6 +1,24 @@
import { Client, Intents } from "discord.js";
import assert from "assert";
import { TOKEN } from "../secrets/discord.js";
import { TOKEN, chat_secret } from "./secrets/discord.js";
import http from "http";
import { io } from "socket.io-client";
const server = http.createServer();
const socket = io("ws://localhost:5001");
socket.io.on("error", (error) => {
console.error(error);
});
socket.io.on("ping", () => {
console.log("PING");
});
socket.on("connect", () => {
console.log("CONNECTED", socket.connected);
});
const client = new Client({
intents: [
@ -143,14 +161,12 @@ client.on("messageCreate", async msg => {
} else if(msg.channel.name === "livestream") {
console.log(">>> LIVESTREAM CHAT MESSAGE FROM", msg.author.username, msg.channel.type, msg.channel.name, msg.content);
// banlist lookup user
const is_ban = BAN_LIST[msg.author.username];
if(is_ban) {
console.log("IGNORE BANNED USER", msg.author.username);
} else {
// else
// socket_conn send message
}
const initials = `${msg.author.username[0]}${msg.author.username[1]}`;
socket.emit("/chat/message", {
chat_secret, user_id: initials, text: msg.content
});
} else {
console.log("IGNORED MESSAGE FROM", msg.author.username, "IN", msg.channel.name);
}

Loading…
Cancel
Save