DM user if it can
This commit is contained in:
parent
18f3bd746b
commit
d26f0d98d2
2 changed files with 48 additions and 6 deletions
|
@ -75,12 +75,12 @@ export default class Timeout extends Command {
|
|||
},
|
||||
]);
|
||||
|
||||
// if (!targetMember.manageable) {
|
||||
// await interaction.reply('Insufficient bot permissions. Please contact a moderator.');
|
||||
// return;
|
||||
// }
|
||||
if (!targetMember.manageable) {
|
||||
await interaction.reply('Insufficient bot permissions. Please contact a moderator.');
|
||||
return;
|
||||
}
|
||||
|
||||
// await targetMember.timeout(timeLength.GetMilliseconds(), reason || "");
|
||||
await targetMember.timeout(timeLength.GetMilliseconds(), reason || "");
|
||||
|
||||
const channelName = await SettingsHelper.GetSetting('channels.logs.mod', interaction.guildId);
|
||||
|
||||
|
@ -97,7 +97,45 @@ export default class Timeout extends Command {
|
|||
|
||||
const resultEmbed = new EmbedBuilder()
|
||||
.setColor(EmbedColours.Ok)
|
||||
.setDescription("User successfully timed out");
|
||||
.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",
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
await interaction.reply({ embeds: [ resultEmbed ]});
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ export default class AuditTools {
|
|||
return "Kick";
|
||||
case AuditType.Ban:
|
||||
return "Ban";
|
||||
case AuditType.Timeout:
|
||||
return "Timeout";
|
||||
default:
|
||||
return "Other";
|
||||
}
|
||||
|
@ -30,6 +32,8 @@ export default class AuditTools {
|
|||
return AuditType.Kick;
|
||||
case "ban":
|
||||
return AuditType.Ban;
|
||||
case "timeout":
|
||||
return AuditType.Timeout;
|
||||
default:
|
||||
return AuditType.General;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue