aboutsummaryrefslogtreecommitdiff
path: root/init.js
blob: 75b5d57cd488b1e5efbb8699c50641db9c165094 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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]
}