Skip to content

Commit

Permalink
Add quantity owned to ge sell autocomplete (#5919)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwjgit committed Jun 17, 2024
1 parent e10c7eb commit 627e68f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/mahoji/commands/ge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { handleMahojiConfirmation } from '../../lib/util/handleMahojiConfirmatio
import { deferInteraction } from '../../lib/util/interactionReply';
import itemIsTradeable from '../../lib/util/itemIsTradeable';
import { cancelGEListingCommand } from '../lib/abstracted_commands/cancelGEListingCommand';
import { itemOption, ownedItemOption, tradeableItemArr } from '../lib/mahojiCommandOptions';
import { itemOption, tradeableItemArr } from '../lib/mahojiCommandOptions';
import { OSBMahojiCommand } from '../lib/util';

export type GEListingWithTransactions = GEListing & {
Expand Down Expand Up @@ -130,10 +130,19 @@ export const geCommand: OSBMahojiCommand = {
description: 'Sell something on the grand exchange.',
options: [
{
...ownedItemOption(item => Boolean(item.tradeable_on_ge)),
name: 'item',
type: ApplicationCommandOptionType.String,
description: 'The item you want to sell.',
required: true
required: true,
autocomplete: async (value, { id }) => {
const user = await mUserFetch(id);

return user.bank
.items()
.filter(i => i[0].tradeable_on_ge)
.filter(i => (!value ? true : i[0].name.toLowerCase().includes(value.toLowerCase())))

Check warning on line 143 in src/mahoji/commands/ge.ts

View workflow job for this annotation

GitHub Actions / Node v18.12.0 - ubuntu-latest

Unexpected string value in conditional. An explicit empty string check is required

Check warning on line 143 in src/mahoji/commands/ge.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

Unexpected string value in conditional. An explicit empty string check is required
.map(i => ({ name: `${i[0].name} (${i[1]}x Owned)`, value: i[0].name }));
}
},
quantityOption,
priceOption
Expand Down

0 comments on commit 627e68f

Please sign in to comment.