From 483ca91efe7b10498e85b0a085c617b82e0cb9f3 Mon Sep 17 00:00:00 2001 From: GhomKrosmonaute Date: Sat, 21 Oct 2023 16:21:07 +0200 Subject: [PATCH] fixe empty ladders --- src/namespaces/ladder.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/namespaces/ladder.ts b/src/namespaces/ladder.ts index dce11d31..8a6fd0bf 100644 --- a/src/namespaces/ladder.ts +++ b/src/namespaces/ladder.ts @@ -34,10 +34,16 @@ export class Ladder { return lines.map(this.options.formatLine).join("\n") } - async fetchEmbed(options: LadderPaginatorOptions) { + async fetchEmbed( + ctx: { client: discord.Client }, + options: LadderPaginatorOptions + ) { return new discord.MessageEmbed() .setTitle(`${this.options.title} leaderboard`) - .setDescription(await this.fetchPage(options)) + .setDescription( + (await this.fetchPage(options)) || + `${tools.emote(ctx, "DENY")} No ladder available` + ) .setFooter({ text: `Page: ${options.pageIndex + 1} / ${await this.fetchPageCount( options @@ -71,7 +77,7 @@ export class Ladder { if (page.length === 0) return `${tools.emote(channel, "DENY")} No ladder available.` - return await this.fetchEmbed({ + return await this.fetchEmbed(channel, { pageIndex, ...options, })