Some cleanup again

This commit is contained in:
powermaker450 2024-10-23 16:07:27 -04:00
parent e89e674aa2
commit 0600f13511
3 changed files with 18 additions and 11 deletions

View file

@ -54,7 +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 // 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 // instead because all of this is used in src/main.ts
const { id: guildId } = interaction.guild!; const { id: guildId } = interaction.guild!;
const { id: userId } = interaction.user; const { id: userId, displayName: userName } = interaction.user;
try { try {
// If the user is banned in this guild, don't let them post // If the user is banned in this guild, don't let them post
@ -74,7 +74,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
}); });
} }
const confessChannel = dt.getGuildInfo(guildId)?.settings.confessChannel; const confessChannel = dt.getGuildInfo(guildId)!.settings.confessChannel;
const adminChannel = dt.getGuildInfo(guildId)?.settings.modChannel; const adminChannel = dt.getGuildInfo(guildId)?.settings.modChannel;
const messageContent = `"${interaction.options.getString("message")}"`; const messageContent = `"${interaction.options.getString("message")}"`;
@ -163,8 +163,8 @@ export async function execute(interaction: ChatInputCommandInteraction) {
dt.addConfession( dt.addConfession(
message, message,
messageId, messageId,
interaction.user.displayName, userName,
interaction.user.id, userId,
messageContent, messageContent,
attachment attachment
); );
@ -173,14 +173,18 @@ export async function execute(interaction: ChatInputCommandInteraction) {
// If there are 2 or more confessions, remove the previous confession's button components // If there are 2 or more confessions, remove the previous confession's button components
if (confessionsLength >= 2) { if (confessionsLength >= 2) {
await ( (BotClient.channels.cache.get(confessChannel) as TextChannel).messages
BotClient.channels.cache.get(confessChannel!) as TextChannel
).messages
.fetch( .fetch(
dt.getGuildInfo(guildId)!.confessions[confessionsLength - 2].messageId dt.getGuildInfo(guildId)!.confessions[confessionsLength - 2].messageId
) )
.then(message => { .then(message => {
message.edit({ components: [] }); message.edit({ components: [] });
})
.catch(err => {
logger.error(
"An error occured removing embeds from the previous message:",
err
);
}); });
} }

View file

@ -184,7 +184,10 @@ export async function execute(interaction: ChatInputCommandInteraction) {
} }
// /confessmod pardon <id> // /confessmod pardon <id>
} else if (interaction.options.getSubcommand() === "pardon") { } else if (interaction.options.getSubcommand() === "pardon") {
const result = dt.removeBanById(guildId, interaction.options.getString("id")!); const result = dt.removeBanById(
guildId,
interaction.options.getString("id")!
);
try { try {
return result return result

View file

@ -1,3 +1,3 @@
export const messageOpts = { export const messageOpts = {
ephemeral: true ephemeral: true
} };