11const { SlashCommandBuilder, EmbedBuilder } = require ( 'discord.js' ) ;
22const BaseSlashCommand = require ( '../../util/BaseSlashCommand' ) ;
33const { GAME } = require ( '../../config.json' ) ;
4- const { universeSlashCommand, userIdToName } = require ( '../../util/Helper' ) ;
4+ const { universeSlashCommand, userIdToName, userNameToID , isNum } = require ( '../../util/Helper' ) ;
55
66module . exports = class Unban extends BaseSlashCommand {
77 constructor ( ) {
@@ -12,10 +12,20 @@ module.exports = class Unban extends BaseSlashCommand{
1212 const universe = client . universes [ interaction . options . getString ( 'universe' ) ] ;
1313 const datastore = universe . datastore ;
1414
15- const userId = interaction . options . getInteger ( 'userid' ) ;
16- const userName = await userIdToName ( userId ) ;
17- if ( ! userName ) return await interaction . reply ( "Specified user doesn't exist." ) ;
15+ let userId = interaction . options . getString ( 'user' ) ;
16+ let userName ;
17+
18+ if ( isNum ( userId ) ) {
19+ const data = await userNameToID ( userId ) ;
1820
21+ userId = data . id ;
22+ userName = data . name ;
23+ }
24+ else {
25+ userName = await userIdToName ( userId ) ;
26+ }
27+
28+ if ( ! userName ) return await interaction . reply ( "Specified user doesn't exist." ) ;
1929 const reason = interaction . options . getString ( 'reason' ) ?? GAME . UNBAN_REASON ;
2030
2131 const banData = {
@@ -54,9 +64,9 @@ module.exports = class Unban extends BaseSlashCommand{
5464 . setRequired ( true )
5565 . addChoices ( ...currentUniverses )
5666 )
57- . addIntegerOption ( ( option ) =>
67+ . addStringOption ( ( option ) =>
5868 option
59- . setName ( 'userid ' )
69+ . setName ( 'user ' )
6070 . setDescription ( 'User you would like to unban' )
6171 . setRequired ( true )
6272 )
0 commit comments