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
d.js toolkit
d.js toolkit2y ago
• 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.
Danial
Danial2y ago
How are you responding to the buttons?
Yoqurt
YoqurtOP2y ago
if (confirmation.customId === "......")
Danial
Danial2y ago
Can you show more code than that please
Yoqurt
YoqurtOP2y ago
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 }); }
});
wen
wen2y ago
pls use a pastebin
Yoqurt
YoqurtOP2y ago
how xD?
KAVI
KAVI2y ago
Or just code blocks atleast
d.js docs
d.js docs2y ago
Codeblocks: ```js const Discord = require("discord.js"); // further code ``` becomes
const Discord = require("discord.js");
// further code
const Discord = require("discord.js");
// further code
Inline Code: `console.log('inline!');` becomes console.log('inline!');
wen
wen2y ago
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.
Yoqurt
YoqurtOP2y ago
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.
treble/luna
treble/luna2y ago
well your collector would be gone after a restart so your best guess would be to listen to the interactioCreate event
wen
wen2y ago
mhm just listen for the event and check if the interaction is a button and do your thing
Yoqurt
YoqurtOP2y ago
I had something like that in my events folder, but I not too sure how it works and use it
Yoqurt
YoqurtOP2y ago
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.
d.js docs
d.js docs2y ago
guide Message Components: The Client#interactionCreate event read moreguide Message Components: Component interactions read more
Yoqurt
YoqurtOP2y ago
Okay then what should I put in interaction.isButton to have it work?
wen
wen2y ago
do what your button is supposed to do when it is clicked
Yoqurt
YoqurtOP2y ago
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
wen
wen2y ago
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
Want results from more Discord servers?
Add your server