Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
theSaintKappa committed Mar 17, 2024
2 parents b2927d6 + e6cdf43 commit da6d11a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/commands/slash/moses.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ApplicationCommandOptionChoiceData, type InteractionReplyOptions, PermissionsBitField, SlashCommandBuilder, User } from "discord.js";
import { PermissionsBitField, SlashCommandBuilder, type ApplicationCommandOptionChoiceData, type InteractionReplyOptions } from "discord.js";
import config from "../../config.json";
import type { ILeaderboard, IMosesQuote, IMosesQuoteQueue } from "../../db";
import { getNextCronDates } from "../../features/scheduler";
Expand Down Expand Up @@ -96,18 +96,25 @@ export default {
return;
}

async function updateCounter() {
if (!interaction.guild) return;
interaction.guild.channels.cache.get(config.channels.mosesCounter)?.edit({ name: `🟣 Moses Quotes ›› ${await MosesQuote.countDocuments()}` });
}

switch (subcommand) {
case "list":
await interaction.reply(await list(options.getNumber("page") ?? 1));
break;
case "add":
await interaction.reply(await add(options.getString("quote") as string, user.id));
updateCounter();
break;
case "edit":
await interaction.reply(await edit(options.getNumber("id") as number, options.getString("quote") as string, memberPermissions, user.id));
break;
case "delete":
await interaction.reply(await drop(options.getNumber("id") as number, memberPermissions, user.id));
updateCounter();
break;
case "leaderboard":
await interaction.reply(await leaderboard());
Expand Down
10 changes: 9 additions & 1 deletion src/commands/slash/pt.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { type InteractionReplyOptions, PermissionsBitField, SlashCommandBuilder, type User, type ApplicationCommandOptionChoiceData } from "discord.js";
import { PermissionsBitField, SlashCommandBuilder, type ApplicationCommandOptionChoiceData, type InteractionReplyOptions, type User } from "discord.js";
import type { ILeaderboard, IPtQuote } from "../../db";
import PtLeaderboard from "../../models/pt/leaderboard.schema";
import PtQuote from "../../models/pt/quote.schema";
import { getErrorReply, getInfoReply, getSuccessReply } from "../../utils/replyEmbeds";
import config from "../../config.json";
import { CommandScope, type SlashCommandObject } from "../types";

const pageSize = 15;
Expand Down Expand Up @@ -61,18 +62,25 @@ export default {

if (!interaction.memberPermissions) throw new Error("Member permissions are not defined.");

async function updateCounter() {
if (!interaction.guild) return;
interaction.guild.channels.cache.get(config.channels.ptCounter)?.edit({ name: `🔴 3pT Quotes ›› ${await PtQuote.countDocuments()}` });
}

switch (subcommand) {
case "list":
await interaction.reply(await list(options.getNumber("page") ?? 1));
break;
case "add":
await interaction.reply(await add(options.getString("quote") as string, options.getUser("author") as User, interaction.user));
updateCounter();
break;
case "edit":
await interaction.reply(await edit(options.getNumber("id") as number, options.getString("quote") as string, interaction.memberPermissions, interaction.user));
break;
case "delete":
await interaction.reply(await drop(options.getNumber("id") as number, interaction.memberPermissions, interaction.user));
updateCounter();
break;
case "leaderboard":
await interaction.reply(await leaderboard());
Expand Down
4 changes: 3 additions & 1 deletion src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"welcone": "986301246048722955",
"picsLog": "1058118420186542120",
"togglePings": "980839919972921374",
"voiceTime": "1190431572508291293"
"voiceTime": "1190431572508291293",
"mosesCounter": "990343138268819497",
"ptCounter": "1029373422779781190"
},
"emojis": {
"upvote": "982630993997496321",
Expand Down

0 comments on commit da6d11a

Please sign in to comment.