adder list
This commit is contained in:
@@ -64,19 +64,48 @@ async function modalSubmitHandler(interaction) {
|
||||
const db = mClient.db('neo-db')
|
||||
const wgeColl = db.collection('timer_wge')
|
||||
|
||||
const prevWge = await wgeColl.findOne({
|
||||
$and: [
|
||||
{ debug: false },
|
||||
{ state: 'running' }
|
||||
]
|
||||
})
|
||||
|
||||
if (prevWge != null) {
|
||||
// Save previous run in history_wge
|
||||
const historyWgeColl = db.collection('history_wge')
|
||||
await historyWgeColl.insertOne({
|
||||
assignedUser: prevWge.assignedUser,
|
||||
assigningUser: prevWge.assigningUser,
|
||||
timeRemaining: prevWge.timeRemaining,
|
||||
topic: prevWge.topic,
|
||||
debug: prevWge.debug,
|
||||
createdAt: prevWge.createdAt
|
||||
});
|
||||
|
||||
console.log({
|
||||
message: 'saved previous wge in history_wge',
|
||||
data: prevWge
|
||||
})
|
||||
|
||||
await wgeColl.deleteOne({
|
||||
_id: prevWge._id
|
||||
})
|
||||
}
|
||||
|
||||
// Get the data entered by the user
|
||||
var wgeAssignedUser = interaction.components[0].component.users.first();
|
||||
const wgeAssigningUser = interaction.user
|
||||
if(wgeAssignedUser.id === process.env.D_ID){
|
||||
if (wgeAssignedUser.id === process.env.D_ID) {
|
||||
// Randomizer Function
|
||||
const participateColl = db.collection('items_wge')
|
||||
const randomParticipant = await participateColl.aggregate([
|
||||
{ $match: { status: true}},
|
||||
{ $sample: { size: 1}}
|
||||
{ $match: { status: true } },
|
||||
{ $sample: { size: 1 } }
|
||||
]).toArray()
|
||||
|
||||
if(!randomParticipant){return interaction.followUp({content: 'No User is participating!'})}
|
||||
|
||||
if (!randomParticipant) { return interaction.followUp({ content: 'No User is participating!' }) }
|
||||
|
||||
random = await interaction.guild.members.fetch(randomParticipant[0].userID)
|
||||
wgeAssignedUser = random.user
|
||||
}
|
||||
@@ -105,6 +134,6 @@ async function modalSubmitHandler(interaction) {
|
||||
createdAt: new Date()
|
||||
});
|
||||
|
||||
return interaction.reply({content: `<@${wgeAssignedUser.id}> is the next expert! Their topic is **${wgeAssignedTopic}**`})
|
||||
return interaction.reply({ content: `<@${wgeAssignedUser.id}> is the next expert! Their topic is **${wgeAssignedTopic}**` })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user