Discord bot komutlar çalışmıyor

SsLiqht

Hectopat
Katılım
3 Şubat 2022
Mesajlar
78
Çözümler
2
Daha fazla  
Sistem Özellikleri
Ryzen 5 5600
RTX 4060
Cinsiyet
Erkek
Meslek
Öğrenci
Selam kendi sunucum için bir Discord bot yaptım çok uğraşmadım sadece sa as yazma ses kanalında durma falan eklemiştim.
Biraz daha geliştirmek istiyorum şimdiye kadar tüm komutları bot.js dosyasına yazdım.
Komutlar dosyası oluşturdum ve ve internetten baktığım rastgele bir komutu attım zar atma komutu.
config.jsden prefix ayarladım ama komutu kullanamıyorum !Zarat yazdığımda hiçbir şey olmuyor.
Bunun sebebi nedir nasıl çözerim?

zar.js:
Kod:
const Discord = require('discord.js')

exports.run = async(client, message, args) => {
const cse = new Discord.EmbedBuilder()
.setColor(Discord.Colors.Blue)
.setTitle('🎲 Zarın: ' + doMagicDiceVoodoo())
await message.reply({embeds: [cse]}).catch(e => {
console.log("HATA ALIYORUM: "+e)
})

function doMagicDiceVoodoo() {
var rand = ['1', '2', '3', '4', '5', '6'];

return rand[Math.floor(Math.random()*rand.length)];
}
}

exports.conf = {
aliases: ['zar']
};

exports.help = {
name: 'zarat'
};
bot.js:

Kod:
const { Client, GatewayIntentBits, Partials } = require("discord.js");
const config = require("./config.js");
const client = new Client({
  partials: [
    Partials.Message, // for message
    Partials.Channel, // for text channel
    Partials.GuildMember, // for guild member
    Partials.Reaction, // for message reaction
    Partials.GuildScheduledEvent, // for guild events
    Partials.User, // for discord user
    Partials.ThreadMember, // for thread member
  ],
  intents: [
    GatewayIntentBits.Guilds, // for guild related things
    GatewayIntentBits.GuildMembers, // for guild members related things
    GatewayIntentBits.GuildBans, // for manage guild bans
    GatewayIntentBits.GuildEmojisAndStickers, // for manage emojis and stickers
    GatewayIntentBits.GuildIntegrations, // for discord Integrations
    GatewayIntentBits.GuildWebhooks, // for discord webhooks
    GatewayIntentBits.GuildInvites, // for guild invite managing
    GatewayIntentBits.GuildVoiceStates, // for voice related things
    GatewayIntentBits.GuildPresences, // for user presence things
    GatewayIntentBits.GuildMessages, // for guild messages things
    GatewayIntentBits.GuildMessageReactions, // for message reactions things
    GatewayIntentBits.GuildMessageTyping, // for message typing things
    GatewayIntentBits.DirectMessages, // for dm messages
    GatewayIntentBits.DirectMessageReactions, // for dm message reaction
    GatewayIntentBits.DirectMessageTyping, // for dm message typinh
    GatewayIntentBits.MessageContent, // enable if you need message content things
  ],
});

module.exports = client;

require("./events/message.js")
require("./events/ready.js")

client.on("ready", () => {
  client.user.setActivity(""`)
    console.log("botun olan Liqht aktif!");
});

client.on('messageCreate', msg => {
    if (msg.content.toLowerCase() === 'sa') {
      msg.reply('Aleyküm Selam, hoşgeldin.');
    }
    if (msg.content.toLowerCase() === 'selamün aleyküm') {
      msg.reply('Aleyküm Selam, hoşgeldin.');
    }
    if (msg.content.toLowerCase() === 'selam') {
      msg.reply('Aleyküm Selam, hoşgeldin.');
    }
    if (msg.content.toLowerCase() === 'selamun aleyküm') {
      msg.reply('Aleyküm Selam, hoşgeldin.');
    }
    if (msg.content.toLowerCase() === "lonca"){
      msg.reply("")
     
    }
   
  });
//
const { joinVoiceChannel } = require('@discordjs/voice')
client.on('ready', () => {
  let channel = client.channels.cache.get("")
 

      const VoiceConnection = joinVoiceChannel({
          channelId: channel.id,
          guildId: channel.guild.id,
          adapterCreator: channel.guild.voiceAdapterCreator
  });
})
//


client.login("");
config.js:

Kod:
module.exports = {
    token: "",
    prefix: "!"
}
 
Son düzenleyen: Moderatör:
Token: "" yazan yeri şöyle yapın token: "bot tokeniniz"

Sorun düzelecektir.

Zaten yazıyor botum aktif bot.js kısmına eklediğim sa as komutu sesde 7/24 durma falan çalışıyor. Komutlar klasçrüne attığım komutları nasıl çalıştıracağım onu bilmiyorum. bot.js içindede config.js içindede tokenim yazıyor sorun çıkarırmı bilmiyorum ikisinede yazmıştım.
 
Bir de böyle deneyin:
bot.js:
Kod:
const { Client, Intents } = require('discord.js');
const config = require('./config.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('messageCreate', async (message) => {
  if (!message.content.startsWith(config.prefix) || message.author.bot) return;

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

  if (command === 'zarat') {
    const zar = require('./komutlar/zar.js');
    zar.run(client, message, args);
  }
});

client.login(config.token);
zar.js:
Kod:
const Discord = require('discord.js')

exports.run = async(client, message, args) => {
  const cse = new Discord.MessageEmbed()
    .setColor("BLUE")
    .setTitle('🎲 Zarın: ' + doMagicDiceVoodoo());

  await message.reply({ embeds: [cse] }).catch(e => {
    console.log("HATA ALIYORUM: " + e)
  })

  function doMagicDiceVoodoo() {
    var rand = ['1', '2', '3', '4', '5', '6'];
    return rand[Math.floor(Math.random() * rand.length)];
  }
}

exports.conf = {
  aliases: ['zarat']
};

exports.help = {
  name: 'zarat'
};
Ayrıca config.js dosyasındaki token ve channel değerlerini de uygun şekilde doldurmanız gerekiyor. Umarım yardımcı olabilmişimdir. Başka bir sorunuz olursa tekrar yazabilirsiniz
 

Technopat Haberler

Yeni konular

Geri
Yukarı