(interaction, config, client)
| 22 | category: "moderation", |
| 23 | |
| 24 | async execute(interaction, config, client) { |
| 25 | try { |
| 26 | if (!interaction.member.permissions.has(PermissionFlagsBits.KickMembers)) { |
| 27 | throw new TitanBotError( |
| 28 | "User lacks permission", |
| 29 | ErrorTypes.PERMISSION, |
| 30 | "You do not have permission to kick members." |
| 31 | ); |
| 32 | } |
| 33 | |
| 34 | const targetUser = interaction.options.getUser("target"); |
| 35 | const member = interaction.options.getMember("target"); |
| 36 | const reason = interaction.options.getString("reason") || "No reason provided"; |
| 37 | |
| 38 | if (!targetUser) { |
| 39 | throw new TitanBotError( |
| 40 | 'Missing target user', |
| 41 | ErrorTypes.USER_INPUT, |
| 42 | 'You must specify a user to kick.', |
| 43 | { subtype: 'invalid_user' }, |
| 44 | ); |
| 45 | } |
| 46 | |
| 47 | if (targetUser.id === interaction.user.id) { |
| 48 | throw new TitanBotError( |
| 49 | "Cannot kick self", |
| 50 | ErrorTypes.VALIDATION, |
| 51 | "You cannot kick yourself." |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | if (targetUser.id === client.user.id) { |
| 56 | throw new TitanBotError( |
| 57 | "Cannot kick bot", |
| 58 | ErrorTypes.VALIDATION, |
| 59 | "You cannot kick the bot." |
| 60 | ); |
| 61 | } |
| 62 | |
| 63 | if (!member) { |
| 64 | throw new TitanBotError( |
| 65 | "Target not found", |
| 66 | ErrorTypes.USER_INPUT, |
| 67 | "The target user is not currently in this server.", |
| 68 | { subtype: 'user_not_found' } |
| 69 | ); |
| 70 | } |
| 71 | |
| 72 | const result = await ModerationService.kickUser({ |
| 73 | guild: interaction.guild, |
| 74 | member, |
| 75 | moderator: interaction.member, |
| 76 | reason, |
| 77 | }); |
| 78 | |
| 79 | await InteractionHelper.universalReply(interaction, { |
| 80 | embeds: [ |
| 81 | successEmbed( |
nothing calls this directly
no test coverage detected