aboutsummaryrefslogtreecommitdiff
path: root/init.js
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2022-03-05 19:18:38 +0100
committerElias Fleckenstein <eliasfleckenstein@web.de>2022-03-05 19:18:38 +0100
commita25d1acd1d702287b6ca095a4079cf3f898cbe89 (patch)
tree552f6ccc15a082f9d662e7ff58bf2f954c0451e5 /init.js
downloadfurrybot-discord-a25d1acd1d702287b6ca095a4079cf3f898cbe89.tar.xz
Initial commit
Diffstat (limited to 'init.js')
-rw-r--r--init.js43
1 files changed, 43 insertions, 0 deletions
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]
+}