Bot core (operationel)

This commit is contained in:
RoyaLProg 2022-02-16 16:06:25 +01:00
parent 5c3a40598e
commit 01e10e4506
2 changed files with 15 additions and 13 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.vscode

26
bot.js
View File

@ -1,21 +1,20 @@
const { REST } = require('@discordjs/rest'); const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9'); const { Routes } = require('discord-api-types/v9');
const { Client, Intents } = require('discord.js'); const { Client, Intents } = require('discord.js');
const CLIENT = new Client({ intents: [Intents.FLAGS.GUILDS] }); const CLIENT = new Client({ intents: [Intents.FLAGS.GUILDS] });
const TOKEN = process.env.TOKEN; const TOKEN = "OTQzNTA2NTgxMjkzNzc2OTQ3.Yg0C-g.XOjFinUc-Gt1gwtrSILPb0Mlspo";
const GUILD = "42ctf"; const GUILD = "42CTFDEV";
const commands = [{ const commands = [{
name: 'connect', name: 'connect',
description: 'connect to discord' description: 'connect to discord',
}]; }];
const roles = new Map([ const roles = new Map([
['top1', 798638767359524875], ['top1', "798638767359524875"],
['top10', 801787467064672286], ['top10', "801787467064672286"],
['top50', 803729539145924649] ['top50', "803729539145924649"]
]); ]);
const rest = new REST({ version: '9' }).setToken(TOKEN); const rest = new REST({ version: '9' }).setToken(TOKEN);
@ -25,7 +24,7 @@ const rest = new REST({ version: '9' }).setToken(TOKEN);
console.log('Started refreshing application (/) commands.'); console.log('Started refreshing application (/) commands.');
await rest.put( await rest.put(
Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), Routes.applicationGuildCommands('943506581293776947', '943459216901955604'),
{ body: commands }, { body: commands },
); );
@ -35,12 +34,13 @@ const rest = new REST({ version: '9' }).setToken(TOKEN);
} }
})(); })();
Client.on('ready', () => { var guild;
console.log(`Logged in as ${Client.user.tag}!`); CLIENT.on('ready', () => {
guild = Utils.get(Client.guilds, Guild.name=GUILD); console.log(`Logged in as ${CLIENT.user.tag}!`);
guild = CLIENT.guilds.resolve(GUILD);
}); });
Client.on('interactionCreate', async interaction => { CLIENT.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return; if (!interaction.isCommand()) return;
if (interaction.commandName === 'connect') { if (interaction.commandName === 'connect') {
@ -48,4 +48,4 @@ Client.on('interactionCreate', async interaction => {
} }
}); });
Client.login(TOKEN); CLIENT.login(TOKEN);