Discord Bot Error | ReferenceError: bot is not defined at Object.<anonymous>?
Hallo zusammen,
ich habe einen Konsolen
Error bei meinem Discord Musik bot. Könnte mir vielleicht jemand helfen?
Ich bedanke mich schonmal im voraus.
LG Julian
Der Error:
ReferenceError: bot is not defined
at Object.<anonymous> (/home/runner/BUGCRAFT-Musik-bot/index.js:8:1)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
index.js
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
const config = require('./settings.json');
const { loadCommands } = require('./utils/loadCommands');
const DisTube = require('distube')
bot.distube = new DisTube(bot, { searchSongs: false, emitNewSongOnly: true });
bot.distube
.on("playSong", (message, queue, song) => message.channel.send(
`Playing \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${song.user}`
))
.on("addSong", (message, queue, song) => message.channel.send(
`Added ${song.name} - \`${song.formattedDuration}\` to the queue by ${song.user}`
))
require('./utils/loadEvents')(bot);
bot.commands = new Discord.Collection();
bot.aliases = new Discord.Collection();
loadCommands(bot);
bot.login(config.token);
Hier noch ein Bild:
1 Antwort
Vom Fragesteller als hilfreich ausgezeichnet
Von gutefrage auf Grund seines Wissens auf einem Fachgebiet ausgezeichneter Nutzer
programmieren
Wie es die Fehlermeldung schon sagt, wurde die Variable bot von dir nicht definiert. Da damit wohl das Client-Objekt angesprochen werden soll, müsstest du lediglich den Namen der client-Variable gegen bot ersetzen.
const bot = new Client({ // etc. ...