MCPcopy Create free account
hub / github.com/codebymitch/TitanBot / execute

Function execute

src/commands/Moderation/unban.js:26–60  ·  view source on GitHub ↗
(interaction, config, client)

Source from the content-addressed store, hash-verified

24 category: "moderation",
25
26 async execute(interaction, config, client) {
27 const deferSuccess = await InteractionHelper.safeDefer(interaction);
28 if (!deferSuccess) {
29 logger.warn(`Unban interaction defer failed`, {
30 userId: interaction.user.id,
31 guildId: interaction.guildId,
32 commandName: 'unban'
33 });
34 return;
35 }
36
37 try {
38 const targetUser = interaction.options.getUser("target");
39 const reason = interaction.options.getString("reason") || "No reason provided";
40
41 const result = await ModerationService.unbanUser({
42 guild: interaction.guild,
43 user: targetUser,
44 moderator: interaction.member,
45 reason
46 });
47
48 await InteractionHelper.safeEditReply(interaction, {
49 embeds: [
50 successEmbed(
51 "✅ User Unbanned",
52 `Successfully unbanned **${targetUser.tag}** from the server.\n\n**Reason:** ${reason}\n**Case ID:** #${result.caseId}`
53 )
54 ]
55 });
56 } catch (error) {
57 logger.error('Unban command error:', error);
58 await handleInteractionError(interaction, error, { subtype: 'unban_failed' });
59 }
60 }
61};

Callers

nothing calls this directly

Calls 5

successEmbedFunction · 0.90
handleInteractionErrorFunction · 0.90
safeDeferMethod · 0.80
unbanUserMethod · 0.80
safeEditReplyMethod · 0.80

Tested by

no test coverage detected