adder list
This commit is contained in:
@@ -237,7 +237,35 @@ async function wgeParticipate(interaction) {
|
||||
upsert: true
|
||||
})
|
||||
|
||||
interaction.reply(`You are ${status ? '' : 'no longer '}participating!`)
|
||||
interaction.reply({
|
||||
content: `You are ${status ? '' : 'no longer '}participating!`,
|
||||
flags: MessageFlags.Ephemeral
|
||||
})
|
||||
}
|
||||
|
||||
async function wgeList(interaction){
|
||||
const thing = interaction.options.getString('thing')
|
||||
switch (thing) {
|
||||
case 'participants':
|
||||
const db = mClient.db('neo-db')
|
||||
const participantColl = db.collection('items_wge')
|
||||
const participants = await participantColl.find({
|
||||
status: true
|
||||
}).toArray()
|
||||
let messageContent = ''
|
||||
participants.forEach((participant) => {
|
||||
messageContent += `<@${participant.userID}>\r\n`
|
||||
})
|
||||
|
||||
interaction.reply({
|
||||
content: `WGE Participants:\r\n${messageContent}`,
|
||||
flags: MessageFlags.Ephemeral
|
||||
})
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
@@ -294,6 +322,22 @@ module.exports = {
|
||||
.addBooleanOption(o =>
|
||||
o.setName('status')
|
||||
.setDescription('choose')
|
||||
.setRequired(true)
|
||||
)
|
||||
)
|
||||
|
||||
// List the previous WGE Sessions
|
||||
.addSubcommand(s =>
|
||||
s
|
||||
.setName('list')
|
||||
.setDescription('list things')
|
||||
.addStringOption(o =>
|
||||
o.setName('thing')
|
||||
.setDescription('what would you like to be listed')
|
||||
.addChoices(
|
||||
{ name: 'participants', value: 'participants'},
|
||||
{ name: 'history', value: 'history'}
|
||||
)
|
||||
)
|
||||
)
|
||||
,
|
||||
@@ -324,6 +368,8 @@ module.exports = {
|
||||
case 'participate':
|
||||
wgeParticipate(interaction)
|
||||
break;
|
||||
case 'list':
|
||||
wgeList(interaction)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -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