Kodumu ve hatayı aşağıda belirttim. Özellikleri: Yazıtura komudu olacak, rastgele yazı tura atacak. .AFK sebep komudu olacak, birisi AFK olan kullanıcıyı yanıtlarsa şu sebepten şu süre boyunca AFK yazacak. Kullanıcı AFK mesajından sonra bir mesaj yazarsa AFK modundan otomatik çıkacak, ne kadardır AFK olduğunu vs. söyleyecek. AFK mesajları da embed ile gelecek. Bunu Discord'un komut özelliği ile yapacak, modernize görünecek. "güno" veya "guno" içeren bi' kelime yazılırsa "Günaydın!" yazacak. "helü" veya "helu" içeren kelime yazılırsa "Merhaba!" yazacak. Botun boşta, online veya rahatsız etme modunu ayarlamak için. Durum komudu olacak. Örneğin. Durum idle yazınca boşta olacak. Botun etkinliğinde "komi-san can't communicate izliyor" yazacak. Mümkünse sil komudunu da ayarlamak istiyorum, dünden beri çalışmıyor. Bu arada sorunum komutlar bazen çalışıyor bazen çalışmıyor, kalıcı çalıştırmak istiyorum.
[CODE title="Kod"]const Discord = require('discord.js');
const { Client, Intents } = Discord;
// AFK ve AFK mesajı için değişkenler
let afkUsers = {};
let afkMessage = "AFK: {reason} ({duration} dakika)";
// Bot tokenı (ortam değişkeninden veya güvenli yöntemden yükleyin)
const BOT_TOKEN = process.env.BOT_TOKEN;
// Bot kurulumu
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
// Yazı tura komutu
client.on('message', async message => {
if (message.content === '.yazıtura') {
const coin = ['Yüz', 'Tura'];
const randomCoin = coin[Math.floor(Math.random() * coin.length)];
const embed = new Discord.MessageEmbed()
.setTitle('Yazı Tura')
.setDescription(
.setColor(randomCoin === 'Yüz' ? '#00ff00' : '#ff0000'); // Renkleri Yüz için yeşil, Tura için kırmızı yapar
message.channel.send({ embeds: [embed] });
}
});
// AFK komutu
client.on('message', async message => {
if (message.content.startsWith('.afk')) {
const reason = message.content.slice(4);
if (!reason) return message.channel.send('Lütfen AFK olma sebebinizi girin.');
afkUsers[message.author.id] = {
reason,
startTime: Date.now()
};
const embed = new Discord.MessageEmbed()
.setTitle('AFK')
.setDescription(
.setColor('#ff0000'); // AFK iken kırmızı
message.channel.send({ embeds: [embed] });
}
});
// AFK mesajı ve otomatik AFK çıkışı
client.on('message', async message => {
if (afkUsers[message.author.id]) {
const afkUser = afkUsers[message.author.id];
const afkDuration = Math.floor((Date.now() - afkUser.startTime) / 60000);
if (message.author !== afkUser.id) {
const embed = new Discord.MessageEmbed()
.setTitle('AFK Modundan Çıkış')
.setDescription(
.setColor('#00ff00'); // AFK'dan çıkınca yeşil
message.channel.send({ embeds: [embed] });
delete afkUsers[message.author.id];
message.channel.send(
}
}
});
// Günaydın ve Merhaba mesajları
client.on('message', async message => {
if (message.content.toLowerCase().includes('güno') || message.content.toLowerCase().includes('guno')) {
const embed = new Discord.MessageEmbed()
.setDescription('Günaydın!')
.setColor('#ffff00'); // Sarı renk
message.channel.send({ embeds: [embed] });
} else if (message.content.toLowerCase().includes('helü') || message.content.toLowerCase().includes('helu')) {
const embed = new Discord.MessageEmbed()
.setDescription('Merhaba!')
.setColor('#ffff00'); // Sarı renk
message.channel.send({ embeds: [embed] });
}
});
// Durum komutu
client.on('message', async message => {
if (message.content.startsWith('.durum')) {
const status = message.content.slice(7).toLowerCase();
if (status === 'idle') {
client.user.setActivity('Boşta', { type: 'PLAYING' });
const embed = new Discord.MessageEmbed()
.setDescription('Durumunuz boşta olarak ayarlandı.')
.setColor('#00ff00'); // Yeşil renk
message.channel.send({ embeds: [embed] });
} else if (status === 'online') {
client.user.setActivity(null);
const embed = new Discord.MessageEmbed()
.setDescription('Durumunuz çevrimiçi olarak ayarlandı.')
.setColor('#00ff00'); // Yeşil renk
message.channel.send({ embeds: [embed] });
} else if (status === 'dnd') {
client.user.setActivity('Rahatsız Etmeyin', { type: 'PLAYING' });
const embed = new Discord.MessageEmbed()
.setDescription('Durumunuz rahatsız etme olarak ayarlandı.')
.setColor('#ff0000'); // Kırmızı renk
message.channel.send({ embeds: [embed] });
} else {
const embed = new Discord.MessageEmbed()
.setDescription('Geçersiz durum. Lütfen idle, online veya dnd girin.')
.setColor('#ff0000'); // Kırmızı renk
message.channel.send({ embeds: [embed] });
}
}
});
// Etkinlik mesajı
client.user.setActivity('Komi-San Can't Communicate İzliyor', { type: 'WATCHING' });
TOKEN GİZLİ
[/CODE]
[CODE title="Hata"]C:\dcbot\Komisan\index.cjs:12
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
^
TypeError: Cannot read properties of undefined (reading 'FLAGS')
at Object.<anonymous> (C:\dcbot\Komisan\index.cjs:12:47)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49
Node.js v20.15.0[/CODE]
@Vavien.[/embed][/embed][/embed][/embed][/embed][/embed][/embed][/embed][/embed]
[CODE title="Kod"]const Discord = require('discord.js');
const { Client, Intents } = Discord;
// AFK ve AFK mesajı için değişkenler
let afkUsers = {};
let afkMessage = "AFK: {reason} ({duration} dakika)";
// Bot tokenı (ortam değişkeninden veya güvenli yöntemden yükleyin)
const BOT_TOKEN = process.env.BOT_TOKEN;
// Bot kurulumu
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
// Yazı tura komutu
client.on('message', async message => {
if (message.content === '.yazıtura') {
const coin = ['Yüz', 'Tura'];
const randomCoin = coin[Math.floor(Math.random() * coin.length)];
const embed = new Discord.MessageEmbed()
.setTitle('Yazı Tura')
.setDescription(
**Kazanan:** ${randomCoin}).setColor(randomCoin === 'Yüz' ? '#00ff00' : '#ff0000'); // Renkleri Yüz için yeşil, Tura için kırmızı yapar
message.channel.send({ embeds: [embed] });
}
});
// AFK komutu
client.on('message', async message => {
if (message.content.startsWith('.afk')) {
const reason = message.content.slice(4);
if (!reason) return message.channel.send('Lütfen AFK olma sebebinizi girin.');
afkUsers[message.author.id] = {
reason,
startTime: Date.now()
};
const embed = new Discord.MessageEmbed()
.setTitle('AFK')
.setDescription(
**Kullanıcı:** ${message.author.username}\n**Sebep:** ${reason}).setColor('#ff0000'); // AFK iken kırmızı
message.channel.send({ embeds: [embed] });
}
});
// AFK mesajı ve otomatik AFK çıkışı
client.on('message', async message => {
if (afkUsers[message.author.id]) {
const afkUser = afkUsers[message.author.id];
const afkDuration = Math.floor((Date.now() - afkUser.startTime) / 60000);
if (message.author !== afkUser.id) {
const embed = new Discord.MessageEmbed()
.setTitle('AFK Modundan Çıkış')
.setDescription(
**Kullanıcı:** ${message.author.username}\n**Sebep:** ${afkUser.reason}\n**Süre:** ${afkDuration} dakika).setColor('#00ff00'); // AFK'dan çıkınca yeşil
message.channel.send({ embeds: [embed] });
delete afkUsers[message.author.id];
message.channel.send(
AFK modundan çıktınız. (${afkDuration} dakika afk oldunuz));}
}
});
// Günaydın ve Merhaba mesajları
client.on('message', async message => {
if (message.content.toLowerCase().includes('güno') || message.content.toLowerCase().includes('guno')) {
const embed = new Discord.MessageEmbed()
.setDescription('Günaydın!')
.setColor('#ffff00'); // Sarı renk
message.channel.send({ embeds: [embed] });
} else if (message.content.toLowerCase().includes('helü') || message.content.toLowerCase().includes('helu')) {
const embed = new Discord.MessageEmbed()
.setDescription('Merhaba!')
.setColor('#ffff00'); // Sarı renk
message.channel.send({ embeds: [embed] });
}
});
// Durum komutu
client.on('message', async message => {
if (message.content.startsWith('.durum')) {
const status = message.content.slice(7).toLowerCase();
if (status === 'idle') {
client.user.setActivity('Boşta', { type: 'PLAYING' });
const embed = new Discord.MessageEmbed()
.setDescription('Durumunuz boşta olarak ayarlandı.')
.setColor('#00ff00'); // Yeşil renk
message.channel.send({ embeds: [embed] });
} else if (status === 'online') {
client.user.setActivity(null);
const embed = new Discord.MessageEmbed()
.setDescription('Durumunuz çevrimiçi olarak ayarlandı.')
.setColor('#00ff00'); // Yeşil renk
message.channel.send({ embeds: [embed] });
} else if (status === 'dnd') {
client.user.setActivity('Rahatsız Etmeyin', { type: 'PLAYING' });
const embed = new Discord.MessageEmbed()
.setDescription('Durumunuz rahatsız etme olarak ayarlandı.')
.setColor('#ff0000'); // Kırmızı renk
message.channel.send({ embeds: [embed] });
} else {
const embed = new Discord.MessageEmbed()
.setDescription('Geçersiz durum. Lütfen idle, online veya dnd girin.')
.setColor('#ff0000'); // Kırmızı renk
message.channel.send({ embeds: [embed] });
}
}
});
// Etkinlik mesajı
client.user.setActivity('Komi-San Can't Communicate İzliyor', { type: 'WATCHING' });
TOKEN GİZLİ
[/CODE]
[CODE title="Hata"]C:\dcbot\Komisan\index.cjs:12
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
^
TypeError: Cannot read properties of undefined (reading 'FLAGS')
at Object.<anonymous> (C:\dcbot\Komisan\index.cjs:12:47)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49
Node.js v20.15.0[/CODE]
@Vavien.[/embed][/embed][/embed][/embed][/embed][/embed][/embed][/embed][/embed]
Son düzenleyen: Moderatör: