Fisban Regner
Fisban Regner
DIAdiscord.js - Imagine a bot
Created by Love on 7/11/2023 in #djs-questions
execute function not ending after return statement?
Just think of it this way
your code
Your function { code
Return // end function return to code }
More code after function
your code
Your function { code
Return // end function return to code }
More code after function
if you want your code to stop after the function you will also need to tell the code to stop. If the function will take more than milliseconds to complete ie connecting to an outside source you will need to await the promise or you will recieve un intended results
12 replies
DIAdiscord.js - Imagine a bot
Created by Love on 7/11/2023 in #djs-questions
execute function not ending after return statement?
It's should but you may want to do an await con.execute so that something has the intended value
12 replies
DIAdiscord.js - Imagine a bot
Created by Love on 7/11/2023 in #djs-questions
execute function not ending after return statement?
This was sent feom my phone so it may contain errors it is to be taken as an example and not an actual solution
12 replies
DIAdiscord.js - Imagine a bot
Created by Love on 7/11/2023 in #djs-questions
execute function not ending after return statement?
if (!con.execute(`SELECT discord_id FROM users WHERE discord_id = ?;`, [target.id], (err, result) => {
if (err) throw err;
// If they have not registered, let the author know and stop running.
if (result.length === 0) {
return false
}
});) {interaction.reply({ content: `something went wrong. ${target} has not yet registered for the event.`, ephemeral: true });}
else {the rest of your code}
if (!con.execute(`SELECT discord_id FROM users WHERE discord_id = ?;`, [target.id], (err, result) => {
if (err) throw err;
// If they have not registered, let the author know and stop running.
if (result.length === 0) {
return false
}
});) {interaction.reply({ content: `something went wrong. ${target} has not yet registered for the event.`, ephemeral: true });}
else {the rest of your code}
some thing like this
12 replies
DIAdiscord.js - Imagine a bot
Created by Love on 7/11/2023 in #djs-questions
execute function not ending after return statement?
What I would do is have the function return a state then test for the state if it passes then continue the code if it fails end execution and send your reply
12 replies
DIAdiscord.js - Imagine a bot
Created by Love on 7/11/2023 in #djs-questions
execute function not ending after return statement?
The return just stops the function and returns to your code. Why the interaction.reply isn't working unsure
12 replies
DIAdiscord.js - Imagine a bot
Created by Fisban Regner on 7/8/2023 in #djs-questions
Issue adding and removing roles in same command
I didn't think to do it that way shouldn't be hard to modify my code because i already do half the process. thank you
9 replies
DIAdiscord.js - Imagine a bot
Created by Fisban Regner on 7/8/2023 in #djs-questions
Issue adding and removing roles in same command
doesnt this remove roles that are not set though
9 replies
DIAdiscord.js - Imagine a bot
Created by Fisban Regner on 7/8/2023 in #djs-questions
Issue adding and removing roles in same command
full code
9 replies
DIAdiscord.js - Imagine a bot
Created by Fisban Regner on 7/8/2023 in #djs-questions
Issue adding and removing roles in same command
9 replies
DIAdiscord.js - Imagine a bot
Created by Fisban Regner on 7/8/2023 in #djs-questions
Issue adding and removing roles in same command
node v18.16.0
9 replies
DIAdiscord.js - Imagine a bot
Created by Duff on 5/29/2023 in #djs-questions
Checking for role not working
What was the problem? how did you solve it? i only ask because im trying to do the same thing with the same results as you.
9 replies