This commit is contained in:
parent
bd5515c587
commit
45002aa13a
2 changed files with 138 additions and 0 deletions
|
@ -33,10 +33,12 @@ export default class Timeout extends Command {
|
|||
public override async execute(interaction: CommandInteraction<CacheType>) {
|
||||
if (!interaction.guild || !interaction.guildId) return;
|
||||
|
||||
// Interaction Inputs
|
||||
const targetUser = interaction.options.get('target');
|
||||
const lengthInput = interaction.options.get('length');
|
||||
const reasonInput = interaction.options.get('reason');
|
||||
|
||||
// Validation
|
||||
if (!targetUser || !targetUser.user || !targetUser.member) {
|
||||
await interaction.reply('Fields are required.');
|
||||
return;
|
||||
|
@ -47,6 +49,7 @@ export default class Timeout extends Command {
|
|||
return;
|
||||
}
|
||||
|
||||
// General Variables
|
||||
const targetMember = targetUser.member as GuildMember;
|
||||
const reason = reasonInput && reasonInput.value ? reasonInput.value.toString() : null;
|
||||
|
||||
|
@ -75,13 +78,16 @@ export default class Timeout extends Command {
|
|||
},
|
||||
]);
|
||||
|
||||
// Bot Permissions Check
|
||||
if (!targetMember.manageable) {
|
||||
await interaction.reply('Insufficient bot permissions. Please contact a moderator.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Execute Timeout
|
||||
await targetMember.timeout(timeLength.GetMilliseconds(), reason || "");
|
||||
|
||||
// Log Embed To Channel
|
||||
const channelName = await SettingsHelper.GetSetting('channels.logs.mod', interaction.guildId);
|
||||
|
||||
if (!channelName) return;
|
||||
|
@ -92,9 +98,11 @@ export default class Timeout extends Command {
|
|||
await channel.send({ embeds: [ logEmbed ]});
|
||||
}
|
||||
|
||||
// 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`);
|
||||
|
@ -137,6 +145,7 @@ export default class Timeout extends Command {
|
|||
]);
|
||||
}
|
||||
|
||||
// Success Reply
|
||||
await interaction.reply({ embeds: [ resultEmbed ]});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue