Skip to content

Commit

Permalink
Merge branch 'main' into refactor/modularize_apiServer
Browse files Browse the repository at this point in the history
  • Loading branch information
tim80411 committed Jul 16, 2023
2 parents ea8bdfb + 79b5ba9 commit a41bcce
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// 使用 IntelliSense 以得知可用的屬性。
// 暫留以檢視現有屬性的描述。
// 如需詳細資訊,請瀏覽: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach to pm2",
"type": "node",
"request": "attach",
"restart": true,
"port": 9229
}
]
}
8 changes: 5 additions & 3 deletions src/apiServer/routes/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ router.get('/', validate, async function (req, res) {

const fetchUserDetails = async (doc) => {
const data = doc.data();
const discordUser = await client.users.fetch(data.discordId);
const guild = await client.guilds.fetch(process.env.DISCORD_GUILDID);
const member = await guild.members.fetch(data.discordId);

return {
id: doc.id,
name: discordUser.username,
avatarURL: discordUser.displayAvatarURL(),
name: member.nickname || member.user.username,
avatarURL: member.user.displayAvatarURL(),
...data
};
};
Expand Down

0 comments on commit a41bcce

Please sign in to comment.