Bot not responding

So I have created my bot and the terminal is showing no errors. Only problem is that when I try to execute a command e.g. try do do !ping it won't respond with pong.
29 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Hacker249
Hacker2492mo ago
Discord.js version is v14 const { Client, GatewayIntentBits } = require('discord.js'); const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages ] }); const prefix = '!' client.login('my token'); client.on('messageCreate', message => { if (message.content.toLowerCase() === 'ping') { message.channel.send('pong'); } });
d.js docs
d.js docs2mo ago
If you aren't getting content, embeds or attachments of a message, make sure you have the MessageContent intent enabled in the Developer Portal and provide it to your client:
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});
Hacker249
Hacker2492mo ago
Here's my code When I wanted to make the bot I didn't want slash commands even though they may be a necessity Well I did try to implement slash commands But when it came to making the .env file to store stuff it said that I could not make the file I got that from a guide I will start to implement the use of slash commands to make it easier. Got any suggestions on who I should follow?
d.js docs
d.js docs2mo ago
:guide: Creating Your Bot: Creating slash commands read more
Hacker249
Hacker2492mo ago
Oh Thank you very much I'm getting a syntax error stating that Clients is already defined. Do you know how to fix this issue
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Hacker249
Hacker2492mo ago
Deploy-commands.js code?
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Hacker249
Hacker2492mo ago
I'll send ss
Hacker249
Hacker2492mo ago
No description
Hacker249
Hacker2492mo ago
Here's the error I'm encountering
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Hacker249
Hacker2492mo ago
Oh k { "token": "token", "clientId": "1224494065710530702", "guildId": "995436307507593216" } const { REST, Routes } = require('discord.js'); const { clientId, guildId, token } = require('./config.json'); const fs = require('node:fs'); const path = require('node:path'); const commands = []; const foldersPath = path.join(__dirname, 'commands'); const commandFolders = fs.readdirSync(foldersPath); for (const folder of commandFolders) { // Grab all the command files from the commands directory you created earlier const commandsPath = path.join(foldersPath, folder); const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js')); // Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment for (const file of commandFiles) { const filePath = path.join(commandsPath, file); const command = require(filePath); if ('data' in command && 'execute' in command) { commands.push(command.data.toJSON()); } else { console.log([WARNING] The command at ${filePath} is missing a required "data" or "execute" property.); } } } // Construct and prepare an instance of the REST module const rest = new REST().setToken(token); // and deploy your commands! (async () => { try { console.log(Started refreshing ${commands.length} application (/) commands.); const data = await rest.put( Routes.applicationGuildCommands(clientId, guildId), { body: commands }, ); console.log(Successfully reloaded ${data.length} application (/) commands.); } catch (error) { console.error(error); } })(); Defined token as token for security reasons ofc
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Hacker249
Hacker2492mo ago
Well I can't send msg cause nitro purposes But I'll ss
d.js docs
d.js docs2mo ago
Tag suggestion for @Hacker249: To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.
Hacker249
Hacker2492mo ago
Oh ye
Hacker249
Hacker2492mo ago
Made pdf
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Hacker249
Hacker2492mo ago
Yup
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Hacker249
Hacker2492mo ago
Ok
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Hacker249
Hacker2492mo ago
So can you tell me where I am importing client the 2nd time?
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs2mo ago
Documentation suggestion for @Hacker249: :mdn: JavaScript Guide The JavaScript Guide shows you how to use JavaScript and gives an overview of the language. If you need exhaustive information about a language feature, have a look at the JavaScript reference.
Hacker249
Hacker2492mo ago
Ye I need to fr