@@ -17,23 +17,20 @@ const sendCardWithInfo = async (interaction, playerParam) => {
17
17
18
18
if ( discordUserId ) {
19
19
const guild = await interaction . guild . fetch ( )
20
- return guild . members . fetch ( discordUserId )
21
- . then ( async ( member ) => {
22
- const discordUserId = member . user . id
20
+ let member = null
21
+ try { member = await guild . members . fetch ( discordUserId ) } catch { throw 'error.user.notFound' }
23
22
24
- if ( ! interaction . member . permissions . has ( 'ManageRoles' ) && discordUserId !== discordId )
25
- return errorCard ( 'error.user.permissions.manageRoles' , lang )
26
- else if ( member . user . bot ) return errorCard ( 'error.user.noBotLink' , lang )
23
+ if ( ! interaction . member . permissions . has ( 'ManageRoles' ) && discordUserId !== discordId )
24
+ return errorCard ( 'error.user.permissions.manageRoles' , lang )
25
+ else if ( member . user . bot ) return errorCard ( 'error.user.noBotLink' , lang )
27
26
28
- const exists = await User . getWithGuild ( discordUserId , null )
29
- if ( exists )
30
- return errorCard ( getTranslation ( 'error.user.globalLink' , lang , {
31
- discord : `<@${ discordUserId } >`
32
- } ) , lang )
27
+ const exists = await User . getWithGuild ( discordUserId , null )
28
+ if ( exists )
29
+ return errorCard ( getTranslation ( 'error.user.globalLink' , lang , {
30
+ discord : `<@${ discordUserId } >`
31
+ } ) , lang )
33
32
34
- return link ( interaction , playerParam , discordUserId , guild . id , nickname )
35
- } )
36
- . catch ( ( ) => errorCard ( 'error.user.notFound' , lang ) )
33
+ return link ( interaction , playerParam , discordUserId , guild . id , nickname )
37
34
}
38
35
39
36
return link ( interaction , playerParam , discordId , null , nickname )
0 commit comments