small tweaks
This commit is contained in:
parent
a2a56f60f1
commit
0594cc71db
|
@ -1,6 +1,6 @@
|
|||
import { AutocompleteInteraction, GuildMember, CommandInteraction, SlashCommandBuilder } from 'discord.js';
|
||||
import { CraftingStationCooldown, db } from '../lib/db';
|
||||
import { getStation, canUseStation, craftingStations, verb } from '../lib/rpg/craftingStations';
|
||||
import { getStation, canUseStation, craftingStations, verb, CraftingStation } from '../lib/rpg/craftingStations';
|
||||
import { formatItem, getItemQuantity, formatItems, getMaxStack, giveItem, formatItemsArray } from '../lib/rpg/items';
|
||||
import { getRecipe, defaultRecipes, formatRecipe } from '../lib/rpg/recipes';
|
||||
import { Command } from '../types/index';
|
||||
|
@ -95,15 +95,21 @@ export default {
|
|||
nextUsableAt = Date.now() + station.cooldown * 1000;
|
||||
}
|
||||
|
||||
return interaction.followUp(`${station.emoji} ${verb(station)} ${formatItemsArray(outputs)}!${nextUsableAt ? `\n${station.name} usable again <t:${Math.floor(nextUsableAt / 1000)}:R>` : ''}`);
|
||||
return interaction.followUp(`${station.emoji} ${verb(station)} ${formatItemsArray(outputs)}!${outputs.length === 1 ? `\n_${outputs[0].item.description}_` : ''}${nextUsableAt ? `\n${station.name} usable again <t:${Math.floor(nextUsableAt / 1000)}:R>` : ''}`);
|
||||
},
|
||||
|
||||
autocomplete: async (interaction: AutocompleteInteraction) => {
|
||||
const focused = interaction.options.getFocused(true);
|
||||
|
||||
if (focused.name === 'station') {
|
||||
const found = craftingStations
|
||||
.filter(station => canUseStation(interaction.user.id, station))
|
||||
const found = (await Promise.all(
|
||||
craftingStations
|
||||
.map(async station => [station, await canUseStation(interaction.user.id, station)])
|
||||
))
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
.filter(([_station, usable]) => usable)
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
.map(([station, _]) => station as CraftingStation)
|
||||
.filter(station => station.name.toLowerCase().includes(focused.value.toLowerCase()))
|
||||
.map(station => ({
|
||||
name: `${station.emoji} ${station.name}`,
|
||||
|
|
|
@ -24,7 +24,7 @@ export default {
|
|||
const items = (await Promise.all(itemsList.map(async i => ({item: await getItem(i.item), quantity: i.quantity})))).filter(i => i.item);
|
||||
|
||||
await interaction.followUp(
|
||||
`Your inventory:\n${items.length === 0 ? '_Your inventory is empty!_' : items.map(i => `- ${formatItems(i.item!, i.quantity)}`).join('\n')}`
|
||||
`Your inventory:\n${items.length === 0 ? '_Your inventory is empty!_' : items.map(i => `- ${formatItems(i.item!, i.quantity)}\n_${i.item!.description}_`).join('\n')}`
|
||||
);
|
||||
}
|
||||
} satisfies Command;
|
|
@ -74,7 +74,7 @@ export const craftingStations: CraftingStation[] = [
|
|||
emoji: '🎣',
|
||||
requires: getDefaultItem(DefaultItems.FISHING_ROD),
|
||||
formatRecipe: (inputs, requirements, outputs, disableBold = false) =>
|
||||
`${formatItemsArray(inputs)} => ${outputs.map(i => formatItem(i.item, disableBold) + '?').join(' ')}`,
|
||||
`${formatItemsArray(inputs, disableBold)} => ${outputs.map(i => formatItem(i.item, disableBold) + '?').join(' ')}`,
|
||||
// weighted random
|
||||
manipulateResults: (outputs) => {
|
||||
const pool: Item[] = [];
|
||||
|
|
|
@ -112,7 +112,7 @@ export const defaultItems: DefaultItem[] = [
|
|||
{
|
||||
id: -10,
|
||||
name: 'Bait',
|
||||
description: 'I _guess_ you could eat this.',
|
||||
description: 'I guess you could eat this.',
|
||||
emoji: '🪱',
|
||||
type: 'consumable',
|
||||
maxStack: 128,
|
||||
|
|
Loading…
Reference in New Issue