feat: initial Papo bot scaffold
This commit is contained in:
36
src/commands/admin/tempban.ts
Normal file
36
src/commands/admin/tempban.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { SlashCommandBuilder, PermissionFlagsBits, ChatInputCommandInteraction } from 'discord.js';
|
||||
import { SlashCommand } from '../../utils/types.js';
|
||||
import { context } from '../../config/context.js';
|
||||
|
||||
const command: SlashCommand = {
|
||||
guildOnly: true,
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('tempban')
|
||||
.setDescription('Bannt einen Nutzer temporär (Angabe in Minuten).')
|
||||
.addUserOption((opt) => opt.setName('user').setDescription('Nutzer').setRequired(true))
|
||||
.addIntegerOption((opt) => opt.setName('minutes').setDescription('Dauer').setRequired(true))
|
||||
.addStringOption((opt) => opt.setName('reason').setDescription('Grund'))
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.BanMembers),
|
||||
async execute(interaction: ChatInputCommandInteraction) {
|
||||
if (!interaction.guild) return;
|
||||
const user = interaction.options.getUser('user', true);
|
||||
const minutes = interaction.options.getInteger('minutes', 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.ban({ reason: `${reason} | ${minutes} Minuten` });
|
||||
await interaction.reply({ content: `${user.tag} wurde für ${minutes} Minuten gebannt.` });
|
||||
context.logging.logAction(user, 'Tempban', reason);
|
||||
|
||||
setTimeout(async () => {
|
||||
await interaction.guild?.members.unban(user.id, 'Tempban abgelaufen').catch(() => null);
|
||||
}, minutes * 60 * 1000);
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
Reference in New Issue
Block a user