bot/bot.js

52 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-02-16 11:32:42 +01:00
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
2022-02-16 12:28:10 +01:00
const { Client, Intents } = require('discord.js');
const CLIENT = new Client({ intents: [Intents.FLAGS.GUILDS] });
2022-02-16 16:06:25 +01:00
const TOKEN = "OTQzNTA2NTgxMjkzNzc2OTQ3.Yg0C-g.XOjFinUc-Gt1gwtrSILPb0Mlspo";
const GUILD = "42CTFDEV";
2022-02-16 11:32:42 +01:00
const commands = [{
2022-02-16 12:28:10 +01:00
name: 'connect',
2022-02-16 16:06:25 +01:00
description: 'connect to discord',
2022-02-16 11:32:42 +01:00
}];
2022-02-16 12:28:10 +01:00
const roles = new Map([
2022-02-16 16:06:25 +01:00
['top1', "798638767359524875"],
['top10', "801787467064672286"],
['top50', "803729539145924649"]
2022-02-16 12:28:10 +01:00
]);
2022-02-16 11:32:42 +01:00
const rest = new REST({ version: '9' }).setToken(TOKEN);
(async () => {
2022-02-16 12:28:10 +01:00
try {
console.log('Started refreshing application (/) commands.');
2022-02-16 11:32:42 +01:00
await rest.put(
2022-02-16 16:06:25 +01:00
Routes.applicationGuildCommands('943506581293776947', '943459216901955604'),
2022-02-16 12:28:10 +01:00
{ body: commands },
2022-02-16 11:32:42 +01:00
);
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
2022-02-16 16:06:25 +01:00
var guild;
CLIENT.on('ready', () => {
console.log(`Logged in as ${CLIENT.user.tag}!`);
guild = CLIENT.guilds.resolve(GUILD);
2022-02-16 11:32:42 +01:00
});
2022-02-16 16:06:25 +01:00
CLIENT.on('interactionCreate', async interaction => {
2022-02-16 12:28:10 +01:00
if (!interaction.isCommand()) return;
2022-02-16 11:32:42 +01:00
2022-02-16 12:28:10 +01:00
if (interaction.commandName === 'connect') {
await interaction.reply('OK!');
}
2022-02-16 11:32:42 +01:00
});
2022-02-16 16:06:25 +01:00
CLIENT.login(TOKEN);