From 5c3a40598e6947359c8d9c3c68426c56e82fbb00 Mon Sep 17 00:00:00 2001 From: RoyaLProg Date: Wed, 16 Feb 2022 12:28:10 +0100 Subject: [PATCH] Bot core (non operationel) --- bot.js | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/bot.js b/bot.js index b02b31a..b1837e2 100644 --- a/bot.js +++ b/bot.js @@ -1,23 +1,32 @@ const { REST } = require('@discordjs/rest'); const { Routes } = require('discord-api-types/v9'); +const { Client, Intents } = require('discord.js'); +const CLIENT = new Client({ intents: [Intents.FLAGS.GUILDS] }); + const TOKEN = process.env.TOKEN; const GUILD = "42ctf"; const commands = [{ - name: 'connect', - description: 'connect to discord' + name: 'connect', + description: 'connect to discord' }]; +const roles = new Map([ + ['top1', 798638767359524875], + ['top10', 801787467064672286], + ['top50', 803729539145924649] +]); + const rest = new REST({ version: '9' }).setToken(TOKEN); (async () => { - try { - console.log('Started refreshing application (/) commands.'); + try { + console.log('Started refreshing application (/) commands.'); await rest.put( - Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), - { body: commands }, + Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), + { body: commands }, ); console.log('Successfully reloaded application (/) commands.'); @@ -26,19 +35,17 @@ const rest = new REST({ version: '9' }).setToken(TOKEN); } })(); -const { Client, Intents } = require('discord.js'); -const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); - -client.on('ready', () => { - console.log(`Logged in as ${client.user.tag}!`); +Client.on('ready', () => { + console.log(`Logged in as ${Client.user.tag}!`); + guild = Utils.get(Client.guilds, Guild.name=GUILD); }); -client.on('interactionCreate', async interaction => { - if (!interaction.isCommand()) return; +Client.on('interactionCreate', async interaction => { + if (!interaction.isCommand()) return; - if (interaction.commandName === 'connect') { - await interaction.reply('OK!'); - } + if (interaction.commandName === 'connect') { + await interaction.reply('OK!'); + } }); -client.login('token'); +Client.login(TOKEN);