Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
abbyfour committed Nov 28, 2024
1 parent 0ccace6 commit 4215bc2
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 21 deletions.
5 changes: 3 additions & 2 deletions src/commands/Fishy/Collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ export class Collection extends FishyChildCommand<typeof args> {
.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,
Expand Down
14 changes: 8 additions & 6 deletions src/commands/Lastfm/NowPlaying/Config/Set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ export class Set extends NowPlayingConfigChildCommand<typeof args> {
}
}

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
Expand All @@ -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()
)
Expand Down
4 changes: 1 addition & 3 deletions src/errors/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/paginators/PaginatedScrobbleCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<LilacScrobble> {
Expand Down Expand Up @@ -47,7 +47,7 @@ export class PaginatedLilacScrobbleCache extends PaginatedCache<LilacScrobble> {
embed: EmbedView,
firstPage: LilacScrobblesPage,
generateTableRow: (scrobble: LilacScrobble) => string,
overrides: Partial<ScrollinViewOptions> = {}
overrides: Partial<ScrollingViewOptions> = {}
): Promise<ScrollingView> {
const scrollingEmbed = new ScrollingView(this.ctx, embed, {
initialItems: this.generateTable(
Expand Down
11 changes: 8 additions & 3 deletions src/lib/ui/fishy.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
}`;
}
4 changes: 2 additions & 2 deletions src/lib/ui/views/ScrollingListView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -18,7 +18,7 @@ export interface ScrollingListViewOptions<T> {
pageInfo: { page: number; offset: number }
) => string;

overrides?: Partial<ScrollinViewOptions>;
overrides?: Partial<ScrollingViewOptions>;
}

export class ScrollingListView<T> extends ScrollingView {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/ui/views/ScrollingView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -51,7 +51,7 @@ export class ScrollingView extends View {
constructor(
private ctx: GowonContext,
private embed: EmbedView,
options: Partial<ScrollinViewOptions>
options: Partial<ScrollingViewOptions>
) {
super();

Expand Down

0 comments on commit 4215bc2

Please sign in to comment.