(interaction, config, client)
| 22 | category: "moderation", |
| 23 | |
| 24 | async execute(interaction, config, client) { |
| 25 | try { |
| 26 | const user = interaction.options.getUser("target"); |
| 27 | const reason = interaction.options.getString("reason") || "No reason provided"; |
| 28 | |
| 29 | if (!user) { |
| 30 | throw new TitanBotError( |
| 31 | 'Missing target user', |
| 32 | ErrorTypes.USER_INPUT, |
| 33 | 'You must specify a user to ban.', |
| 34 | { subtype: 'invalid_user' }, |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | if (user.id === interaction.user.id) { |
| 39 | throw new Error("You cannot ban yourself."); |
| 40 | } |
| 41 | if (user.id === client.user.id) { |
| 42 | throw new Error("You cannot ban the bot."); |
| 43 | } |
| 44 | |
| 45 | const result = await ModerationService.banUser({ |
| 46 | guild: interaction.guild, |
| 47 | user, |
| 48 | moderator: interaction.member, |
| 49 | reason |
| 50 | }); |
| 51 | |
| 52 | await InteractionHelper.universalReply(interaction, { |
| 53 | embeds: [ |
| 54 | successEmbed( |
| 55 | `🚫 **Banned** ${user.tag}`, |
| 56 | `**Reason:** ${reason}\n**Case ID:** #${result.caseId}`, |
| 57 | ), |
| 58 | ], |
| 59 | }); |
| 60 | } catch (error) { |
| 61 | logger.error('Ban command error:', error); |
| 62 | await handleInteractionError(interaction, error, { subtype: 'ban_failed' }); |
| 63 | } |
| 64 | }, |
| 65 | }; |
nothing calls this directly
no test coverage detected