adder list
This commit is contained in:
@@ -237,7 +237,35 @@ async function wgeParticipate(interaction) {
|
|||||||
upsert: true
|
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 = {
|
module.exports = {
|
||||||
@@ -294,6 +322,22 @@ module.exports = {
|
|||||||
.addBooleanOption(o =>
|
.addBooleanOption(o =>
|
||||||
o.setName('status')
|
o.setName('status')
|
||||||
.setDescription('choose')
|
.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':
|
case 'participate':
|
||||||
wgeParticipate(interaction)
|
wgeParticipate(interaction)
|
||||||
break;
|
break;
|
||||||
|
case 'list':
|
||||||
|
wgeList(interaction)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,35 @@ async function modalSubmitHandler(interaction) {
|
|||||||
const db = mClient.db('neo-db')
|
const db = mClient.db('neo-db')
|
||||||
const wgeColl = db.collection('timer_wge')
|
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
|
// Get the data entered by the user
|
||||||
var wgeAssignedUser = interaction.components[0].component.users.first();
|
var wgeAssignedUser = interaction.components[0].component.users.first();
|
||||||
const wgeAssigningUser = interaction.user
|
const wgeAssigningUser = interaction.user
|
||||||
|
|||||||
Reference in New Issue
Block a user