Skip to content

Commit 1ed79b6

Browse files
committed
feat(event-numbers): custom option
1 parent e171de3 commit 1ed79b6

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

bot/interactions/slashcommands/event-numbers.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { EmbedBuilder } = require("discord.js");
1+
const { EmbedBuilder, ApplicationCommandOptionType } = require("discord.js");
22
const SlashCommand = require("../../../structures/base/BaseSlashCommand");
33

44
class EventNumbersCommand extends SlashCommand {
@@ -13,6 +13,14 @@ class EventNumbersCommand extends SlashCommand {
1313
cooldown: 3,
1414
commandData: {
1515
description: "Fetch event attendance data from HackRU's database.",
16+
options: [
17+
{
18+
name: "event-name",
19+
type: ApplicationCommandOptionType.String,
20+
description: "Enter the database name of the event to get attendance.",
21+
required: false,
22+
},
23+
],
1624
},
1725
});
1826
}
@@ -45,9 +53,15 @@ class EventNumbersCommand extends SlashCommand {
4553
.setFooter({ text: "Data as of" })
4654
.setTimestamp();
4755

48-
for (const event of events) {
56+
if (!interaction.options.getString("event-name", false)) {
57+
for (const event of events) {
58+
const count = await users.countDocuments({ registration_status: "checked_in", [`day_of.event.${event}.attend`]: { $gte: 1 } });
59+
infoEmbed.addFields({ name: event, value: `\`${count}\``, inline: true });
60+
}
61+
} else {
62+
const event = interaction.options.getString("event-name");
4963
const count = await users.countDocuments({ registration_status: "checked_in", [`day_of.event.${event}.attend`]: { $gte: 1 } });
50-
infoEmbed.addFields({ name: event, value: `\`${count}\``, inline: true });
64+
infoEmbed.addFields({ name: event, value: `\`${count}\`` });
5165
}
5266

5367
interaction.editReply({ embeds: [infoEmbed] });

0 commit comments

Comments
 (0)