Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
Int-CI-Moderation-EditCase: Edit the public message log. Fixes #32
Browse files Browse the repository at this point in the history
  • Loading branch information
RadiatedExodus committed May 28, 2024
1 parent 303a5b1 commit c5b1fc6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/interactions/commands/moderation/editCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,29 @@ export const Command: MeteoriumChatCommand = {
},
});

// Edit public moderation log message if exists
const guildSettings = await client.db.guild.findUnique({ where: { GuildId: interaction.guildId } });
if (caseData.PublicLogMsgId != "" && guildSettings?.PublicModLogChannelId != "") {
const channel = await client.channels
.fetch(guildSettings!.PublicModLogChannelId)
.catch(() => null);
const message =
channel && channel.isTextBased()
? await channel.messages.fetch(caseData.PublicLogMsgId).catch(() => null)
: null;
if (message)
await message.edit({
embeds: [
await client.dbUtils.generateCaseEmbedFromData(
newCaseData,
undefined,
false,
false,
),
],
});
}

// Edit the reply
const editCount = await client.db.moderationCaseHistory.count({ where: { GlobalCaseId: caseId } });
await interaction.editReply({
Expand Down

0 comments on commit c5b1fc6

Please sign in to comment.