forked from Dvent1123/discordBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (29 loc) · 1.2 KB
/
index.js
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
require('dotenv').config()
const { Client, Intents, Collection } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS] });
const prefix = '-'
const fs = require('fs')
client.commands = new Collection()
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'))
for(const file of commandFiles) {
const command = require(`./commands/${file}`)
client.commands.set(command.name, command)
}
client.once('ready', () => {
console.log('Daddy Bezos is online')
})
client.on('messageCreate' , message => {
//if not prefixed or is bot then return
if(!message.content.startsWith(prefix) || message.author.bot) return;
//splits message after prefix
const args = message.content.slice(prefix.length).split(/ +/)
const command = args.shift().toLowerCase()
if(command === 'ping'){
client.commands.get('ping').execute(message, args)
}else if(command === 'poll'){
client.commands.get('poll').execute(client, message, args)
}
})
client.login(`${process.env.TOKEN}`)