Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class GuildLeaderboardService extends LeaderboardService {

const ranking = await this.getLeaderboardRankings(Guild, [field], input);

if (!ranking || !ranking[0].rank) throw new GuildNotFoundException();
if (!ranking || !ranking[0] || !ranking[0].rank) throw new GuildNotFoundException();

return ranking[0].rank;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class BaseLeaderboardCommand {

if (interaction.getUserId() === userId && !message.ephemeral) {
up.disable(page === 0);
currentPage = page || currentPage;
currentPage = page ?? currentPage;
const row = new ActionRowBuilder([up, down, searchDocument, searchPosition]);

context.reply({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const list = getLeaderboardFields(Guild).map(
);

const fuse = new Fuse(list, {
keys: ["name", "key"],
keys: ["name", "value"],
includeScore: false,
shouldSort: true,
isCaseSensitive: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const entries = Object.entries(
);

const FUSE_OPTIONS = {
keys: ["name", "key"],
keys: ["name", "value"],
includeScore: false,
shouldSort: true,
isCaseSensitive: false,
Expand Down
6 changes: 4 additions & 2 deletions packages/discord/src/services/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ export class ApiService extends StatsifyApiService {
type: LeaderboardQuery
) {
return super.getPlayerLeaderboard(field, input, type).catch((err: AxiosError) => {
if ((err.response?.data as PlayerNotFoundException).statusCode === 404) return null;
if (!err.response || !err.response.data) throw this.unknownError();
if ((err.response.data as PlayerNotFoundException).statusCode === 404) return null;
throw new ErrorMessage("errors.leaderboardNotFound");
});
}
Expand All @@ -201,7 +202,8 @@ export class ApiService extends StatsifyApiService {
type: LeaderboardQuery
) {
return super.getGuildLeaderboard(field, input, type).catch((err: AxiosError) => {
if ((err.response?.data as GuildNotFoundException).statusCode === 404) return null;
if (!err.response || !err.response.data) throw this.unknownError();
if ((err.response.data as GuildNotFoundException).statusCode === 404) return null;
throw new ErrorMessage("errors.leaderboardNotFound");
});
}
Expand Down
Loading