From 4215bc225f6d6e245afcd2edf701de50e5e1c5ce Mon Sep 17 00:00:00 2001 From: John Ivison Date: Thu, 28 Nov 2024 04:31:31 -0800 Subject: [PATCH] Small fixes --- src/commands/Fishy/Collection.ts | 5 +++-- src/commands/Lastfm/NowPlaying/Config/Set.ts | 14 ++++++++------ src/errors/errors.ts | 4 +--- src/lib/paginators/PaginatedScrobbleCache.ts | 4 ++-- src/lib/ui/fishy.ts | 11 ++++++++--- src/lib/ui/views/ScrollingListView.ts | 4 ++-- src/lib/ui/views/ScrollingView.ts | 6 +++--- 7 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/commands/Fishy/Collection.ts b/src/commands/Fishy/Collection.ts index a5952fc9..05ce2061 100644 --- a/src/commands/Fishy/Collection.ts +++ b/src/commands/Fishy/Collection.ts @@ -41,8 +41,9 @@ export class Collection extends FishyChildCommand { .filter((f) => f && f.hidden) as Fishy[]), ]; - const embed = this.minimalEmbed() - .setTitle(`${perspective.upper.possessive} fishy collection`); + const embed = this.minimalEmbed().setTitle( + `${perspective.upper.possessive} fishy collection` + ); const scrollingEmbed = new ScrollingListView(this.ctx, embed, { items: fishyDisplayList, diff --git a/src/commands/Lastfm/NowPlaying/Config/Set.ts b/src/commands/Lastfm/NowPlaying/Config/Set.ts index f056f657..f2855ab9 100644 --- a/src/commands/Lastfm/NowPlaying/Config/Set.ts +++ b/src/commands/Lastfm/NowPlaying/Config/Set.ts @@ -79,8 +79,14 @@ export class Set extends NowPlayingConfigChildCommand { } } + const successMessage = presetConfig + ? `${Emoji.checkmark} Using preset ${code(newConfig[0])}:` + : filtered.length + ? `${Emoji.checkmark} Successfully set your config as:` + : ""; + const filteredDisplay = filtered.length - ? `${Emoji.checkmark} Successfully set your config as:\n\`\`\`diff + ? `\`\`\`diff ${filtered.map((f) => `+ ${f}`).join("\n")}\`\`\`` : ""; const filteredOutDisplay = filteredOut.length @@ -90,11 +96,7 @@ ${filteredOut.map((f) => `- ${f}`).join("\n")}\`\`\`` const embed = this.minimalEmbed() .setDescription( - `${ - presetConfig - ? `${Emoji.checkmark} Using preset ${code(newConfig[0])}` - : "" - } + `${successMessage} ${filteredDisplay} ${filteredOutDisplay}`.trim() ) diff --git a/src/errors/errors.ts b/src/errors/errors.ts index 3a40f05d..a2d281da 100644 --- a/src/errors/errors.ts +++ b/src/errors/errors.ts @@ -175,9 +175,7 @@ export class CrownBannedError extends ClientError { name = "CrownBannedError"; constructor() { - super( - "you have been banned from the crowns game. If you think this is an error please speak to a staff member." - ); + super("you have been banned from the crowns game."); } } diff --git a/src/lib/paginators/PaginatedScrobbleCache.ts b/src/lib/paginators/PaginatedScrobbleCache.ts index 96d4efa1..19904165 100644 --- a/src/lib/paginators/PaginatedScrobbleCache.ts +++ b/src/lib/paginators/PaginatedScrobbleCache.ts @@ -9,7 +9,7 @@ import { LilacLibraryService } from "../../services/lilac/LilacLibraryService"; import { GowonContext } from "../context/Context"; import { displayNumberedList } from "../ui/displays"; import { EmbedView } from "../ui/views/EmbedView"; -import { ScrollinViewOptions, ScrollingView } from "../ui/views/ScrollingView"; +import { ScrollingView, ScrollingViewOptions } from "../ui/views/ScrollingView"; import { PaginatedCache } from "./PaginatedCache"; export class PaginatedLilacScrobbleCache extends PaginatedCache { @@ -47,7 +47,7 @@ export class PaginatedLilacScrobbleCache extends PaginatedCache { embed: EmbedView, firstPage: LilacScrobblesPage, generateTableRow: (scrobble: LilacScrobble) => string, - overrides: Partial = {} + overrides: Partial = {} ): Promise { const scrollingEmbed = new ScrollingView(this.ctx, embed, { initialItems: this.generateTable( diff --git a/src/lib/ui/fishy.ts b/src/lib/ui/fishy.ts index abe19e68..c6cfa68a 100644 --- a/src/lib/ui/fishy.ts +++ b/src/lib/ui/fishy.ts @@ -1,9 +1,8 @@ import { bold } from "../../helpers/discord"; import { Fishy } from "../../services/fishy/Fishy"; -import { fishyList } from "../../services/fishy/fishyList"; +import { findFishy, fishyList } from "../../services/fishy/fishyList"; import { FishyRarityData } from "../../services/fishy/rarity"; import { Emoji } from "../emoji/Emoji"; -import { displayNumber } from "./displays"; export function displayRarity( rarity: FishyRarityData, @@ -35,6 +34,12 @@ export function displayFishyLevelUp(level: number): string { export function displayFishyCollectionProgress(collection: string[]) { const noHidden = fishyList.filter((f) => !f.hidden); + const hiddenCount = collection.filter( + (f) => findFishy({ byID: f })?.hidden + ).length; + const nonHiddenCount = collection.length - hiddenCount; - return `${displayNumber(collection.length)} of ${noHidden.length}`; + return `${nonHiddenCount}${hiddenCount ? `+${hiddenCount}` : ""} of ${ + noHidden.length + }`; } diff --git a/src/lib/ui/views/ScrollingListView.ts b/src/lib/ui/views/ScrollingListView.ts index 3f628a7d..50070419 100644 --- a/src/lib/ui/views/ScrollingListView.ts +++ b/src/lib/ui/views/ScrollingListView.ts @@ -2,8 +2,8 @@ import { EmbedFieldData } from "discord.js"; import { GowonContext } from "../../context/Context"; import { EmbedView } from "./EmbedView"; import { - ScrollinViewOptions, ScrollingView, + ScrollingViewOptions, isEmbedFields, } from "./ScrollingView"; @@ -18,7 +18,7 @@ export interface ScrollingListViewOptions { pageInfo: { page: number; offset: number } ) => string; - overrides?: Partial; + overrides?: Partial; } export class ScrollingListView extends ScrollingView { diff --git a/src/lib/ui/views/ScrollingView.ts b/src/lib/ui/views/ScrollingView.ts index 75175264..d4acfc28 100644 --- a/src/lib/ui/views/ScrollingView.ts +++ b/src/lib/ui/views/ScrollingView.ts @@ -12,7 +12,7 @@ import { displayNumber } from "../displays"; import { EmbedView } from "./EmbedView"; import { View } from "./View"; -export interface ScrollinViewOptions { +export interface ScrollingViewOptions { initialItems: string | EmbedFieldData[]; totalPages: number; totalItems: number; @@ -40,7 +40,7 @@ export function isEmbedFields( export class ScrollingView extends View { private currentPage = 1; private currentItems: string | EmbedFieldData[]; - private options: ScrollinViewOptions; + private options: ScrollingViewOptions; private onPageChangeCallback: OnPageChangeCallback = () => ""; private readonly leftArrow = EmojiRaw.arrowLeft; @@ -51,7 +51,7 @@ export class ScrollingView extends View { constructor( private ctx: GowonContext, private embed: EmbedView, - options: Partial + options: Partial ) { super();