Compare commits
2 commits
18f3bd746b
...
bd5515c587
Author | SHA1 | Date | |
---|---|---|---|
bd5515c587 | |||
d26f0d98d2 |
5 changed files with 998 additions and 946 deletions
|
@ -31,17 +31,17 @@
|
||||||
"discord.js": "^14.3.0",
|
"discord.js": "^14.3.0",
|
||||||
"dotenv": "^16.0.0",
|
"dotenv": "^16.0.0",
|
||||||
"emoji-regex": "^9.2.0",
|
"emoji-regex": "^9.2.0",
|
||||||
"jest": "^27.4.5",
|
"jest": "^29.5.0",
|
||||||
"jest-mock-extended": "^3.0.0",
|
"jest-mock-extended": "^3.0.4",
|
||||||
"minimatch": "7.4.2",
|
"minimatch": "7.4.2",
|
||||||
"mysql": "^2.18.1",
|
"mysql": "^2.18.1",
|
||||||
"random-bunny": "^2.0.5",
|
"random-bunny": "^2.0.5",
|
||||||
"ts-jest": "^27.1.2",
|
"ts-jest": "^29.0.5",
|
||||||
"typeorm": "^0.2.44",
|
"typeorm": "^0.2.44",
|
||||||
"uuid": "^9.0.0"
|
"uuid": "^9.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^18.0.0",
|
"@types/node": "^18.0.0",
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,12 +75,12 @@ export default class Timeout extends Command {
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// if (!targetMember.manageable) {
|
if (!targetMember.manageable) {
|
||||||
// await interaction.reply('Insufficient bot permissions. Please contact a moderator.');
|
await interaction.reply('Insufficient bot permissions. Please contact a moderator.');
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// await targetMember.timeout(timeLength.GetMilliseconds(), reason || "");
|
await targetMember.timeout(timeLength.GetMilliseconds(), reason || "");
|
||||||
|
|
||||||
const channelName = await SettingsHelper.GetSetting('channels.logs.mod', interaction.guildId);
|
const channelName = await SettingsHelper.GetSetting('channels.logs.mod', interaction.guildId);
|
||||||
|
|
||||||
|
@ -97,7 +97,45 @@ export default class Timeout extends Command {
|
||||||
|
|
||||||
const resultEmbed = new EmbedBuilder()
|
const resultEmbed = new EmbedBuilder()
|
||||||
.setColor(EmbedColours.Ok)
|
.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 ]});
|
await interaction.reply({ embeds: [ resultEmbed ]});
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ export default class AuditTools {
|
||||||
return "Kick";
|
return "Kick";
|
||||||
case AuditType.Ban:
|
case AuditType.Ban:
|
||||||
return "Ban";
|
return "Ban";
|
||||||
|
case AuditType.Timeout:
|
||||||
|
return "Timeout";
|
||||||
default:
|
default:
|
||||||
return "Other";
|
return "Other";
|
||||||
}
|
}
|
||||||
|
@ -30,6 +32,8 @@ export default class AuditTools {
|
||||||
return AuditType.Kick;
|
return AuditType.Kick;
|
||||||
case "ban":
|
case "ban":
|
||||||
return AuditType.Ban;
|
return AuditType.Ban;
|
||||||
|
case "timeout":
|
||||||
|
return AuditType.Timeout;
|
||||||
default:
|
default:
|
||||||
return AuditType.General;
|
return AuditType.General;
|
||||||
}
|
}
|
||||||
|
|
16
tests/commands/timeout.test.ts
Normal file
16
tests/commands/timeout.test.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import { PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||||
|
import Timeout from "../../src/commands/timeout";
|
||||||
|
|
||||||
|
describe('Constructor', () => {
|
||||||
|
test('Expect CommandBuilder to be configured', () => {
|
||||||
|
const command = new Timeout();
|
||||||
|
|
||||||
|
expect(command.CommandBuilder).toBeDefined();
|
||||||
|
|
||||||
|
const commandBuilder = command.CommandBuilder as SlashCommandBuilder;
|
||||||
|
|
||||||
|
expect(commandBuilder.name).toBe("timeout");
|
||||||
|
expect(commandBuilder.description).toBe("Timeouts a user out, sending them a DM with the reason if possible");
|
||||||
|
expect(commandBuilder.options.length).toBe(3);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue