@@ -135,11 +135,24 @@ export class DiscordClient extends EventEmitter {
135
135
name : "leavechannel" ,
136
136
description : "Leave the current voice channel" ,
137
137
} ,
138
+ {
139
+ name : "botleave" ,
140
+ description : "Bot owner command to leave server" ,
141
+ } ,
138
142
] ;
139
143
140
144
try {
145
+ // Add debug logging
146
+ elizaLogger . debug ( "Attempting to register commands:" , commands ) ;
147
+
148
+ // Register globally
141
149
await this . client . application ?. commands . set ( commands ) ;
142
- elizaLogger . success ( "Slash commands registered" ) ;
150
+
151
+ // Log success with more details
152
+ elizaLogger . success ( "Slash commands registered successfully" , {
153
+ commandCount : commands . length ,
154
+ commandNames : commands . map ( ( c ) => c . name ) ,
155
+ } ) ;
143
156
} catch ( error ) {
144
157
console . error ( "Error registering slash commands:" , error ) ;
145
158
}
@@ -372,6 +385,39 @@ export class DiscordClient extends EventEmitter {
372
385
case "leavechannel" :
373
386
await this . voiceManager . handleLeaveChannelCommand ( interaction ) ;
374
387
break ;
388
+ case "botleave" :
389
+ // Check if command user is bot owner
390
+ const BOT_OWNER_ID = this . runtime . getSetting (
391
+ "DISCORD_BOT_OWNER_ID"
392
+ ) ;
393
+
394
+ // Add debug logging
395
+ elizaLogger . debug ( "Bot leave command attempted" , {
396
+ commandUserId : interaction . user . id ,
397
+ expectedOwnerId : BOT_OWNER_ID ,
398
+ userName : interaction . user . username ,
399
+ } ) ;
400
+
401
+ if ( interaction . user . id !== BOT_OWNER_ID ) {
402
+ await interaction . reply ( {
403
+ content : "Only the bot owner can use this command." ,
404
+ ephemeral : true ,
405
+ } ) ;
406
+ return ;
407
+ }
408
+ try {
409
+ await interaction . reply ( {
410
+ content : "Leaving server as requested by bot owner" ,
411
+ } ) ;
412
+ await interaction . guild . leave ( ) ;
413
+ } catch ( error ) {
414
+ elizaLogger . error ( "Error leaving server:" , error ) ;
415
+ await interaction . reply ( {
416
+ content : "Failed to leave the server." ,
417
+ ephemeral : true ,
418
+ } ) ;
419
+ }
420
+ break ;
375
421
}
376
422
}
377
423
0 commit comments