diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-03-05 19:18:38 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-03-05 19:18:38 +0100 |
commit | a25d1acd1d702287b6ca095a4079cf3f898cbe89 (patch) | |
tree | 552f6ccc15a082f9d662e7ff58bf2f954c0451e5 /init.js | |
download | furrybot-discord-a25d1acd1d702287b6ca095a4079cf3f898cbe89.tar.xz |
Initial commit
Diffstat (limited to 'init.js')
-rw-r--r-- | init.js | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -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] +} |