wacuus
wacuus
DIAdiscord.js - Imagine an app
Created by wacuus on 1/5/2025 in #djs-questions
Why am i have something like this
No description
9 replies
DIAdiscord.js - Imagine an app
Created by wacuus on 1/4/2025 in #djs-questions
My embed doenst work #embeds
my embeds dont send, but messages usually do. I tried to change the code and looked for help with gpt but emebed still doesnt work /:
const Discord = require('discord.js');
const fs = require('fs');

const client = new Discord.Client({ intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.MessageContent
]});

client.commands = new Discord.Collection();

const commandfolders = fs.readdirSync('./commands');

for (const folder of commandfolders) {
const commandFiles = fs.readdirSync(`./commands/${folder}`).filter(file => file.endsWith('js'));

for (const file of commandFiles) {
const command = require(`./commands/${folder}/${file}`);
client.commands.set(command.name, command);
}
}

const prefix = '!';

client.once('ready', () => {
console.log(`Logged in as ${client.user.tag} (bot is online)`);
client.user.setActivity('wacuus', { type: 'WATCHING' });
});

client.on('messageCreate', async message => {
console.log(`Message received: ${message.content}`); // Logging the message

if (!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();

console.log(`Command detected: ${commandName}`); // Logging the command name

if (!client.commands.has(commandName)) {
console.log(`Command not found: ${commandName}`); // If the command doesn't exist
return;
}

const command = client.commands.get(commandName);

try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('Oops... Something went wrong, and your command could not be executed.');
}

console.log('Loaded commands:');
client.commands.forEach((command, name) => {
console.log(`- ${name}`);
});
});

client.login('YOUR_BOT_TOKEN');
const Discord = require('discord.js');
const fs = require('fs');

const client = new Discord.Client({ intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.MessageContent
]});

client.commands = new Discord.Collection();

const commandfolders = fs.readdirSync('./commands');

for (const folder of commandfolders) {
const commandFiles = fs.readdirSync(`./commands/${folder}`).filter(file => file.endsWith('js'));

for (const file of commandFiles) {
const command = require(`./commands/${folder}/${file}`);
client.commands.set(command.name, command);
}
}

const prefix = '!';

client.once('ready', () => {
console.log(`Logged in as ${client.user.tag} (bot is online)`);
client.user.setActivity('wacuus', { type: 'WATCHING' });
});

client.on('messageCreate', async message => {
console.log(`Message received: ${message.content}`); // Logging the message

if (!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();

console.log(`Command detected: ${commandName}`); // Logging the command name

if (!client.commands.has(commandName)) {
console.log(`Command not found: ${commandName}`); // If the command doesn't exist
return;
}

const command = client.commands.get(commandName);

try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('Oops... Something went wrong, and your command could not be executed.');
}

console.log('Loaded commands:');
client.commands.forEach((command, name) => {
console.log(`- ${name}`);
});
});

client.login('YOUR_BOT_TOKEN');
Version: v22.12.0
15 replies