Skip to content

Commit

Permalink
Fix /casket command
Browse files Browse the repository at this point in the history
  • Loading branch information
gc committed Oct 12, 2024
1 parent befda3c commit 6e61477
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/lib/workers/casket.worker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '../data/itemAliases';

import { roll } from 'e';
import { Bank, EliteMimicTable, MasterMimicTable } from 'oldschooljs';
import { EliteMimicTable, type ItemBank, MasterMimicTable } from 'oldschooljs';

import type { CasketWorkerArgs } from '.';
import { ClueTiers } from '../clues/clueTiers';
Expand All @@ -10,7 +10,7 @@ if (global.prisma || global.redis) {
throw new Error('Prisma/Redis is loaded in the casket worker!');
}

export default async ({ clueTierID, quantity }: CasketWorkerArgs): Promise<[Bank, string]> => {
export default async ({ clueTierID, quantity }: CasketWorkerArgs): Promise<[ItemBank, string]> => {
const clueTier = ClueTiers.find(tier => tier.id === clueTierID)!;
const loot = clueTier.table.roll(quantity);
let mimicNumber = 0;
Expand All @@ -31,5 +31,5 @@ export default async ({ clueTierID, quantity }: CasketWorkerArgs): Promise<[Bank
: ''
}`;

return [new Bank(loot), opened];
return [loot.toJSON(), opened];
};
3 changes: 1 addition & 2 deletions src/lib/workers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import path, { resolve } from 'node:path';

import type { Bank } from 'oldschooljs';
import Piscina from 'piscina';

import type { ItemBank } from '../types';
Expand Down Expand Up @@ -66,7 +65,7 @@ const casketWorker = new Piscina({
});

export const Workers = {
casketOpen: (args: CasketWorkerArgs): Promise<[Bank, string]> => casketWorker.run(args),
casketOpen: (args: CasketWorkerArgs): Promise<[ItemBank, string]> => casketWorker.run(args),
kill: (args: KillWorkerArgs): KillWorkerReturn => killWorker.run(args),
finish: (args: FinishWorkerArgs): FinishWorkerReturn => finishWorker.run(args)
};
5 changes: 3 additions & 2 deletions src/mahoji/commands/casket.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { CommandRunOptions } from '@oldschoolgg/toolkit/util';
import { ApplicationCommandOptionType } from 'discord.js';
import { Bank } from 'oldschooljs';

import { ClueTiers } from '../../lib/clues/clueTiers';
import { PerkTier } from '../../lib/constants';
Expand Down Expand Up @@ -56,8 +57,8 @@ export const casketCommand: OSBMahojiCommand = {

await deferInteraction(interaction);

const [loot, title] = await Workers.casketOpen({ quantity: options.quantity, clueTierID: clueTier.id });

const [_loot, title] = await Workers.casketOpen({ quantity: options.quantity, clueTierID: clueTier.id });
const loot = new Bank(_loot);
if (loot.length === 0) return `${title} and got nothing :(`;

const image = await makeBankImage({
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/sanity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { describe, expect, test } from 'vitest';
import Buyables from '../../src/lib/data/buyables/buyables';
import { marketPriceOfBank } from '../../src/lib/marketPrices';
import { allOpenables } from '../../src/lib/openables';
import { itemNameFromID } from '../../src/lib/util';
import getOSItem from '../../src/lib/util/getOSItem';
import itemID from '../../src/lib/util/itemID';
import itemIsTradeable from '../../src/lib/util/itemIsTradeable';
import { BingoTrophies } from '../../src/mahoji/lib/bingo/BingoManager';
import { itemNameFromID } from '../../src/lib/util';

describe('Sanity', () => {
test('misc', () => {
Expand Down

0 comments on commit 6e61477

Please sign in to comment.