-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (34 loc) · 1.31 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
const fs = require('fs');
config = require('dotenv').config();
const { Client, GatewayIntentBits, Partials } = require("discord.js");
const router = require('./botFunctions/_mainRouter');
const leaderboard_refresh = require('./botFunctions/leaderboardRefresh');
require('./utilities');
require('./deploy-commands.js');
const client = new Client({
intents: [
GatewayIntentBits.DirectMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
partials: [Partials.Channel],
}); client.login(process.env.DISCORD_TOKEN);
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
let commandName = interaction.commandName;
let commandGroup = " " + interaction.options.getSubcommandGroup();
let commandSubcommand = " " + interaction.options.getSubcommand(false);
if (!interaction.options.getSubcommandGroup()) {
commandGroup = '';
}
console.log(`Received command: ${commandName}${commandGroup}${commandSubcommand}`);
router(config, interaction);
});
client.on('interactionCreate', interaction => {
if (!interaction.isButton()) return;
if (interaction.customId === 'refresh') {
leaderboard_refresh(config, interaction);
}
});