generated from Baipyrus/DiscordJS-Template
response data modal
This commit is contained in:
parent
17570e81ac
commit
c61a6fd282
@ -361,7 +361,23 @@ export const data = new SlashCommandBuilder()
|
|||||||
);
|
);
|
||||||
/** @param {ModalSubmitInteraction} interaction */
|
/** @param {ModalSubmitInteraction} interaction */
|
||||||
export async function modalSubmit(interaction) {
|
export async function modalSubmit(interaction) {
|
||||||
// Only executable in 'add' subcommand
|
const { fields } = interaction;
|
||||||
|
|
||||||
|
// Get text inputs from modal
|
||||||
|
const name = fields.getTextInputValue('name');
|
||||||
|
const keyword = fields.getTextInputValue('keyword');
|
||||||
|
const response = fields.getTextInputValue('response');
|
||||||
|
|
||||||
|
// Get id of keyword
|
||||||
|
/** @type {import('../../models/keywords.js').Keyword} */
|
||||||
|
const found = await Keywords.findOne({
|
||||||
|
where: {
|
||||||
|
name: keyword
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create new response data with keyword attached
|
||||||
|
await Responses.create({ keyword: found.id, name, response });
|
||||||
}
|
}
|
||||||
/** @param {AutocompleteInteraction} interaction */
|
/** @param {AutocompleteInteraction} interaction */
|
||||||
export async function autocomplete(interaction) {
|
export async function autocomplete(interaction) {
|
||||||
|
Loading…
Reference in New Issue
Block a user