implement changes to commands and templates

This commit is contained in:
2026-04-08 14:20:54 +02:00
parent e90b8b4d85
commit 65a281dbcb
15 changed files with 326 additions and 59 deletions
+6
View File
@@ -18,6 +18,12 @@ module.exports = {
.setDescription('The reason of the kick')),
category: 'Moderation',
async execute(interaction) {
if (!interaction.guild) {
return interaction.reply({
content: 'This command can only be used inside a server.',
ephemeral: true,
});
}
const user = interaction.options.getUser('target');
const reason = interaction.options.getString('reason') || 'No reason provided';
+6
View File
@@ -25,6 +25,12 @@ module.exports = {
.setDescription('The reason of the mute')),
category: 'Moderation',
async execute(interaction) {
if (!interaction.guild) {
return interaction.reply({
content: 'This command can only be used inside a server.',
ephemeral: true,
});
}
const target = interaction.options.getUser('target');
const duration = interaction.options.getInteger('duration');
const reason = interaction.options.getString('reason') || 'No reason provided';
+3
View File
@@ -48,6 +48,9 @@ module.exports = {
.setRequired(true))),
category: 'Moderation',
async execute(interaction) {
if (!interaction.guild) {
return interaction.reply({ content: 'This command can only be used inside a server.', ephemeral: true });
}
const target = interaction.options.getUser('target');
const role = interaction.options.getRole('role');
const action = interaction.options.getSubcommand();
+28 -8
View File
@@ -18,6 +18,8 @@ module.exports = {
option
.setName('durationms')
.setDescription('Duration of the temporary ban (in milliseconds).')
.setMinValue(60_000)
.setMaxValue(2_592_000_000)
.setRequired(true))
.addStringOption(option =>
option
@@ -31,23 +33,41 @@ module.exports = {
.setMinValue(0).setMaxValue(7)),
category: 'Moderation',
async execute(interaction) {
if (!interaction.guild) {
return interaction.reply({
content: 'This command can only be used inside a server.',
ephemeral: true,
});
}
const user = interaction.options.getUser('target');
const reason = interaction.options.getString('reason');
const durationms = interaction.options.getInteger('durationms');
const deleteMessages = interaction.options.getInteger('delete-messages');
// If you want to parse time like "1d", "10m", etc., use ms package:
let banUntil;
try {
banUntil = Date.now() + durationms;
} catch (e) {
// If parsing fails, handle error
if (user.bot) {
return interaction.reply({
content: 'Invalid duration format. Please use something like "10m" or "1d".',
ephemeral: true
content: 'You cannot temp-ban a bot account.',
ephemeral: true,
});
}
if (user.id === interaction.user.id) {
return interaction.reply({
content: 'You cannot temp-ban yourself.',
ephemeral: true,
});
}
// If you want to parse time like "1d", "10m", etc., use ms package:
if (!Number.isFinite(durationms) || durationms <= 0) {
return interaction.reply({
content: 'Invalid duration. Provide a positive number of milliseconds.',
ephemeral: true,
});
}
const banUntil = Date.now() + durationms;
// A function to send ephemeral messages
async function sendEphemeral(message) {
+8
View File
@@ -4,6 +4,8 @@ const { getGuildSettings } = require('../../services/guildSettings');
const { recordModerationAction } = require('../../services/moderationRecords');
const { connectToDatabase } = require('../../db');
const MAX_REASON_LENGTH = 500;
module.exports = {
permissionGroup: 'moderation',
data: new SlashCommandBuilder()
@@ -31,6 +33,12 @@ module.exports = {
ephemeral: true,
});
}
if (reason.length > MAX_REASON_LENGTH) {
return interaction.reply({
content: `Reason must be ${MAX_REASON_LENGTH} characters or fewer.`,
ephemeral: true,
});
}
const { warnings, strikeCount } = await addWarning({
guildId: interaction.guildId,