Attempt to create dms to the user a moderation action was taken on
All checks were successful
Test / build (push) Successful in 7s

This commit is contained in:
Ethan Lane 2024-08-17 15:26:17 +01:00 committed by Vylpes
parent 674a4ac614
commit a89b9246a3
4 changed files with 86 additions and 48 deletions

View file

@ -62,7 +62,6 @@ export default class Ban extends Command {
} }
await member.ban(); await member.ban();
await interaction.reply(`\`${targetUser.user.tag}\` has been banned.`);
const channelName = await SettingsHelper.GetSetting('channels.logs.mod', interaction.guildId); const channelName = await SettingsHelper.GetSetting('channels.logs.mod', interaction.guildId);
@ -74,7 +73,29 @@ export default class Ban extends Command {
await channel.send({ embeds: [ logEmbed ]}); await channel.send({ embeds: [ logEmbed ]});
} }
const dmEmbed = new EmbedBuilder()
.setColor(EmbedColours.Ok)
.setTitle(interaction.guild.name)
.setDescription("You have been banned by a moderator.")
.addFields([
{
name: "Reason",
value: reason,
},
]);
let replyText = "Successfully banned user.";
try {
const dmChannel = await targetUser.user!.createDM();
await dmChannel.send({ embeds: [ dmEmbed ] });
} catch {
replyText += " *Note: I was unable to DM the user the reason.*";
}
const audit = new Audit(targetUser.user.id, AuditType.Ban, reason, interaction.user.id, interaction.guildId); const audit = new Audit(targetUser.user.id, AuditType.Ban, reason, interaction.user.id, interaction.guildId);
await audit.Save(Audit, audit); await audit.Save(Audit, audit);
await interaction.reply(replyText);
} }
} }

View file

@ -62,7 +62,6 @@ export default class Kick extends Command {
} }
await member.kick(); await member.kick();
await interaction.reply(`\`${targetUser.user.tag}\` has been kicked.`);
const channelName = await SettingsHelper.GetSetting('channels.logs.mod', interaction.guildId); const channelName = await SettingsHelper.GetSetting('channels.logs.mod', interaction.guildId);
@ -74,7 +73,29 @@ export default class Kick extends Command {
await channel.send({ embeds: [ logEmbed ]}); await channel.send({ embeds: [ logEmbed ]});
} }
const dmEmbed = new EmbedBuilder()
.setColor(EmbedColours.Ok)
.setTitle(interaction.guild.name)
.setDescription("You have been kicked from the server.")
.addFields([
{
name: "Reason",
value: reason,
},
]);
let replyText = "Successfully kicked user.";
try {
const dmChannel = await targetUser.user!.createDM();
await dmChannel.send({ embeds: [ dmEmbed ] });
} catch {
replyText += " *Note: I was unable to DM the user the reason.*";
}
const audit = new Audit(targetUser.user.id, AuditType.Kick, reason, interaction.user.id, interaction.guildId); const audit = new Audit(targetUser.user.id, AuditType.Kick, reason, interaction.user.id, interaction.guildId);
await audit.Save(Audit, audit); await audit.Save(Audit, audit);
await interaction.reply(replyText);
} }
} }

View file

@ -104,54 +104,30 @@ export default class Timeout extends Command {
await channel.send({ embeds: [ logEmbed ]}); await channel.send({ embeds: [ logEmbed ]});
} }
const dmEmbed = new EmbedBuilder()
.setColor(EmbedColours.Ok)
.setTitle(interaction.guild.name)
.setDescription("You have been given a warning by a moderator.")
.addFields([
{
name: "Reason",
value: reason || "*none*",
},
]);
let replyText = "Successfully warned user.";
try {
const dmChannel = await targetUser.user!.createDM();
await dmChannel.send({ embeds: [ dmEmbed ] });
} catch {
replyText += " *Note: I was unable to DM the user the reason.*";
}
// Create Audit // Create Audit
const audit = new Audit(targetUser.user.id, AuditType.Timeout, reason || "*none*", interaction.user.id, interaction.guildId); const audit = new Audit(targetUser.user.id, AuditType.Timeout, reason || "*none*", interaction.user.id, interaction.guildId);
await audit.Save(Audit, audit); await audit.Save(Audit, audit);
// DM User, if possible await interaction.reply(replyText);
const resultEmbed = new EmbedBuilder()
.setColor(EmbedColours.Ok)
.setDescription(`<@${targetUser.user.id}> has been timed out`);
const dmEmbed = new EmbedBuilder()
.setColor(EmbedColours.Ok)
.setDescription(`You have been timed out in ${interaction.guild.name}`)
.addFields([
{
name: "Reason",
value: reason || "*none*"
},
{
name: "Length",
value: timeLength.GetLengthShort(),
},
{
name: "Until",
value: timeLength.GetDateFromNow().toString(),
},
]);
try {
const dmChannel = await targetUser.user.createDM();
await dmChannel.send({ embeds: [ dmEmbed ]});
resultEmbed.addFields([
{
name: "DM Sent",
value: "true",
},
]);
} catch {
resultEmbed.addFields([
{
name: "DM Sent",
value: "false",
},
]);
}
// Success Reply
await interaction.reply({ embeds: [ resultEmbed ]});
} }
} }

View file

@ -63,9 +63,29 @@ export default class Warn extends Command {
await channel.send({ embeds: [ logEmbed ]}); await channel.send({ embeds: [ logEmbed ]});
} }
const dmEmbed = new EmbedBuilder()
.setColor(EmbedColours.Ok)
.setTitle(interaction.guild.name)
.setDescription("You have been given a warning by a moderator.")
.addFields([
{
name: "Reason",
value: reason,
},
]);
let replyText = "Successfully warned user.";
try {
const dmChannel = await targetUser.user!.createDM();
await dmChannel.send({ embeds: [ dmEmbed ] });
} catch {
replyText += " *Note: I was unable to DM the user the reason.*";
}
const audit = new Audit(targetUser.user.id, AuditType.Warn, reason, interaction.user.id, interaction.guildId); const audit = new Audit(targetUser.user.id, AuditType.Warn, reason, interaction.user.id, interaction.guildId);
await audit.Save(Audit, audit); await audit.Save(Audit, audit);
await interaction.reply('Successfully warned user.'); await interaction.reply(replyText);
} }
} }