Collectors

Hey guys , how u doin. dont have a code issue , more of a question ( not looking for an answer in code , just some guide or link of how i can solve my problems ). So some context about what im doin. I got collectors in my code that after user execute a command bot dm the user and ask the user for some info , which i gather them with Collectors. so each collector represent a step in my process. What i was wondering was , is there a way to repeat a collector or get back in code somehow?. This is my code ====> https://pastebin.com/cv7xrAUK for each embed that im asking for smth im gonna add a BACK button ( starting from step two ). and i want that back button to be like going 1 step back in the process. so if its on the step which is asking for Description , and user press back button it goes to Title step which is the collector before description. I also wanna add a skip button which user click it end that specific collector and get to next step , which i guess if i find a way to do the Back button i can make the other one easily. again , im not looking for an exact code reply , just some guide on how i can achieve this thanks in advance.
Pastebin
const { Client, ChatInputCommandInteraction, SlashCommandBuilder...
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.
3 Replies
d.js toolkit
d.js toolkit4d 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
NyR
NyR4d ago
What I like to do is use promise based collector in a function that recursively calls itself after completion of each step. Tracking what step the user is on (index) and having the data in an array to get the question for that index (step). You minus/add the index in case of skip/prev, so something like this
const data =[....];
async function something(index = 0) {
const d = data[index];
if (!d) return;
const int = await <Message>.awaitMessageComponents({....});

// do whatever you want to do with that, and if it passess
return something(index++)
// or subtract depending on what was selected
}
const data =[....];
async function something(index = 0) {
const d = data[index];
if (!d) return;
const int = await <Message>.awaitMessageComponents({....});

// do whatever you want to do with that, and if it passess
return something(index++)
// or subtract depending on what was selected
}
Kermit
KermitOP2d ago
i can see it working in my brain i guess xD thanks for quick resposne , ill try it real soon and see how it works sry for the mention. just wanted to thank you again for the help. maanged to do what i want , ( not complete yet ) , changed what you suggested a bit , but the process is based on your suggestions. https://paste.ofcode.org/fP8CW5yBvtSwCYqjhMG9XD

Did you find this page helpful?