Why buttons doesn't worked after bot restart?
Why if the bot sends a button message and is restarted. The button no longer works. Is it possible to change this somehow?
20 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.How are you responding to the buttons?
if (confirmation.customId === "......")
Can you show more code than that please
client.on("guildMemberAdd", async (member) => {
console.log(
});
Dołączył ${member}
);
await member.roles.add("1109553637488873553");
await member.roles.add("1039653655873335316");
await member.roles.add("1039277232125911162");
await member.roles.add("1097599833579192511");
await member.roles.add("1114601901783257198");
const channel = member.guild.channels.cache.get("1039215859329142935");
const buttons = new Discord.ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId(przywitaj
)
.setLabel(👋 Bądź pierwszy. Przywitaj się
)
.setStyle(ButtonStyle.Success)
);
const embed = new EmbedBuilder()
.setTitle("NOWY UŻYTKOWNIK")
.setDescription(${member} dołączył na serwer
)
.setColor("#54d16d");
const response = await channel.send({
embeds: [embed],
components: [buttons],
});
const confirmation = await response.awaitMessageComponent({ time: null });
if (confirmation.customId === "przywitaj") {
console.log(${confirmation.user} wysłał wiadomość powtialną
);
const ok = new EmbedBuilder()
.setTitle("WIADOMOŚĆ POWITALNA")
.setDescription(Została wysłana na kanale <#1109940604311437372>
)
.setColor("#54d16d");
const channel2 = member.guild.channels.cache.get("1109940604311437372");
channel2.send(
Witaj ${member}! Dostałeś wiadomość powtitalną od ${confirmation.user}
);
confirmation.reply({ embeds: [ok], ephemeral: true });
}
});
pls use a pastebin
how xD?
Or just code blocks atleast
Codeblocks:
```js
const Discord = require("discord.js");
// further code
```
becomes
Inline Code:
`console.log('inline!');` becomes
console.log('inline!');
Pastebin
Pastebin.com - #1 paste tool since 2002!
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin
client.on("guildMemberAdd", async (member) => { console.log(`Dołąc...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
well your collector would be gone after a restart so your best guess would be to listen to the interactioCreate event
mhm just listen for the event and check if the interaction is a button and do your thing
I had something like that in my events folder, but I not too sure how it works and use it
Pastebin
const { Events } = require('discord.js');module.exports = { name: E...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Okay then what should I put in interaction.isButton to have it work?
do what your button is supposed to do when it is clicked
send a message on specific channel
and I would like the user to be able to click it only once
Only that it must yet retrieve the name of the user who joined the server. Because his nickname is supposed to be in this message
u could use a map for that or a collection
but it would reset on bot restart
so a db is ideal
then put in the code for that