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