1- import { config } from "./.." ;
21import Logger from "@/utils/logger" ;
32import Component from "@handlers/components/Component" ;
43
54import type { ButtonInteraction , Snowflake } from "discord.js" ;
65import { MessageFlagsBitField , roleMention } from "discord.js" ;
6+ import { config } from "./.." ;
77
88// noinspection JSUnusedGlobalSymbols
99export default class VerifyDevForumRank extends Component {
@@ -13,38 +13,28 @@ export default class VerifyDevForumRank extends Component {
1313
1414 override async execute ( interaction : ButtonInteraction ) : Promise < void > {
1515 if ( ! interaction . inCachedGuild ( ) ) {
16- await interaction . reply ( {
17- content : "This command can only be used in a server." ,
18- flags : MessageFlagsBitField . Flags . Ephemeral
19- } ) ;
16+ await interaction . editReply ( "This interaction can only be used in a server." ) ;
2017 return ;
2118 }
2219
2320 if ( ! process . env . ROVER_API_KEY ) {
24- await interaction . reply ( {
25- content : "The `ROVER_API_KEY` environment variable must be set for this feature." ,
26- flags : MessageFlagsBitField . Flags . Ephemeral
27- } ) ;
21+ await interaction . editReply ( "The `ROVER_API_KEY` environment variable must be set for this feature." ) ;
2822 return ;
2923 }
3024
25+ await interaction . deferReply ( { flags : MessageFlagsBitField . Flags . Ephemeral } ) ;
26+
3127 const robloxUsername = await this . getRobloxUsername ( interaction . user . id , interaction . guildId ) ;
3228
3329 if ( ! robloxUsername ) {
34- await interaction . reply ( {
35- content : "Failed to verify your Roblox username. Please try again later." ,
36- flags : MessageFlagsBitField . Flags . Ephemeral
37- } ) ;
30+ await interaction . editReply ( "Failed to verify your Roblox username. Please try again later." ) ;
3831 return ;
3932 }
4033
4134 const trustLevel = await this . getTrustLevel ( robloxUsername ) ;
4235
4336 if ( ! trustLevel ) {
44- await interaction . reply ( {
45- content : "Failed to verify your trust level. You may not be a member of the developer forum." ,
46- flags : MessageFlagsBitField . Flags . Ephemeral
47- } ) ;
37+ await interaction . editReply ( "Failed to verify your trust level. You may not be a member of the developer forum." ) ;
4838 return ;
4939 }
5040
@@ -138,10 +128,7 @@ export default class VerifyDevForumRank extends Component {
138128 await interaction . member . roles . remove ( [ config . devforumMemberRoleId , config . devforumRegularRoleId ] ) ;
139129 } catch ( error ) {
140130 Logger . error ( `Failed to remove roles from user ${ interaction . user . id } : ${ error } ` ) ;
141- await interaction . reply ( {
142- content : "Failed to remove roles. Please contact a moderator." ,
143- flags : MessageFlagsBitField . Flags . Ephemeral
144- } ) ;
131+ await interaction . editReply ( "Failed to remove roles. Please contact a moderator." ) ;
145132 return ;
146133 }
147134 }
@@ -159,11 +146,7 @@ export default class VerifyDevForumRank extends Component {
159146
160147 // Check if the user already has the role to add
161148 if ( interaction . member . roles . cache . has ( roleToAdd ) ) {
162- await interaction . reply ( {
163- content : `You already have the ${ roleMention ( roleToAdd ) } role.` ,
164- flags : MessageFlagsBitField . Flags . Ephemeral ,
165- allowedMentions : { parse : [ ] }
166- } ) ;
149+ await interaction . editReply ( `You already have the ${ roleMention ( roleToAdd ) } role.` ) ;
167150 return ;
168151 }
169152
@@ -173,11 +156,7 @@ export default class VerifyDevForumRank extends Component {
173156 await interaction . member . roles . remove ( roleToRemove ) ;
174157 } catch ( error ) {
175158 Logger . error ( `Failed to remove role ${ roleToRemove } from user ${ interaction . user . id } : ${ error } ` ) ;
176- await interaction . reply ( {
177- content : `Failed to remove the ${ roleMention ( roleToRemove ) } role. Please contact a moderator.` ,
178- flags : MessageFlagsBitField . Flags . Ephemeral ,
179- allowedMentions : { parse : [ ] }
180- } ) ;
159+ await interaction . editReply ( `Failed to remove the ${ roleMention ( roleToRemove ) } role. Please contact a moderator.` ) ;
181160 return ;
182161 }
183162 }
@@ -187,19 +166,11 @@ export default class VerifyDevForumRank extends Component {
187166 await interaction . member . roles . add ( roleToAdd ) ;
188167 } catch ( error ) {
189168 Logger . error ( `Failed to add role ${ roleToAdd } to user ${ interaction . user . id } : ${ error } ` ) ;
190- await interaction . reply ( {
191- content : `Failed to add the ${ roleMention ( roleToAdd ) } role. Please contact a moderator.` ,
192- flags : MessageFlagsBitField . Flags . Ephemeral ,
193- allowedMentions : { parse : [ ] }
194- } ) ;
169+ await interaction . editReply ( `Failed to add the ${ roleMention ( roleToAdd ) } role. Please contact a moderator.` ) ;
195170 return ;
196171 }
197172
198- await interaction . reply ( {
199- content : `Successfully updated your developer forum role to ${ roleMention ( roleToAdd ) } .` ,
200- flags : MessageFlagsBitField . Flags . Ephemeral ,
201- allowedMentions : { parse : [ ] }
202- } ) ;
173+ await interaction . editReply ( `Successfully updated your developer forum role to ${ roleMention ( roleToAdd ) } .` ) ;
203174 }
204175}
205176
0 commit comments