Skip to content

Commit d2257b9

Browse files
author
Alex L
authored
use user mentions instead of tags in coin leaderboard (#518)
1 parent 277acf2 commit d2257b9

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

src/commandDetails/coin/leaderboard.ts

+4-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { container, SapphireClient } from '@sapphire/framework';
2-
import { EmbedBuilder, User } from 'discord.js';
2+
import { EmbedBuilder } from 'discord.js';
33
import {
44
CodeyCommandDetails,
55
getUserFromMessage,
@@ -40,13 +40,8 @@ const getCoinLeaderboardEmbed = async (
4040
break;
4141
}
4242
const userCoinEntry = leaderboard[i++];
43-
let user: User;
44-
try {
45-
user = await client.users.fetch(userCoinEntry.user_id);
46-
} catch (e) {
47-
continue;
48-
}
49-
if (user.bot) continue;
43+
const user = await client.users.fetch(userCoinEntry.user_id).catch(() => null);
44+
if (user?.bot) continue;
5045
if (previousBalance === userCoinEntry.balance) {
5146
previousBalance = userCoinEntry.balance;
5247
// rank does not change
@@ -60,18 +55,7 @@ const getCoinLeaderboardEmbed = async (
6055
position = rank;
6156
}
6257
if (leaderboardArray.length < LEADERBOARD_LIMIT_DISPLAY) {
63-
const userTag = user?.tag ?? '<unknown>';
64-
const cleanUserTag = userTag
65-
.split('~')
66-
.join('\\~')
67-
.split('*')
68-
.join('\\*')
69-
.split('_')
70-
.join('\\_')
71-
.split('`')
72-
.join('\\`');
73-
// added a "\\" below in ${rank}\\. ${cleanUserTag} so that Markdown does not automatically increment by 1 each time
74-
const userCoinEntryText = `${rank}\\. ${cleanUserTag} - ${
58+
const userCoinEntryText = `${rank}\\. <@${userCoinEntry.user_id}> - ${
7559
userCoinEntry.balance
7660
} ${getCoinEmoji()}`;
7761
leaderboardArray.push(userCoinEntryText);

0 commit comments

Comments
 (0)