Dünden beri bunu düzeltmeye uğraşıyorum, sırf bunun için bottaki 21 komudu bozdum. Yardımcı olabilir misiniz? AFK komudum var ve bu embed, .afk sebep yazınca bu hatayı alıyorum. Tam hata:
[CODE title="HATA"]C:\dcbot\Komisan\node_modules\discord.js\src\rest\RequestHandler.js:154
throw new DiscordAPIError(request.path, data, request.method, res.status);
^
DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (C:\dcbot\Komisan\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async RequestHandler.push (C:\dcbot\Komisan\node_modules\discord.js\src\rest\RequestHandler.js:39:14) {
method: 'post',
path: '/channels/1230606508606226562/messages',
code: 50006,
httpStatus: 400
}
Node.js v20.15.0[/CODE]
Index:
AFK.js:
Sürümüm 12.5.3 bu arada.
@brkdnmz @sahnelerde @umut
[CODE title="HATA"]C:\dcbot\Komisan\node_modules\discord.js\src\rest\RequestHandler.js:154
throw new DiscordAPIError(request.path, data, request.method, res.status);
^
DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (C:\dcbot\Komisan\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async RequestHandler.push (C:\dcbot\Komisan\node_modules\discord.js\src\rest\RequestHandler.js:39:14) {
method: 'post',
path: '/channels/1230606508606226562/messages',
code: 50006,
httpStatus: 400
}
Node.js v20.15.0[/CODE]
Index:
Kod:
const Discord = require('discord.js');
const fs = require('fs');
const client = new Discord.Client();
const prefix = '.'; // Komutlar için kullanılacak önek
client.commands = new Discord.Collection();
client.AFK = new Map(); // AFK koleksiyonunu burada tanımlayın
// Komut dosyalarını yükleme
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.once('ready', () => {
console.log('Bot hazır, çalışıyor!');
client.user.setActivity('Komi-San Can\'t Communicate', { type: 'WATCHING' });
});
client.on('message', message => {
if (message.author.bot) return;
// AFK kullanıcı kontrolü
if (client.AFK.has(message.author.id)) {
const afkData = client.AFK.get(message.author.id);
const afkDuration = (Date.now() - afkData.time) / 1000; // saniye cinsinden süre
client.AFK.delete(message.author.id);
const embed = new Discord.MessageEmbed()
.setTitle('AFK Modundan Çıkıldı')
.setDescription(`**Sebep:** ${afkData.reason}\n**Süre:** ${Math.floor(afkDuration)} saniye`)
.setColor('#00ff00');
message.channel.send(embed).catch(console.error);
}
// Başka bir kullanıcıyı etiketleme kontrolü
if (message.mentions.users.size > 0) {
message.mentions.users.forEach(user => {
if (client.AFK.has(user.id)) {
const afkData = client.AFK.get(user.id);
const afkDuration = (Date.now() - afkData.time) / 1000; // saniye cinsinden süre
const embed = new Discord.MessageEmbed()
.setTitle(`${user.tag} AFK Modunda`)
.setDescription(`**Sebep:** ${afkData.reason}\n**Süre:** ${Math.floor(afkDuration)} saniye`)
.setColor('#ff0000');
message.channel.send(embed).catch(console.error);
}
});
}
// Otomatik cevaplar
const gunaydins = ["Güno", "Guno", "Günaydın"];
const merhabas = ["Hello", "Helo", "Merhaba", "Helü", "Selam", "Helu"];
if (gunaydins.some(word => message.content.includes(word))) {
message.channel.send('Günaydın!').catch(console.error);
} else if (merhabas.some(word => message.content.includes(word))) {
message.channel.send('Merhaba!').catch(console.error);
}
// Komutlar
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
if (!client.commands.has(commandName)) return;
const command = client.commands.get(commandName);
try {
command.execute(message, args, client.AFK); // AFK koleksiyonunu buraya ekleyin
} catch (error) {
console.error(error);
message.reply('Komutu yürütmeye çalışırken bir hata oluştu!').catch(console.error);
}
});
client.login("GİZLİ");
AFK.js:
Kod:
const { MessageEmbed } = require('discord.js');
module.exports = {
name: 'afk',
description: 'Kullanıcıyı AFK moduna alır.',
execute(message, args, AFK) {
const reason = args.join(' ') || 'Sebep belirtilmedi';
AFK.set(message.author.id, { reason: reason, time: Date.now() });
const embed = new MessageEmbed()
.setTitle('AFK Moduna Geçildi')
.setDescription(`**Sebep:** ${reason}`)
.setColor('#ff0000');
message.channel.send({ embeds: [embed] });
}
};
Sürümüm 12.5.3 bu arada.
@brkdnmz @sahnelerde @umut
Son düzenleme: