From fb8a9500e7e4b62e328339878a14130cb7f69395 Mon Sep 17 00:00:00 2001 From: powermaker450 Date: Sun, 13 Oct 2024 19:29:48 -0400 Subject: [PATCH] Comment some funky looking stuff --- src/commands/confess.ts | 26 ++++++++++++++++++++++++++ src/commands/confessbanlist.ts | 9 +++++++++ src/commands/confessdel.ts | 7 +++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/commands/confess.ts b/src/commands/confess.ts index e9cff0c..7569315 100644 --- a/src/commands/confess.ts +++ b/src/commands/confess.ts @@ -54,6 +54,7 @@ export async function execute(interaction: ChatInputCommandInteraction) { // TODO: This all works as intended, but I'd like for it so be a reusable function // instead because all of this is used in src/main.ts try { + // If the user is banned in this guild, don't let them post if (dt.isBanned(interaction.guild?.id!, interaction.user.id)) { return interaction.reply({ content: "You are banned from confessions in this server!", @@ -61,6 +62,7 @@ export async function execute(interaction: ChatInputCommandInteraction) { }); } + // If no guild info is present for this guild, don't let the user post if (!dt.getGuildInfo(interaction.guild?.id!)) { return interaction.reply({ content: @@ -82,6 +84,15 @@ export async function execute(interaction: ChatInputCommandInteraction) { const color = getRandomColor(); const messageId = StoreMan.genId(); + + // Looks like: + // + // | + // | Anonymous Confession a1b2 + // | + // | "example confession content" + // | + // const userConfessionEmbed = new EmbedBuilder() .setColor(color) .setTitle(`Anonymous Confession \`${messageId}\``) @@ -89,6 +100,20 @@ export async function execute(interaction: ChatInputCommandInteraction) { isAttachment(attachment) && userConfessionEmbed.setImage(attachment); + // Looks like: + // + // | + // | Anonymous Confession a1b2 + // | + // | "example confession content" + // | + // | Author + // | @user1 + // | + // | Author ID + // | 1234567890 + // | + // const adminConfessionEmbed = new EmbedBuilder() .setColor(color) .setTitle(`Anonymous Confession \`${messageId}\``) @@ -148,6 +173,7 @@ export async function execute(interaction: ChatInputCommandInteraction) { const confessionsLength = dt.getGuildInfo(interaction.guild?.id!) ?.confessions.length!; + // If there are 2 or more confessions, remove the previous confession's button components if (confessionsLength >= 2) { await ( BotClient.channels.cache.get(confessChannel!) as TextChannel diff --git a/src/commands/confessbanlist.ts b/src/commands/confessbanlist.ts index fb7cdd3..d7d14cc 100644 --- a/src/commands/confessbanlist.ts +++ b/src/commands/confessbanlist.ts @@ -35,6 +35,15 @@ export async function execute(interaction: CommandInteraction) { ? "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}\``; } diff --git a/src/commands/confessdel.ts b/src/commands/confessdel.ts index c3d2009..4ff354f 100644 --- a/src/commands/confessdel.ts +++ b/src/commands/confessdel.ts @@ -18,7 +18,6 @@ import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, SlashCommandBuilder, TextChannel @@ -38,6 +37,8 @@ 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({ content: @@ -49,6 +50,8 @@ export async function execute(interaction: ChatInputCommandInteraction) { const idVal = interaction.options.getString("id")!; const result = dt.getConfession(interaction.guild?.id!, idVal); + // If a confession is found with the given ID, check if the user is the one that posted it, and delete it if they are. + // Otherwise, don't let the user delete anything. if (result) { try { const confession = dt.getConfession( @@ -60,9 +63,9 @@ export async function execute(interaction: ChatInputCommandInteraction) { const emptyEmbed = new EmbedBuilder() .setColor(getRandomColor()) .setTitle("Confession Deleted") - // @ts-ignore .setDescription("[Confession Deleted]"); + // Replace the given confession with an empty embed await (BotClient.channels.cache.get(channelId) as TextChannel).messages .fetch(confession!) .then(e => {