-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
65 lines (51 loc) · 1.93 KB
/
Copy pathindex.js
File metadata and controls
65 lines (51 loc) · 1.93 KB
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
const { Client, GatewayIntentBits, Collection } = require('discord.js');
const fs = require('fs');
require('dotenv').config();
const { readCoinPrice, updateCoinPrice, readPriceHistory, startPriceUpdates } = require('./utils/coinPrice');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
// Load commands into a Collection
client.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
// Register all aliases (names)
command.names.forEach(name => {
client.commands.set(name, command);
});
}
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
startPriceUpdates(client);
});
const badWords = require('./utils/badwords');
client.on('messageCreate', (message) => {
// Ignore bot messages
if (message.author.bot) return;
// Check for bad words
const content = message.content.toLowerCase();
if (badWords.some(word => content.includes(word)) && message.author.id != '783036885299626015') {
message.delete();
return message.channel.send(`<@${message.author.id}>, please watch your language! Your message was deleted`);
}
// Check for commands
if (!message.content.startsWith('!')) return;
const args = message.content.slice(1).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
// Check if the command exists
const command = client.commands.get(commandName);
if (!command)
return message.reply('Unrecognized command: ' + commandName);
try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('There was an error executing that command.');
}
});
client.login(process.env.BOT_TOKEN);