Skip to content

Commit 81dcc4c

Browse files
JustDamsweb-flow
andauthored
fix: wrong error message thrown (#454)
Co-authored-by: JustDams <noreply@github.com>
1 parent 82ba755 commit 81dcc4c

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

commands/link.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,20 @@ const sendCardWithInfo = async (interaction, playerParam) => {
1717

1818
if (discordUserId) {
1919
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' }
2322

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)
2726

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)
3332

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)
3734
}
3835

3936
return link(interaction, playerParam, discordId, null, nickname)

0 commit comments

Comments
 (0)