client.on("messageCreate", message => { if (message.content.startsWith("-play") message.content.startsWith("-P")) { const voiceChannel = message.member.voice.channel if (!voiceChannel) { return message.channel.send("You must be in a voice channel to run this command") } const voiceChannelBot = message.guild.channels.cache.find(x => x.type == "GUILD_VOICE" && x.members.has(client.user.id)) if (voiceChannelBot && voiceChannel.id != voiceChannelBot.id) { return message.channel.send("This bot is already in use in another chat") } let args = message.content.split(/\s+/) let query = args.slice(1).join(" ") if (!query) { return message.channel.send("Enter the song you want to listen to") } distube.play(voiceChannelBot || voiceChannel, query, { member: message.member, textChannel: message.channel, message: message }) client.on("messageCreate", message => { let button1 = new Discord.MessageButton() .setEmoji("") .setLabel("stop!") .setStyle("SUCCESS") .setCustomId(
buttonstop,${message.author.id}
buttonstop,${message.author.id}
) let row = new Discord.MessageActionRow() .addComponents(button1) message.channel.send({components: {row}}); } ) client.on("interactionCreate", interaction => { if (!interaction.isButton()) return if (interaction.customId.startsWith("buttonstop")) { interaction.deferUpdate() const voiceChannel = interaction.member.voice.channel if (!voiceChannel) { return interaction.reply("You must be in a voice channel to run this command") } const voiceChannelBot = interaction.guild.channels.cache.find(x => x.type == "GUILD_VOICE" && x.members.has(client.user.id)) if (voiceChannelBot && voiceChannel.id != voiceChannelBot.id) { return interaction.reply("This bot is already in use in another chat") } try { distube.stop(interaction) } catch { return interaction.reply("No songs playing") } interaction.channel.send("Bye") } }) }