This repository has been archived by the owner on Jan 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.js
executable file
·55 lines (50 loc) · 1.59 KB
/
start.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
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env -S node
const fs = require('fs');
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const config = require('./config.json');
require('dotenv').config();
console.log('Starting!');
// const client = new Discord.Client({ intents: config.intents.map(intent => eval(`Discord.Intents.FLAGS.${intent}`)) });
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences
]
});
// todo: move back to file
client.commands = new Collection();
fs.readdirSync('./commands')
.filter(file => file.endsWith('.js'))
.forEach(file => {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
});
// Create a collection using those command files
fs.readdirSync('./events')
.filter(file => file.endsWith('.js'))
.map(file => require(`./events/${file}`))
.forEach(({ once, event, listener }) => {
client[once ? 'once' : 'on'](event, listener(client, config));
});
// Create listeners from the event files.
client.generateErrorMessage = (errorMsg, avatarURL) => ({
embeds: [{
title: '<:AnitroxError:809651936563429416> Error',
color: 13632027,
footer: {
icon_url: avatarURL,
text: config.footerTxt
},
fields: [
{
name: 'Something went wrong!',
value: errorMsg
}
]
}]
});
// Error message generator.
client.updater = require('./functions/updateCheck.js')(); // da update checker (real)
client.login(process.env.TOKEN);
// Login to Discord!