From a25d1acd1d702287b6ca095a4079cf3f898cbe89 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 5 Mar 2022 19:18:38 +0100 Subject: Initial commit --- init.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 init.js (limited to 'init.js') diff --git a/init.js b/init.js new file mode 100644 index 0000000..75b5d57 --- /dev/null +++ b/init.js @@ -0,0 +1,43 @@ +const Discord = require("discord.js") +const common = require("./common.js") + +const client = module.exports = new Discord.Client({ + intents: [Discord.GatewayIntentBits.Guilds, Discord.GatewayIntentBits.GuildMessages] +}) + +client.login(process.env.DISCORD_TOKEN) + +let fb = { + commands: {}, + requests: {}, + operators: common.storageLoad("operators") || [], + ignored: common.storageLoad("ignored") || [], +} + +client.on("messageCreate", msg => { + if (msg.author.id != client.user.id && msg.content.startsWith("!") && !fb.ignored[msg.author.id]) { + let args = msg.content.slice(1).split(" ") + let cmd = args.shift() + let def = fb.commands[cmd] + + if (def) { + if (def.operator && !fb.operators[msg.author.id]) + msg.reply(`Sorry, you need to be an operator run this command: ${cmd}`) + else + def.func(msg, args, fb) + } else { + msg.reply(`Invalid command: ${cmd}`) + } + } +}) + +//const modules = ["nsfw", "random", "http", "operator"] +const modules = ["basic", "bullshit", "marriage", "http", "roleplay", "death", "economy", "waifu"] + +for (let f of modules) { + let m = require(`./${f}.js`) + + if (m) + for (let k in m) + fb.commands[k] = m[k] +} -- cgit v1.2.3