Need help with buttons

how to send a message with a set of buttons (set 1) and upon clicking a button, the message gets edited with a new set of buttons (set 2), and make set 2 functional? I have tried stuff like creating new collector, trying to collect the customId of set 2 in the same collector for set 1 but nothing works. My code currently is like https://sourceb.in/RBjdTmvmJB
28 Replies
d.js toolkit
d.js toolkit5mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
duck
duck5mo ago
there's many ways to achieve this, including using a second collector putting aside the fact that the section with the second collector is currently commented out, it seems as though you're accessing the nonexistent matchResponse, and you may also run into some scoping issues regarding confirmation in your catch block please put together something you believe would work, then we can work through why it doesn't
ItzDaSrijan
ItzDaSrijan5mo ago
matchResponse was initially defined as sending a new message upon clicking start button and it was supposed to be editing the new message upon choosing a move, since it didn't work I commented it out and tried editing the initial message using same collector for all buttons
duck
duck5mo ago
well awaitMessageComponent, the promisified component interaction collector, only collects one component interaction and resolves when it's done so if you wanted to handle everything with one collector, you'd need to use the standard event-based collector createMessageComponentCollector
ItzDaSrijan
ItzDaSrijan5mo ago
hmm, I think I'll go with 2nd collector itself
duck
duck5mo ago
just as a note, <Interaction>.reply() resolves in an InteractionResponse if you don't specify fetchReply: true, and collectors created from InteractionResponses currently have a couple issues I believe this case may not run into them, but for most cases it's recommended to specify fetchReply: true so that it resolves in the Message sent instead
ItzDaSrijan
ItzDaSrijan5mo ago
seems more neat hm I've made modifications to the code: https://sourceb.in/XyWzf8GU9h using 2nd collector right now the issue is, it edits the initial message and sends a new message with embeds and attack component but it only accepts the first click any click after that leads to interaction failed message there's no error in console
duck
duck5mo ago
the first click as in the start/cancel buttons? or the first click of each of punch/kick/surrender?
ItzDaSrijan
ItzDaSrijan5mo ago
this one
duck
duck5mo ago
that's because as mentioned, awaitMessageComponent only collects one component interaction if you want to use a collector to handle more than one, you'd need to use the standard event-based collector createMessageComponentCollector
ItzDaSrijan
ItzDaSrijan5mo ago
ohhh is there any guides for that?
d.js docs
d.js docs5mo ago
guide Popular Topics: Collectors - Interaction collectors read moremethod Message#createMessageComponentCollector() Creates a message component interaction collector.
ItzDaSrijan
ItzDaSrijan5mo ago
alright
duck
duck5mo ago
(it's roughly the same options as awaitMessageComponent)
ItzDaSrijan
ItzDaSrijan5mo ago
so you are suggesting I should use createMessageComponentCollector for punch/kick/surrender row right?
duck
duck5mo ago
sure
ItzDaSrijan
ItzDaSrijan5mo ago
okay thanks! I'ma try it btw if I give time parameter as 30_000 will it collect only for 30s or it will start the timer after every click
duck
duck5mo ago
the time option is just a standard time limit if you want it to reset each time the collector collects something, you should use the idle option
d.js docs
d.js docs5mo ago
interface CollectorOptions Options to be applied to the collector.
ItzDaSrijan
ItzDaSrijan5mo ago
ohh oke
duck
duck5mo ago
putting aside how awkwardly message appears to be defined, <TextChannel>.send() is asynchronous you were previously awaiting it <Interaction>.followUp() also exists and sends a follow up message through the interaction webhook if you'd prefer to go through the interaction
ItzDaSrijan
ItzDaSrijan5mo ago
I didn't know that how should I define it I have no idea
mushtaq
mushtaq5mo ago
why dont create message component collectar using interaction not message
ItzDaSrijan
ItzDaSrijan5mo ago
well I did something and its working now https://sourceb.in/Ue7AZT3d07 oh there's 2 collect events lemme remove one
mushtaq
mushtaq5mo ago
nice
ItzDaSrijan
ItzDaSrijan5mo ago
well I have a javascript doubt but dont feel its worth making a post so I'll ask here how do I import functions and use from other files?
treble/luna
treble/luna5mo ago
thats basic js, #rules 3 #resources
Want results from more Discord servers?
Add your server
More Posts
How to update about me?How to update the bot `about me` using the djs api? I'm referring that 'description' section which Hosting on Deno DeployI'm hosting my bot on `Deno Deploy` https://deno.com/deploy it's working great but after some time iSlash Command registered but application cannot locate it when calledTrying to update an older bot to use slash commands and I have run into an issue when responding to Error [Object object]In my bot discord i have a defaultrole system, he add the role when a guy join but i add a reason anDiscordAPIError[50013]: Missing PermissionsI have a timeout command my bot has all the permissions it needs so I dont know why im getting this Slash command working but still replying with "The application did not respond"the command works but before its sent it responds with "The application did not respond". ```js coHi i am currently trying to fetch json data from an api using slash commands but it keeps erroring```js const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const { SlashCommandBuildRecommendations for good boilerplate/template projectsHi! New to Discord.js, _very_ familiar with JavaScript/TypeScript. I was hoping to write a Discord bCollection problemIs there any easy way to modify an array that is placed as a value in an Collection object?hey iam builduin a ticket system for my bot with slash command and deploy command buti hav an errorit works fine and it shows the slash command in discord but when i execute it it says this error Er