Attempt to create dms to the user a moderation action was taken on
All checks were successful
Test / build (push) Successful in 6s
All checks were successful
Test / build (push) Successful in 6s
This commit is contained in:
parent
8e87fd6618
commit
53c0e3e488
4 changed files with 86 additions and 48 deletions
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue