-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (56 loc) · 2.14 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"use strict";
const dotenv = require("dotenv")
const { Client, Collection, GatewayIntentBits, Options, sendTyping, ActivityType, EmbedBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
const path = require("path");
const axios = require('axios');
const slashc = require('./deploy-commands');
const fs = require("fs");
const log = require('./utils/logger');
dotenv.config();
const client = new Client({
sweepers: {
...Options.DefaultSweeperSettings,
messages: {
interval: 3600,
filter: () => message => message.author.id !== client.user.id,
},
},
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMembers
]
});
client.on("messageCreate", async (msg) => {
if (msg.author.bot) return;
if (msg.mentions.everyone || msg.mentions.here) {
return;
}
if (!msg.mentions.has(client.user)) return;
if (!msg.content.startsWith(`<@${client.user.id}>`)) return;
msg.content = msg.content.replace(/<@\d+>/g, "");
if (msg.content.length === 0) {
await msg.react("👋");
return;
}
});
client.slashCommands = new Collection();
const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
client.slashCommands.set(command.data.name, command);
} else {
log.info(`The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
const handlersDir = path.join(__dirname, './handlers');
fs.readdirSync(handlersDir).forEach(async handler => {
(await Promise.resolve(`${`${handlersDir}/${handler}`}`).then(s => __importStar(require(s)))).default(client);
});
client.login(process.env.TOKEN);