Can someone explain me what can I do that my bot always response. If I try next day a slash command

my bot doesn't respons.
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
const dotenv = require('dotenv');
const dbconnection = require('./events/dbconnection.js');
const cocapiconnection = require('./events/cocapiconnection.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

dotenv.config();

client.commands = new Collection();
const commandsPath = path.join(__dirname, 'commands');
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);
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] Der Befehl in ${filePath} fehlt eine erforderliche "data" oder "execute" Eigenschaft.`);
}
}

const eventsPath = path.join(__dirname, 'events');
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));





for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}

client.login(process.env.token);
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
const dotenv = require('dotenv');
const dbconnection = require('./events/dbconnection.js');
const cocapiconnection = require('./events/cocapiconnection.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

dotenv.config();

client.commands = new Collection();
const commandsPath = path.join(__dirname, 'commands');
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);
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] Der Befehl in ${filePath} fehlt eine erforderliche "data" oder "execute" Eigenschaft.`);
}
}

const eventsPath = path.join(__dirname, 'events');
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));





for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}

client.login(process.env.token);
23 Replies
d.js toolkit
d.js toolkit6mo 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!
monbrey
monbrey6mo ago
None of the code here is for responding to commands
d.js docs
d.js docs6mo ago
:guide: Slash Commands: Command response methods read more
Nicolas Matheisen
Nicolas MatheisenOP6mo ago
jup but in my command folder and there are the standards from djs commands like ping or server
monbrey
monbrey6mo ago
This code here loads commands and event files It isnt responsible for the responding Or the handling
d.js docs
d.js docs6mo ago
:guide: Creating Your Bot: Command handling read more
Nicolas Matheisen
Nicolas MatheisenOP6mo ago
I think we're talking past each other. Every time I use a command the next day it says that the bot isn't responding and I don't understand why. I would like it to be able to respond 24/7
monbrey
monbrey6mo ago
Theres no reason that would happen with the default code That sounds like a hosting or crashing issue
Nicolas Matheisen
Nicolas MatheisenOP6mo ago
öhm ? ok how I can test it? I host a server from netcup
monbrey
monbrey6mo ago
You already are testing it, and its failing. Check your server for logs. If it didnt respond there must be a reason why
Nicolas Matheisen
Nicolas MatheisenOP6mo ago
hmmm nope my code have no errors or something I need to log in my app and use node . to start it
monbrey
monbrey6mo ago
And then you logout? Does it keep running?
Nicolas Matheisen
Nicolas MatheisenOP6mo ago
jup and then next day I try to use it and it don't work
monbrey
monbrey6mo ago
Theres very little me or anyone can do without some sort of logging indicating why
Nicolas Matheisen
Nicolas MatheisenOP6mo ago
No description
Nicolas Matheisen
Nicolas MatheisenOP6mo ago
this? I look the server was running all the time I can get u my login that u can look
monbrey
monbrey6mo ago
I can literally see it powering off?
Nicolas Matheisen
Nicolas MatheisenOP6mo ago
wich info do u need
monbrey
monbrey6mo ago
I dont need any more info I need you to run your bot on a server that doesnt restart This has nothing to do with discord.js
Nicolas Matheisen
Nicolas MatheisenOP6mo ago
No description
Nicolas Matheisen
Nicolas MatheisenOP6mo ago
it is :/ I don't restart it and the only one with access is me
monbrey
monbrey6mo ago
Okay, so its been running since March Theres nothing here that helps me diagnose anything If its not responding, its probably not running Figure out why Application logs Run it like node . > logs.txt so it writes stuff to file even when you're logged out
Nicolas Matheisen
Nicolas MatheisenOP6mo ago
I run debian in the server it's the command ? And if it work I can send the log tomorrow I can test it I send the liga here
Want results from more Discord servers?
Add your server