Skip to content

Commit e171de3

Browse files
committed
feat: event-numbers cmd
1 parent 485c6a7 commit e171de3

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const { EmbedBuilder } = require("discord.js");
2+
const SlashCommand = require("../../../structures/base/BaseSlashCommand");
3+
4+
class EventNumbersCommand extends SlashCommand {
5+
/**
6+
* @param {import("../../index.js")} client HackRUBot's Discord Client.
7+
*/
8+
constructor(client) {
9+
super(client, {
10+
name: "event-numbers",
11+
category: "team",
12+
guildRequired: true,
13+
cooldown: 3,
14+
commandData: {
15+
description: "Fetch event attendance data from HackRU's database.",
16+
},
17+
});
18+
}
19+
20+
/**
21+
* @param {import("discord.js").ChatInputCommandInteraction} interaction
22+
*/
23+
async run(interaction) {
24+
await interaction.deferReply();
25+
26+
const users = await this.HackRUBot.db.getCollection("users");
27+
28+
const events = [
29+
"lunch-saturday",
30+
"dinner-saturday",
31+
"github-copilot",
32+
"figma-workshop",
33+
"wakefern-coffee-chat",
34+
"wakefern-cafe",
35+
"midnight-surpise",
36+
"icims-tech-talk",
37+
"breakfast-sunday",
38+
"lunch-sunday",
39+
];
40+
41+
const infoEmbed = new EmbedBuilder()
42+
.setAuthor({ name: "HackRU Events Attendance", iconURL: interaction.guild.iconURL() })
43+
.setDescription("Count of checked in users who attended events. Duplicates are not counted.")
44+
.setColor("Blurple")
45+
.setFooter({ text: "Data as of" })
46+
.setTimestamp();
47+
48+
for (const event of events) {
49+
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 });
51+
}
52+
53+
interaction.editReply({ embeds: [infoEmbed] });
54+
55+
return;
56+
}
57+
}
58+
59+
module.exports = EventNumbersCommand;

0 commit comments

Comments
 (0)