Random

Making a slashcommand having multiple possible answer and making them completly different ( like 5 choices ) BUT it don't repeat the previous ones, and when it say the last one, it reset. and re randomize 5.
12 Replies
d.js toolkit
d.js toolkit12mo 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 staff
Solo
SoloOP12mo ago
i'm on the last discord.js version, and i have no clue for how to do this, even with the docs
Making a slashcommand having multiple possible answer and making them completly different ( like 5 choices ) BUT it don't repeat the previous ones, and when it say the last one, it reset. and re randomize 5.
Making a slashcommand having multiple possible answer and making them completly different ( like 5 choices ) BUT it don't repeat the previous ones, and when it say the last one, it reset. and re randomize 5.
waseeeen
waseeeen12mo ago
so what's your problem? where are you stuck?
Solo
SoloOP12mo ago
i have no clue of how to make it
waseeeen
waseeeen12mo ago
what is IT? do you have trouble with making slash command or making random answers or anyhting else?
Solo
SoloOP12mo ago
Making random answers, and not repeating the previous ones until he already sent them all, then it reset
waseeeen
waseeeen12mo ago
quick answer: interaction.reply( anyhtingYouWantToSendAsResponseToThatCommand). the way you will get random answers is not d.js related
Solo
SoloOP12mo ago
so there is no way to do the 'random' thing? @waseeeen
client.on(Events.InteractionCreate, interaction => {
if(!interaction.isChatInputCommand()) return;
if(interaction.commandName === "hi") {
rndmessage(message);
function rndmessage(message){
var messages =['hi','yo','hello'];
var rnd = Math.floor(Math.random()*messages.length);

interaction.reply({ content: rnd })
}
}
});
client.on(Events.InteractionCreate, interaction => {
if(!interaction.isChatInputCommand()) return;
if(interaction.commandName === "hi") {
rndmessage(message);
function rndmessage(message){
var messages =['hi','yo','hello'];
var rnd = Math.floor(Math.random()*messages.length);

interaction.reply({ content: rnd })
}
}
});
like this but it don't work ( found it on internet. )
waseeeen
waseeeen12mo ago
discord bot is the way to input and output data to and from your program. same as when you create CLI application, you provide some input to command line, YOUR program does some magic with that input and answers to you
Solo
SoloOP12mo ago
Oh i see
waseeeen
waseeeen12mo ago
the logic between
if(interaction.commandName === "hi") {
if(interaction.commandName === "hi") {
and
interaction.reply({ content: rnd })
interaction.reply({ content: rnd })
is not discord related at all
Solo
SoloOP12mo ago
🤔 so you can't help me ?
Want results from more Discord servers?
Add your server