diff --git a/src/commands/Moderation/Ban.ts b/src/commands/Moderation/Ban.ts index 2a48a12..d425559 100644 --- a/src/commands/Moderation/Ban.ts +++ b/src/commands/Moderation/Ban.ts @@ -37,6 +37,8 @@ export const Command: MeteoriumCommand = { const GuildUser = await interaction.guild.members.fetch(User).catch(() => null); const GuildSchema = (await client.Database.guild.findUnique({ where: { GuildId: interaction.guildId } }))!; + await interaction.deferReply({ ephemeral: GuildSchema?.PublicModLogChannelId != "" }); + if (User.id == interaction.user.id) return await interaction.reply({ content: "You can't ban yourself!", ephemeral: true }); if (User.bot) @@ -69,9 +71,6 @@ export const Command: MeteoriumCommand = { NotAppealable: NotAppealable, }, }); - await interaction.guild.members.ban(User, { - reason: `Case ${CaseResult.CaseId} by ${interaction.user.username} (${interaction.user.id}): ${Reason}`, - }); const LogEmbed = new MeteoriumEmbedBuilder(undefined, interaction.user) .setAuthor({ @@ -92,6 +91,17 @@ export const Command: MeteoriumCommand = { .setTimestamp() .setColor("Red"); + try { + const DirectMessageChannnel = await User.createDM(); + await DirectMessageChannnel.send({ embeds: [LogEmbed] }); + } catch (err) { + client.Logging.GetNamespace("Moderation/Ban").warn(`Could not dm ${User.id}\n${err}`); + } + + await interaction.guild.members.ban(User, { + reason: `Case ${CaseResult.CaseId} by ${interaction.user.username} (${interaction.user.id}): ${Reason}`, + }); + const PublicModLogChannel = await interaction.guild.channels .fetch(GuildSchema.PublicModLogChannelId) .catch(() => null); @@ -132,13 +142,12 @@ export const Command: MeteoriumCommand = { }) .catch(() => null); - return await interaction.reply({ + return await interaction.editReply({ content: PublicModLogChannel != null && PublicModLogChannel.isTextBased() ? undefined : "(Warning: could not send log message to the public mod log channel)", embeds: [LogEmbed], - ephemeral: GuildSchema?.PublicModLogChannelId != "", }); }, }; diff --git a/src/commands/Moderation/TempBan.ts b/src/commands/Moderation/TempBan.ts index a88eed4..309f0c3 100644 --- a/src/commands/Moderation/TempBan.ts +++ b/src/commands/Moderation/TempBan.ts @@ -43,6 +43,8 @@ export const Command: MeteoriumCommand = { const GuildUser = await interaction.guild.members.fetch(User).catch(() => null); const GuildSchema = (await client.Database.guild.findUnique({ where: { GuildId: interaction.guildId } }))!; + await interaction.deferReply({ ephemeral: GuildSchema?.PublicModLogChannelId != "" }); + if (User.id == interaction.user.id) return await interaction.reply({ content: "You can't ban yourself!", ephemeral: true }); if (User.bot) @@ -75,14 +77,6 @@ export const Command: MeteoriumCommand = { ModeratorNote: ModeratorNote, }, }); - await client.Database.activeTempBans.create({ - data: { - GlobalCaseId: CaseResult.GlobalCaseId, - }, - }); - await interaction.guild.members.ban(User, { - reason: `Case ${CaseResult.CaseId} by ${interaction.user.username} (${interaction.user.id}): ${Reason}`, - }); const LogEmbed = new MeteoriumEmbedBuilder(undefined, interaction.user) .setAuthor({ @@ -103,6 +97,23 @@ export const Command: MeteoriumCommand = { .setTimestamp() .setColor("Red"); + try { + const DirectMessageChannnel = await User.createDM(); + await DirectMessageChannnel.send({ embeds: [LogEmbed] }); + } catch (err) { + client.Logging.GetNamespace("Moderation/TempBan").warn(`Could not dm ${User.id}\n${err}`); + } + + await interaction.guild.members.ban(User, { + reason: `Case ${CaseResult.CaseId} by ${interaction.user.username} (${interaction.user.id}): ${Reason}`, + }); + + await client.Database.activeTempBans.create({ + data: { + GlobalCaseId: CaseResult.GlobalCaseId, + }, + }); + const PublicModLogChannel = await interaction.guild.channels .fetch(GuildSchema.PublicModLogChannelId) .catch(() => null); @@ -143,13 +154,12 @@ export const Command: MeteoriumCommand = { }) .catch(() => null); - return await interaction.reply({ + return await interaction.editReply({ content: PublicModLogChannel != null && PublicModLogChannel.isTextBased() ? undefined : "(Warning: could not send log message to the public mod log channel)", embeds: [LogEmbed], - ephemeral: GuildSchema?.PublicModLogChannelId != "", }); }, Init(client) {