29 lines
1.2 KiB
TypeScript
29 lines
1.2 KiB
TypeScript
import { SlashCommandBuilder, PermissionFlagsBits, ChatInputCommandInteraction } from 'discord.js';
|
|
import { SlashCommand } from '../../utils/types';
|
|
import { context } from '../../config/context';
|
|
|
|
const command: SlashCommand = {
|
|
guildOnly: true,
|
|
data: new SlashCommandBuilder()
|
|
.setName('kick')
|
|
.setDescription('Kickt einen Nutzer vom Server.')
|
|
.addUserOption((opt) => opt.setName('user').setDescription('Nutzer').setRequired(true))
|
|
.addStringOption((opt) => opt.setName('reason').setDescription('Grund'))
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.KickMembers),
|
|
async execute(interaction: ChatInputCommandInteraction) {
|
|
if (!interaction.guild) return;
|
|
const user = interaction.options.getUser('user', true);
|
|
const reason = interaction.options.getString('reason') ?? 'Kein Grund angegeben';
|
|
const member = await interaction.guild.members.fetch(user.id).catch(() => null);
|
|
if (!member) {
|
|
await interaction.reply({ content: 'Mitglied nicht gefunden.', ephemeral: true });
|
|
return;
|
|
}
|
|
await member.kick(reason);
|
|
await interaction.reply({ content: `${user.tag} wurde gekickt.` });
|
|
context.logging.logAction(user, 'Kick', reason);
|
|
}
|
|
};
|
|
|
|
export default command;
|