Nucleus stats done / premium started
diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts
index 613b48c..7d54674 100644
--- a/src/utils/confirmationMessage.ts
+++ b/src/utils/confirmationMessage.ts
@@ -183,7 +183,7 @@
let component;
try {
component = await m.awaitMessageComponent({
- filter: (m) => m.user.id === this.interaction.user.id && m.channel!.id === this.interaction.channel!.id,
+ filter: (i) => i.user.id === this.interaction.user.id && i.channel!.id === this.interaction.channel!.id && i.id === m.id,
time: 300000
});
} catch (e) {
@@ -287,7 +287,7 @@
await this.interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle(this.title)
- .setDescription(this.failedMessage ?? "")
+ .setDescription(this.failedMessage ?? "*Message timed out*")
.setStatus(this.failedStatus ?? "Danger")
.setEmoji(this.failedEmoji ?? this.redEmoji ?? this.emoji)
], components: []
diff --git a/src/utils/database.ts b/src/utils/database.ts
index 1e8e990..3d4ca78 100644
--- a/src/utils/database.ts
+++ b/src/utils/database.ts
@@ -67,7 +67,6 @@
value: any,
innerKey?: string | null
) {
- console.log(Array.isArray(value));
if (innerKey) {
await this.guilds.updateOne(
{ id: guild },
@@ -191,6 +190,10 @@
const entry = await this.modNotes.findOne({ guild: guild, user: user });
return entry?.note ?? null;
}
+
+ async delete(guild: string) {
+ await this.modNotes.deleteMany({ guild: guild });
+ }
}
export class Premium {
@@ -204,7 +207,18 @@
const entry = await this.premium.findOne({
appliesTo: { $in: [guild] }
});
- return entry !== null;
+ if (!entry) return false;
+ return entry.expires.valueOf() > Date.now();
+ }
+
+ async fetchTotal(user: string): Promise<number> {
+ const entry = await this.premium.findOne({ user: user });
+ if (!entry) return 0;
+ return entry.appliesTo.length;
+ }
+
+ setPremium(user: string, guild: string) {
+ return this.premium.updateOne({ user: user }, { $addToSet: { appliesTo: guild } }, { upsert: true });
}
}
diff --git a/src/utils/dualCollector.ts b/src/utils/dualCollector.ts
index 64e87b8..f55716e 100644
--- a/src/utils/dualCollector.ts
+++ b/src/utils/dualCollector.ts
@@ -60,15 +60,17 @@
})
.on("collect", async (i: ButtonInteraction) => {
mod.stop();
- if (!i.deferred) await i.deferUpdate();
+ int.stop();
+ await i.deferUpdate();
resolve(i);
});
const mod = new InteractionCollector(client as Client, {
- filter: (i: Interaction) => modalFilter(i),
+ filter: (i: Interaction) => modalFilter(i) && i.isModalSubmit(),
time: 300000
}).on("collect", async (i: ModalSubmitInteraction) => {
int.stop();
- if (!i.deferred) await i.deferUpdate();
+ mod.stop();
+ await i.deferUpdate();
resolve(i);
});
});