Alli
Alli
DIAdiscord.js - Imagine a boo! 👻
Created by Alli on 9/24/2023 in #djs-questions
await not behaving nicely after displaying a modal
thanks! alliheart
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by Alli on 9/24/2023 in #djs-questions
await not behaving nicely after displaying a modal
i'm just very used to using connection.promise().query() for mysql2, is the short answer
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by Alli on 9/24/2023 in #djs-questions
await not behaving nicely after displaying a modal
thank you though ❤️
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by Alli on 9/24/2023 in #djs-questions
await not behaving nicely after displaying a modal
looked further, i'm going to close this as not discordjs related, i'm doing this with an insert in another bot i wrote and it behaves perfectly fine there - i just matched all the syntax and it looks exactly correct, so this appears to be out of scope
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by Alli on 9/24/2023 in #djs-questions
await not behaving nicely after displaying a modal
mysql2
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by Alli on 9/24/2023 in #djs-questions
await not behaving nicely after displaying a modal
Right, there's nothing there when I log it
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by Alli on 9/24/2023 in #djs-questions
await not behaving nicely after displaying a modal
'kay!
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by Alli on 9/24/2023 in #djs-questions
await not behaving nicely after displaying a modal
await interaction.showModal(modal);
var submittedModal = await interaction.awaitModalSubmit({ time: 60000 });
if (submittedModal) {
var cwflag_name = submittedModal.fields.getTextInputValue('flagName');
var value = submittedModal.fields.getTextInputValue('flagValue');
if (visibility == 'cflag') { //visibility is set elsewhere in user input, i verified this is working
var cwflags = await connection.promise().query('select * from characterflags where lower(name) like lower("%?%") and guild_id = ?', [cwflag_name, interaction.guildId]); //interaction.guildId is set properly, I'm using that from the slash command that triggered the modal in the first place
console.log(cwflags);
} else {
var cwflags = await connection.promise().query('select * from worldflags where lower(name) like lower("%?%") and guild_id = ?', [cwflag_name, interaction.guildId]);
console.log(cwflags);
}
await submittedModal.reply({ content: 'Checking for flags...', ephemeral: true });
if (cwflags[0].length < 1) {
await submittedModal.editReply({ content: "No flags with that name exist.", ephemeral: true });
} else if (cwflags[0].length == 1) {
await connection.promise().query('insert into reputations (name, guild_id, description, visibility, maximum, start_value, cwflag_id, cwflag_value) values (?, ?, ?, ?, ?, ?, ?, ?)', [name, interaction.guildId, description, visibility, maximum, start_value, cwflags[0][0].id, value]);
await submittedModal.editReply({ content: "Reputation added.", ephemeral: true });
}
await interaction.showModal(modal);
var submittedModal = await interaction.awaitModalSubmit({ time: 60000 });
if (submittedModal) {
var cwflag_name = submittedModal.fields.getTextInputValue('flagName');
var value = submittedModal.fields.getTextInputValue('flagValue');
if (visibility == 'cflag') { //visibility is set elsewhere in user input, i verified this is working
var cwflags = await connection.promise().query('select * from characterflags where lower(name) like lower("%?%") and guild_id = ?', [cwflag_name, interaction.guildId]); //interaction.guildId is set properly, I'm using that from the slash command that triggered the modal in the first place
console.log(cwflags);
} else {
var cwflags = await connection.promise().query('select * from worldflags where lower(name) like lower("%?%") and guild_id = ?', [cwflag_name, interaction.guildId]);
console.log(cwflags);
}
await submittedModal.reply({ content: 'Checking for flags...', ephemeral: true });
if (cwflags[0].length < 1) {
await submittedModal.editReply({ content: "No flags with that name exist.", ephemeral: true });
} else if (cwflags[0].length == 1) {
await connection.promise().query('insert into reputations (name, guild_id, description, visibility, maximum, start_value, cwflag_id, cwflag_value) values (?, ?, ?, ?, ?, ?, ?, ?)', [name, interaction.guildId, description, visibility, maximum, start_value, cwflags[0][0].id, value]);
await submittedModal.editReply({ content: "Reputation added.", ephemeral: true });
}
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by Alli on 9/24/2023 in #djs-questions
await not behaving nicely after displaying a modal
sure! 1 sec
20 replies