From b562c4ea5772139e06b0294c24829b4e3a4c2bee Mon Sep 17 00:00:00 2001 From: Tutur33 Date: Tue, 13 Feb 2024 21:41:14 +0100 Subject: [PATCH] intents --- main.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/main.js b/main.js index 995a18b..1273163 100644 --- a/main.js +++ b/main.js @@ -1,15 +1,25 @@ -const Discord = require('discord.js'); require('dotenv').config(); +const { Client, GatewayIntentBits } = require('discord.js'); -const client = new Discord.Client(); - -client.on('ready', () => { - console.log(`Bot is ready as: ${client.user.tag}`); +const client = new Client({ + intents: [ + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMessages, + GatewayIntentBits.MessageContent, + GatewayIntentBits.GuildMembers, + ], }); -client.on('message', message => { - if (message.content === 'ping') { - message.reply('pong'); + +client.on('ready', () => { + console.log(`Logged in as ${client.user.tag}!`); +}); + +client.on('interactionCreate', async interaction => { + if (!interaction.isChatInputCommand()) return; + + if (interaction.commandName === 'ping') { + await interaction.reply('Pong!'); } });