botJS #1

Merged
Starthur merged 12 commits from botJS into main 2022-05-27 09:49:52 +02:00
1 changed files with 24 additions and 17 deletions
Showing only changes of commit 5c3a40598e - Show all commits

41
bot.js
View File

@ -1,23 +1,32 @@
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 = new Client({ intents: [Intents.FLAGS.GUILDS] });
const TOKEN = process.env.TOKEN; const TOKEN = process.env.TOKEN;
const GUILD = "42ctf"; const GUILD = "42ctf";
const commands = [{ const commands = [{
name: 'connect', name: 'connect',
description: 'connect to discord' description: 'connect to discord'
}]; }];
const roles = new Map([
['top1', 798638767359524875],
['top10', 801787467064672286],
['top50', 803729539145924649]
]);
const rest = new REST({ version: '9' }).setToken(TOKEN); const rest = new REST({ version: '9' }).setToken(TOKEN);
(async () => { (async () => {
try { try {
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(CLIENT_ID, GUILD_ID),
{ body: commands }, { body: commands },
); );
console.log('Successfully reloaded application (/) 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'); Client.on('ready', () => {
const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); console.log(`Logged in as ${Client.user.tag}!`);
guild = Utils.get(Client.guilds, Guild.name=GUILD);
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
}); });
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') {
await interaction.reply('OK!'); await interaction.reply('OK!');
} }
}); });
client.login('token'); Client.login(TOKEN);