WGE Implementation Basics
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
const { Events, MessageFlags } = require('discord.js')
|
||||
|
||||
const { mClient } = require('../index')
|
||||
module.exports = {
|
||||
name: Events.InteractionCreate,
|
||||
once: false,
|
||||
async execute(interaction) {
|
||||
if (interaction.isChatInputCommand()) { commandHandler(interaction) };
|
||||
if (interaction.isChatInputCommand()) { commandHandler(interaction) }
|
||||
if (interaction.isButton()) { buttonHandler(interaction) }
|
||||
if (interaction.isMentionableSelectMenu()) { selectMenuHandler(interaction)}
|
||||
if (interaction.isMentionableSelectMenu()) { selectMenuHandler(interaction) }
|
||||
if (interaction.isUserSelectMenu()) { selectMenuHandler(interaction) }
|
||||
if (interaction.isModalSubmit()) { modalSubmitHandler(interaction) }
|
||||
}
|
||||
}
|
||||
async function commandHandler(interaction) {
|
||||
@@ -55,4 +56,30 @@ async function selectMenuHandler(interaction) {
|
||||
await interaction.reply({ content: 'There was an error while executing this command!', flags: MessageFlags.Ephemeral });
|
||||
}
|
||||
}
|
||||
}
|
||||
async function modalSubmitHandler(interaction) {
|
||||
if (interaction.customId === 'wgeBaseModal') {
|
||||
await interaction.reply({
|
||||
content: 'Your submission was received successfully!'
|
||||
});
|
||||
|
||||
// Get the data entered by the user
|
||||
const wgeAssignedUser = interaction.components[0].component.users.first();
|
||||
const wgeAssigningUser = interaction.user
|
||||
const wgeAssignedTopic = interaction.fields.getTextInputValue('wgeTopicInput');
|
||||
|
||||
const wgeDefaultAssignedTime = 7 * 24 * 60 * 60 * 1000; // 7 days in ms
|
||||
|
||||
const db = mClient.db('neo-db')
|
||||
const wgeColl = db.collection('timer_wge')
|
||||
|
||||
wgeColl.insertOne({
|
||||
"assignedUser": wgeAssignedUser.id,
|
||||
"assigningUser": wgeAssigningUser.id,
|
||||
"timeRemaining": wgeDefaultAssignedTime,
|
||||
"createdAt": new Date(),
|
||||
"topic": wgeAssignedTopic,
|
||||
"debug" :false
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user