-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.mjs
75 lines (63 loc) · 1.92 KB
/
bot.mjs
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//Requried Dependencies
import { Client, Collection, Intents } from 'discord.js';
import { createRequire } from 'module';
import fs from 'node:fs';
const require = createRequire(import.meta.url);
const config = require('./config.json');
//List of DISCORD INTENTS
const INTENTS =
[
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_BANS,
Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
Intents.FLAGS.GUILD_INTEGRATIONS,
Intents.FLAGS.GUILD_WEBHOOKS,
Intents.FLAGS.GUILD_INVITES,
Intents.FLAGS.GUILD_VOICE_STATES,
Intents.FLAGS.GUILD_PRESENCES,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Intents.FLAGS.GUILD_MESSAGE_TYPING,
Intents.FLAGS.DIRECT_MESSAGES,
Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
Intents.FLAGS.DIRECT_MESSAGE_TYPING,
Intents.FLAGS.GUILD_SCHEDULED_EVENTS,
];
//New Discord Client
const client = new Client({ intents: INTENTS });
client.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.mjs'));
for(const file of commandFiles)
{
const command = require(`./commands/${file}`);
// Set a new item in the Collection
// With the key as the command name and the value as the exported module
client.commands.set(command.data.name, command);
}
//Once time only event listener.
client.once('ready', () =>
{
console.log('Client Initialized...');
// client.channels.fetch(config.baseChannel)
// .then(channel =>
// {
// channel.send('what\'s up fuckers? <:Pepepunch:783434609539022881>');
// });
});
client.on('interactionCreate', async interaction =>
{
if(!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName);
if(!command) return;
try
{
await command.execute(interaction);
}
catch ({ error })
{
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command.', ephermeral: true });
}
});
client.login(config.token);