diff --git a/src/commands/confess.ts b/src/commands/confess.ts
index 7569315..e1f9b11 100644
--- a/src/commands/confess.ts
+++ b/src/commands/confess.ts
@@ -104,9 +104,9 @@ export async function execute(interaction: ChatInputCommandInteraction) {
//
// |
// | Anonymous Confession a1b2
- // |
+ // |
// | "example confession content"
- // |
+ // |
// | Author
// | @user1
// |
diff --git a/src/commands/confessban.ts b/src/commands/confessban.ts
deleted file mode 100644
index 96a4e09..0000000
--- a/src/commands/confessban.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Confoss: Anonymous confessions for Discord, free as in freedom and price!
- * Copyright (C) 2024 powermaker450
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import {
- ChatInputCommandInteraction,
- PermissionFlagsBits,
- SlashCommandBuilder
-} from "discord.js";
-import { dt } from "../main";
-import Logger from "../utils/Logger";
-
-const logger = new Logger("(/) confessban");
-
-export const data = new SlashCommandBuilder()
- .setName("confessban")
- .setDescription("Ban a user from submitting confessions.")
- .addStringOption(option =>
- option
- .setName("id")
- .setDescription("The confession ID to ban")
- .setRequired(true)
- )
- .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers);
-
-export async function execute(interaction: ChatInputCommandInteraction) {
- const guildId = interaction.guild?.id!;
- const confessionId = interaction.options.getString("id")!;
-
- if (dt.isBanned(guildId, confessionId)) {
- return interaction.reply({
- content: "That user is already banned!",
- ephemeral: true
- });
- }
-
- const result = dt.addBan(guildId, confessionId);
-
- try {
- return result
- ? interaction.reply({
- content: "User was banned.",
- ephemeral: true
- })
- : interaction.reply({
- content: "No confession with that ID was found.",
- ephemeral: true
- });
- } catch (err) {
- logger.error("An error occured:", err);
- }
-}
diff --git a/src/commands/confessbanlist.ts b/src/commands/confessbanlist.ts
deleted file mode 100644
index d7d14cc..0000000
--- a/src/commands/confessbanlist.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Confoss: Anonymous confessions for Discord, free as in freedom and price!
- * Copyright (C) 2024 powermaker450
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import {
- CommandInteraction,
- PermissionFlagsBits,
- SlashCommandBuilder
-} from "discord.js";
-import { dt } from "../main";
-
-export const data = new SlashCommandBuilder()
- .setName("confessbanlist")
- .setDescription("Get the current ban list")
- .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages);
-
-export async function execute(interaction: CommandInteraction) {
- const bannedMembers = dt.getBans(interaction.guild?.id!);
-
- let content = bannedMembers.length
- ? "Banned Members:\n"
- : "There are no banned members.";
-
- // For each member, add them to the message content.
- // It will end up looking something like this:
- //
- // Banned Members:
- //
- // @user1 | a1b2
- // @user2 | c3d4
- // @user3 | e5f6
- //
- for (const member of bannedMembers) {
- content += `\n<@${member.user}> | \`${member.confessionId}\``;
- }
-
- return interaction.reply({
- content: content,
- ephemeral: true
- });
-}
diff --git a/src/commands/confessdel.ts b/src/commands/confessdel.ts
index 4ff354f..a2db659 100644
--- a/src/commands/confessdel.ts
+++ b/src/commands/confessdel.ts
@@ -37,7 +37,6 @@ export const data = new SlashCommandBuilder()
);
export async function execute(interaction: ChatInputCommandInteraction) {
-
// If there is no guild info, don't let the user delete anything
if (!dt.getGuildInfo(interaction.guild?.id!)) {
return interaction.reply({
diff --git a/src/commands/confessmod.ts b/src/commands/confessmod.ts
new file mode 100644
index 0000000..510a3b4
--- /dev/null
+++ b/src/commands/confessmod.ts
@@ -0,0 +1,151 @@
+/*
+ * Confoss: Anonymous confessions for Discord, free as in freedom and price!
+ * Copyright (C) 2024 powermaker450
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+import {
+ ChatInputCommandInteraction,
+ PermissionFlagsBits,
+ SlashCommandBuilder
+} from "discord.js";
+import { dt } from "../main";
+import Logger from "../utils/Logger";
+
+const logger = new Logger("(/) confessban");
+
+export const data = new SlashCommandBuilder()
+ .setName("confessmod")
+ .setDescription("Moderate confessions")
+ .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
+ .addSubcommand(ban =>
+ ban
+ .setName("ban")
+ .setDescription("Ban a user from confessions")
+ .addStringOption(option =>
+ option
+ .setName("id")
+ .setDescription("The confession ID to ban")
+ .setMinLength(4)
+ .setMaxLength(4)
+ .setRequired(true)
+ )
+ )
+ .addSubcommand(list =>
+ list.setName("list").setDescription("Show the list of banned users")
+ )
+ .addSubcommand(pardon =>
+ pardon
+ .setName("pardon")
+ .setDescription("Unban a user from confessions")
+ .addStringOption(id =>
+ id
+ .setName("id")
+ .setDescription("The confession ID to ban")
+ .setMinLength(4)
+ .setMaxLength(4)
+ .setRequired(true)
+ )
+ );
+
+export async function execute(interaction: ChatInputCommandInteraction) {
+ const guildId = interaction.guild?.id!;
+
+ // /confessmod ban
+ if (interaction.options.getSubcommand() === "ban") {
+ const confessionId = interaction.options.getString("id")!;
+
+ if (dt.isBanned(guildId, confessionId)) {
+ try {
+ return interaction.reply({
+ content: "That user is already banned!",
+ ephemeral: true
+ });
+ } catch (err) {
+ logger.error("A ban interaction error occured:", err);
+ }
+ }
+
+ const result = dt.addBan(guildId, confessionId);
+
+ try {
+ return result
+ ? interaction.reply({
+ content: "User was banned.",
+ ephemeral: true
+ })
+ : interaction.reply({
+ content: "No confession with that ID was found.",
+ ephemeral: true
+ });
+ } catch (err) {
+ logger.error("A ban interaction error occured:", err);
+ }
+ // /confessmod list
+ } else if (interaction.options.getSubcommand() === "list") {
+ const bannedMembers = dt.getBans(interaction.guild?.id!);
+
+ let content = bannedMembers.length
+ ? "Banned Members:\n"
+ : "There are no banned members.";
+
+ // For each member, add them to the message content.
+ // It will end up looking something like this:
+ //
+ // Banned Members:
+ //
+ // @user1 | a1b2
+ // @user2 | c3d4
+ // @user3 | e5f6
+ //
+ for (const member of bannedMembers) {
+ content += `\n<@${member.user}> | \`${member.confessionId}\``;
+ }
+
+ try {
+ return interaction.reply({
+ content: content,
+ ephemeral: true
+ });
+ } catch (err) {
+ logger.error("A banlist interaction error occured:", err);
+ }
+ // /confessmod pardon
+ } else if (interaction.options.getSubcommand() === "pardon") {
+ const result = dt.removeBan(
+ interaction.guild?.id!,
+ interaction.options.getString("id")!
+ );
+
+ try {
+ return result
+ ? interaction.reply({
+ content: "User was unbanned.",
+ ephemeral: true
+ })
+ : interaction.reply({
+ content: "No confession with that ID was found.",
+ ephemeral: true
+ });
+ } catch (err) {
+ logger.error("An unban interaction error occured:", err);
+ }
+ }
+
+ return interaction.reply({
+ content: "Unknown error",
+ ephemeral: true
+ });
+}
diff --git a/src/commands/confesspardon.ts b/src/commands/confesspardon.ts
deleted file mode 100644
index 2b8d1d9..0000000
--- a/src/commands/confesspardon.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Confoss: Anonymous confessions for Discord, free as in freedom and price!
- * Copyright (C) 2024 powermaker450
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import {
- ChatInputCommandInteraction,
- PermissionFlagsBits,
- SlashCommandBuilder
-} from "discord.js";
-import { dt } from "../main";
-import Logger from "../utils/Logger";
-
-const logger = new Logger("(/) confesspardon");
-
-export const data = new SlashCommandBuilder()
- .setName("confesspardon")
- .setDescription("Unbans a user from confessions")
- .addStringOption(option =>
- option
- .setName("id")
- .setDescription("The confession ID to unban")
- .setRequired(true)
- )
- .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages);
-
-export function execute(interaction: ChatInputCommandInteraction) {
- const result = dt.removeBan(
- interaction.guild?.id!,
- interaction.options.getString("id")!
- );
-
- try {
- return result
- ? interaction.reply({
- content: "User was unbanned.",
- ephemeral: true
- })
- : interaction.reply({
- content: "No confession with that ID was found.",
- ephemeral: true
- });
- } catch (err) {
- logger.error("An error occured:", err);
- }
-}
diff --git a/src/commands/index.ts b/src/commands/index.ts
index b6009cc..b7578e5 100644
--- a/src/commands/index.ts
+++ b/src/commands/index.ts
@@ -18,18 +18,14 @@
import * as confess from "./confess";
import * as confessdel from "./confessdel";
-import * as confessban from "./confessban";
-import * as confessbanlist from "./confessbanlist";
-import * as confesspardon from "./confesspardon";
+import * as confessmod from "./confessmod";
import * as ping from "./ping";
import * as setup from "./setup";
export const commands = {
confess,
confessdel,
- confessban,
- confessbanlist,
- confesspardon,
+ confessmod,
ping,
setup
};