button spam

client.on("messageCreate", message => { if (message.content.startsWith("-play") message.content.startsWith("-start") 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})
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")
} }) }
7 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
yuyaaici_YT
yuyaaici_YT2y ago
Hi I would have a problem that is every time this code is executed the button is spammed in chat You can repeat I did not understand
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
yuyaaici_YT
yuyaaici_YT2y ago
because I have to do that when the word -play part below appears a button
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
yuyaaici_YT
yuyaaici_YT2y ago
A ok thanks
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server
More Posts