const { REST } = require('@discordjs/rest'); const { Routes } = require('discord-api-types/v9'); const TOKEN = process.env.TOKEN; const GUILD = "42ctf"; const commands = [{ name: 'connect', description: 'connect to discord' }]; const rest = new REST({ version: '9' }).setToken(TOKEN); (async () => { try { console.log('Started refreshing application (/) commands.'); await rest.put( Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), { body: commands }, ); console.log('Successfully reloaded application (/) commands.'); } catch (error) { console.error(error); } })(); 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('interactionCreate', async interaction => { if (!interaction.isCommand()) return; if (interaction.commandName === 'connect') { await interaction.reply('OK!'); } }); client.login('token');