willowissnake (ssss)
DIAdiscord.js - Imagine an app
•Created by willowissnake (ssss) on 9/16/2023 in #djs-questions
Bot not replying
Hi! My bot is not replying. Message intents are enabled, I used a tutorial from a year ago and haven't been able to find out where it all goes wrong </3
I'm new to discord.js
main.js
Commands/ping.js
const Discord = require('discord.js');
const path = require('node:path');
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.commands = new Collection();
client.once('ready', () => {
console.log(`⚠️ | The client is now online.`);
});
const fs = require('fs');
const prefix = 's!';
const commandsPath = path.join(__dirname, 'commands');
client.commands = new Discord.Collection();
const commands = fs.readdirSync('./Commands').filter(file => file.endsWith('.js'));
for (file of commands) {
const filePath = path.join(commandsPath, file);
const commandName = file.split('.')[0];
const command = require(`./Commands/${commandName}`);
client.commands.set (commandName, command);
};
client.on('messageCreate', message => {
if (message.content.startsWith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const commandName = args.shift();
const command = client.commands.get(commandName);
if (!command) {
return message.reply(':question: | Sorry, that command doesn\'t exist!');
}
command.run (client, message, args);
}
});
client.login('CLIENT KEY IS HERE, IVE JUST REMOVED IT FOR OBVIOUS REASONS');
const Discord = require('discord.js');
const path = require('node:path');
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.commands = new Collection();
client.once('ready', () => {
console.log(`⚠️ | The client is now online.`);
});
const fs = require('fs');
const prefix = 's!';
const commandsPath = path.join(__dirname, 'commands');
client.commands = new Discord.Collection();
const commands = fs.readdirSync('./Commands').filter(file => file.endsWith('.js'));
for (file of commands) {
const filePath = path.join(commandsPath, file);
const commandName = file.split('.')[0];
const command = require(`./Commands/${commandName}`);
client.commands.set (commandName, command);
};
client.on('messageCreate', message => {
if (message.content.startsWith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const commandName = args.shift();
const command = client.commands.get(commandName);
if (!command) {
return message.reply(':question: | Sorry, that command doesn\'t exist!');
}
command.run (client, message, args);
}
});
client.login('CLIENT KEY IS HERE, IVE JUST REMOVED IT FOR OBVIOUS REASONS');
module.exports.run = (client, message, args) => {
message.reply('🏓 | Pong!');
};
module.exports.run = (client, message, args) => {
message.reply('🏓 | Pong!');
};
9 replies