various tiny fixes now that i can actually test it
This commit is contained in:
parent
42d875a68f
commit
41af7fa2e2
|
@ -78,14 +78,14 @@ module.exports = {
|
|||
.insert({
|
||||
station: station.key,
|
||||
user: member.id,
|
||||
usedAt: db.fn.now()
|
||||
usedAt: Date.now()
|
||||
});
|
||||
} else {
|
||||
await db<CraftingStationCooldown>('craftingStationCooldowns')
|
||||
.where('station', station.key)
|
||||
.where('user', member.id)
|
||||
.update({
|
||||
usedAt: db.fn.now()
|
||||
usedAt: Date.now()
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -113,8 +113,8 @@ module.exports = {
|
|||
.filter(recipe => recipe.station === interaction.options.getString('station'))
|
||||
.filter(recipe => recipe.outputs.filter(n => n.item.name.toLowerCase().includes(focused.value.toLowerCase())).length > 0)
|
||||
.map(recipe => ({
|
||||
name: formatRecipe(recipe),
|
||||
value: recipe.id
|
||||
name: formatRecipe(recipe, true),
|
||||
value: recipe.id.toString()
|
||||
}));
|
||||
|
||||
return interaction.respond(found);
|
||||
|
|
|
@ -8,7 +8,7 @@ export interface CraftingStation {
|
|||
requires?: Item,
|
||||
// in seconds
|
||||
cooldown?: number,
|
||||
formatRecipe?: (inputs: Items[], requirements: Items[], outputs: Items[]) => string,
|
||||
formatRecipe?: (inputs: Items[], requirements: Items[], outputs: Items[], disableBold?: boolean) => string,
|
||||
manipulateResults?: (outputs: Items[]) => Items[]
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ export const craftingStations: CraftingStation[] = [
|
|||
description: 'Pick up various sticks and stones from the forest',
|
||||
emoji: '🌲',
|
||||
cooldown: 60 * 5,
|
||||
formatRecipe: (_inputs, _requirements, outputs) => `${outputs.map(i => formatItems(i.item, i.quantity) + '?').join(' ')}`,
|
||||
formatRecipe: (_inputs, _requirements, outputs, disableBold = false) => `${outputs.map(i => formatItems(i.item, i.quantity, disableBold) + '?').join(' ')}`,
|
||||
manipulateResults: (outputs) =>
|
||||
outputs.map(o => ({item: o.item, quantity: Math.floor(o.quantity * Math.random())})).filter(o => o.quantity !== 0)
|
||||
},
|
||||
|
|
|
@ -109,15 +109,16 @@ export function getMaxStack(item: Item) {
|
|||
return item.type === 'weapon' ? 1 : item.maxStack;
|
||||
}
|
||||
|
||||
export function formatItem(item: Item | undefined) {
|
||||
if (!item) return '? **MISSINGNO**';
|
||||
return `${item.emoji} **${item.name}**`;
|
||||
export function formatItem(item: Item | undefined, disableBold = false) {
|
||||
if (!item) return disableBold ? '? MISSINGNO' : '? **MISSINGNO**';
|
||||
return disableBold ? `${item.emoji} ${item.name}` : `${item.emoji} **${item.name}**`;
|
||||
}
|
||||
export function formatItems(item: Item | undefined, quantity: number) {
|
||||
return `${quantity}x ${formatItem(item)}`;
|
||||
export function formatItems(item: Item | undefined, quantity: number, disableBold = false) {
|
||||
return `${quantity}x ${formatItem(item, disableBold)}`;
|
||||
}
|
||||
export function formatItemsArray(items: Items[]) {
|
||||
return items.map(i => formatItems(i.item, i.quantity)).join(' ');
|
||||
export function formatItemsArray(items: Items[], disableBold = false) {
|
||||
if (items.length === 0) return disableBold ? 'nothing' : '**nothing**';
|
||||
return items.map(i => formatItems(i.item, i.quantity, disableBold)).join(' ');
|
||||
}
|
||||
|
||||
export async function itemAutocomplete(interaction: AutocompleteInteraction) {
|
||||
|
|
|
@ -40,10 +40,10 @@ export function getRecipe(id: number): Recipe | undefined {
|
|||
return getDefaultRecipe(id); // currently just a stub
|
||||
}
|
||||
|
||||
const defaultFormatRecipe = (inputs: Items[], requirements: Items[], outputs: Items[]) =>
|
||||
`${formatItemsArray(inputs)}${requirements.length === 0 ? '' : ` w/ ${formatItemsArray(requirements)}`} => ${formatItemsArray(outputs)}`;
|
||||
const defaultFormatRecipe = (inputs: Items[], requirements: Items[], outputs: Items[], disableBold = false) =>
|
||||
`${formatItemsArray(inputs, disableBold)}${requirements.length === 0 ? '' : ` w/ ${formatItemsArray(requirements, disableBold)}`} => ${formatItemsArray(outputs, disableBold)}`;
|
||||
|
||||
export function formatRecipe(recipe: DefaultRecipe) {
|
||||
export function formatRecipe(recipe: DefaultRecipe, disableBold = false) {
|
||||
const station = getStation(recipe.station);
|
||||
return (station?.formatRecipe || defaultFormatRecipe)(recipe.inputs, recipe.requirements, recipe.outputs);
|
||||
return (station?.formatRecipe || defaultFormatRecipe)(recipe.inputs, recipe.requirements, recipe.outputs, disableBold);
|
||||
}
|
Loading…
Reference in New Issue