@@ -13,7 +13,7 @@ export default class DiscordBot extends Client {
1313
1414 if ( ! config )
1515 throw new Error ( "Configuration file not successfully injected." ) ;
16-
16+
1717 this . tourneyConfig = config . config ;
1818
1919 this . once ( 'ready' , ( ) => {
@@ -25,7 +25,7 @@ export default class DiscordBot extends Client {
2525
2626 const channelId = this . tourneyConfig . discord . welcomeChannelId ;
2727 const channel = guild . channels . cache . get ( channelId ) as TextChannel ;
28-
28+
2929 channel . send ( `Welcome ${ member } you are now verified!` )
3030 } catch ( e ) {
3131 consola . error ( e ) ;
@@ -41,7 +41,7 @@ export default class DiscordBot extends Client {
4141
4242 await this . changeNickName ( nickname , guildMember ) ;
4343 consola . success ( `Added ${ nickname } nickname to ${ userId } .` )
44-
44+
4545 const roles = this . tourneyConfig . discord . roles ;
4646 const arr : string [ ] = [ ] ;
4747
@@ -55,25 +55,23 @@ export default class DiscordBot extends Client {
5555 consola . info ( `Adding ${ arr } roles to ${ nickname } ...` ) ;
5656
5757 for ( let i = 0 ; i < arr . length ; i ++ ) {
58- if ( ! guildMember . roles . cache . has ( roles [ i ] . id ) ) {
59- try {
60- consola . info ( `Adding ${ roles [ i ] . id } to ${ nickname } ...` ) ;
61- await guildMember . roles . add ( arr ) ;
62- } catch ( e ) {
63- consola . error ( `Failed to add ${ roles [ i ] . id } to ${ nickname } .\nReason: ${ e } ` )
64- }
58+ try {
59+ consola . info ( `Adding ${ arr [ i ] } to ${ nickname } ...` ) ;
60+ guildMember . roles . add ( arr ) ;
61+ } catch ( e ) {
62+ consola . error ( `Failed to add ${ arr [ i ] } to ${ nickname } .\nReason: ${ e } ` )
6563 }
6664 }
6765
6866 this . emit ( 'userVerified' , guildMember . guild , guildMember ) ;
6967
70- } catch ( e ) {
68+ } catch ( e ) {
7169 console . error ( e ) ;
7270 }
7371 }
7472
7573 private async findGuildMember ( userId : string ) {
76- const guild = this . guilds . cache . get ( " guildId" ) ;
74+ const guild = this . guilds . cache . get ( this . tourneyConfig . discord . guildId ) ;
7775
7876 if ( guild === undefined )
7977 throw new Error ( "Invalid guild. Bot is likely not joined to the correct guild." ) ;
@@ -96,7 +94,7 @@ export default class DiscordBot extends Client {
9694 return true ;
9795 else
9896 return false ;
99- } catch ( e ) {
97+ } catch ( e ) {
10098 consola . error ( e ) ;
10199 return false ;
102100 }
0 commit comments