Attempt to create dms to the user a moderation action was taken on #469

Merged
Vylpes merged 1 commit from feature/255-warn-dm into develop 2024-08-17 16:56:32 +01:00
4 changed files with 86 additions and 48 deletions
Showing only changes of commit a89b9246a3 - Show all commits

View file

@ -62,7 +62,6 @@ export default class Ban extends Command {
}
await member.ban();
await interaction.reply(`\`${targetUser.user.tag}\` has been banned.`);
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 ]});
}
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);
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 interaction.reply(`\`${targetUser.user.tag}\` has been kicked.`);
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 ]});
}
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);
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 ]});
}
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
const audit = new Audit(targetUser.user.id, AuditType.Timeout, reason || "*none*", interaction.user.id, interaction.guildId);
await audit.Save(Audit, audit);
// DM User, if possible
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 ]});
await interaction.reply(replyText);
}
}

View file

@ -63,9 +63,29 @@ export default class Warn extends Command {
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);
await audit.Save(Audit, audit);
await interaction.reply('Successfully warned user.');
await interaction.reply(replyText);
}
}