23 lines
1002 B
TypeScript
23 lines
1002 B
TypeScript
import { SlashCommandBuilder, PermissionFlagsBits, ChatInputCommandInteraction } from 'discord.js';
|
|
import { SlashCommand } from '../../utils/types.js';
|
|
|
|
const command: SlashCommand = {
|
|
guildOnly: true,
|
|
data: new SlashCommandBuilder()
|
|
.setName('clear')
|
|
.setDescription('Löscht Nachrichten (max 100).')
|
|
.addIntegerOption((opt) => opt.setName('amount').setDescription('Anzahl').setRequired(true))
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
|
|
async execute(interaction: ChatInputCommandInteraction) {
|
|
const amount = interaction.options.getInteger('amount', true);
|
|
if (!interaction.channel || amount < 1 || amount > 100) {
|
|
await interaction.reply({ content: 'Anzahl muss zwischen 1 und 100 liegen.', ephemeral: true });
|
|
return;
|
|
}
|
|
const messages = await interaction.channel.bulkDelete(amount, true);
|
|
await interaction.reply({ content: `Gelöschte Nachrichten: ${messages.size}`, ephemeral: true });
|
|
}
|
|
};
|
|
|
|
export default command;
|