From 1ab0a8c21d736cea6a37627d1b98149b8f297299 Mon Sep 17 00:00:00 2001 From: kdh8219 <65698239+kdh8219@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:55:35 +0900 Subject: [PATCH] fix nickname null bug --- src/command/commands/get_members.ts | 4 +++- src/command/commands/search.ts | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/command/commands/get_members.ts b/src/command/commands/get_members.ts index b713337..e517ffd 100755 --- a/src/command/commands/get_members.ts +++ b/src/command/commands/get_members.ts @@ -37,7 +37,9 @@ export default { for (const member of member_data) { let nickname: string; try { - nickname = (await interaction.guild.members.fetch(member[0])).nickname; + nickname = + (await interaction.guild.members.fetch(member[0])).nickname || + (await interaction.client.users.fetch(member[0])).username; } catch (e) { nickname = ``; } diff --git a/src/command/commands/search.ts b/src/command/commands/search.ts index 97bdb45..a5d073d 100755 --- a/src/command/commands/search.ts +++ b/src/command/commands/search.ts @@ -73,9 +73,10 @@ export default { content: "`에러`: 해당 멤버는 등록되지 않았어요!", }); } - let text = ""; - text += (await interaction.guild.members.fetch(discord_id)).nickname; + text += + (await interaction.guild.members.fetch(discord_id)).nickname || + interaction.user.username; text += ": "; for (const user of the_datas.docs) { const minecraft_uuid = user.data()["minecraft_uuid"];