implement changes to commands and templates
This commit is contained in:
@@ -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';
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user