my bot cannot be connect to discord

I am doing my first bot, and my first command, but my bot do an error when i execute my command
26 Replies
d.js toolkit
d.js toolkit17mo 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!
treble/luna
treble/luna17mo ago
can you show that error too and your code
cat neko
cat nekoOP17mo ago
ok
const fs = require('node:fs');
const path = require('node:path');

const { Client, Events, GatewayIntentBits, Collection } = require('discord.js');

// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

const { token } = require('./config.json');

client.commands = new Collection();
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
// Set a new item in the Collection with the key as the command name and the value as the exported module
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}




}

client.once(Events.ClientReady, c => {
console.log(`Ready! Logged in as ${c.user.tag}`);
});

client.on(Events.InteractionCreate, interaction => {
if (!interaction.isChatInputCommand()) return;
console.log(interaction)
});



client.login(token);
const fs = require('node:fs');
const path = require('node:path');

const { Client, Events, GatewayIntentBits, Collection } = require('discord.js');

// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

const { token } = require('./config.json');

client.commands = new Collection();
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
// Set a new item in the Collection with the key as the command name and the value as the exported module
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}




}

client.once(Events.ClientReady, c => {
console.log(`Ready! Logged in as ${c.user.tag}`);
});

client.on(Events.InteractionCreate, interaction => {
if (!interaction.isChatInputCommand()) return;
console.log(interaction)
});



client.login(token);
, but i don't have error, i just have the message Couldn't connect to Discord via RPC: Error: Could not connect comment faire
treble/luna
treble/luna17mo ago
can you show the error and did you deploy your commands?
cat neko
cat nekoOP17mo ago
I don't have an error.
treble/luna
treble/luna17mo ago
or well the message you get
cat neko
cat nekoOP17mo ago
Couldn't connect to discord via RCP: error: could not connect The application don't work
treble/luna
treble/luna17mo ago
did you deploy your commands and that message you get doesnt seem to come from this code
cat neko
cat nekoOP17mo ago
I try
treble/luna
treble/luna17mo ago
do you get any 'read, logged in as ....' message?
cat neko
cat nekoOP17mo ago
That not come from the code, just my bot and discord I think. Because my bot is online but the command don't reply to my slash
treble/luna
treble/luna17mo ago
. if thats all the code you have, i am assuming you do not in which case
d.js docs
d.js docs17mo ago
guide Creating Your Bot: Registering slash commands read more
treble/luna
treble/luna17mo ago
follow that
cat neko
cat nekoOP17mo ago
Ok I see the success message but the command don't work
treble/luna
treble/luna17mo ago
define dont work does the command show up at all?
cat neko
cat nekoOP17mo ago
i can chose the command but she not work
treble/luna
treble/luna17mo ago
well in the above code you dont have any code that replies to the command so yes, it will indeed not work, other than logging the interaction
cat neko
cat nekoOP17mo ago
ok but how can i fix it
treble/luna
treble/luna17mo ago
by writing code to reply to it
cat neko
cat nekoOP17mo ago
ok
treble/luna
treble/luna17mo ago
i assume you followed the guide up until this point, just keep following
cat neko
cat nekoOP17mo ago
ok I have the message
the app is not responding
the app is not responding
on my discord server
treble/luna
treble/luna17mo ago
and do you reply to the interaction
invictus
invictus17mo ago
Continue the code, bro. All you did is just logging the interaction.
cat neko
cat nekoOP17mo ago
Okk
Want results from more Discord servers?
Add your server