aboutsummaryrefslogtreecommitdiff
path: root/init.js
blob: a1429696e10fd3b42cc5cf6cddbd22f7e2bb5321 (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
44
45
46
47
48
49
50
51
52
53
54
const Discord = require("discord.js")
const common = require("./common.js")
const copypasta = require("./copypasta.json")
const copypastaTrigger = require("./copypasta.js")

const client = module.exports = new Discord.Client({
	intents: [Discord.GatewayIntentBits.Guilds, Discord.GatewayIntentBits.GuildMessages, Discord.GatewayIntentBits.GuildVoiceStates]
})

client.login(process.env.DISCORD_TOKEN)

let fb = {
	commands: {},
	requests: {},
	operators: common.storageLoad("operators") || [],
	ignored: common.storageLoad("ignored") || [],
}


client.on("ready", _ => client.user.setActivity("Leftist propaganda"))

client.on("messageCreate", msg => {
	if (fb.ignored[msg.author.id] || msg.author.id == client.user.id)
		return;

	const trigger = copypastaTrigger(msg.content.toLowerCase())
	if (trigger)
		return msg.reply(copypasta[trigger])

	if (msg.content.startsWith("!")) {
		let args = msg.content.replace(/@/g, "\\@").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 = ["basic", "bullshit", "marriage", "http", "roleplay", "death", "economy", "waifu", "operator", "nsfw", "random", "music", "badapple"]

for (let f of modules) {
	let m = require(`./${f}.js`)

	if (m)
		for (let k in m)
			fb.commands[k] = m[k]
}