I'm new to this coding thing and I have this code for a discord bot that has a feature that should be able to join the discord call and play music. Whenever I attempted to make the bot join and play music by doing "?play (music) " it joins the call (which is good) but then doesn't play any music and gives me this error code,
"UnhandledPromiseRejectionWarning: Unhandled promise rejection. This
error originated either by throwing inside of an async function
without a catch block, or by rejecting a promise which was not handled
with .catch(). To terminate the node process on unhandled promise
rejection, use the CLI flag --unhandled-rejections=strict
"
Not sure what to do to fix this, here's my code which I think is affecting the bot.
bot.on("message", async message => {
const prefix = '?' ;
const args = message.content. slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if (command === 'play') {
let track = await bot.player.play(message.member.voice.channel, args[0], message.member.user.tag);
message.channel.send(`Currently playing ${track.name}! - Requested by ${track.requestedBy}`);
}
if (command === 'stop') {
let track = await bot.player.stop(message.guild.id);
message.channel.send(`STOPPED`);
}
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…