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
- 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!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');
}
});
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:
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?
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•7mo ago
Message Not Public
Sign In & Join Server To View
Deploy-commands.js code?
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
I'll send ss
Here's the error I'm encountering
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
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 ofcUnknown User•7mo ago
Message Not Public
Sign In & Join Server To View
Well I can't send msg cause nitro purposes
But I'll ss
Oh ye
Made pdf
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
Yup
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
Ok
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
So can you tell me where I am importing client the 2nd time?
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
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.
Ye I need to fr