items part 1

This commit is contained in:
stjet
2024-08-06 08:06:31 +00:00
parent 9226debee2
commit 38c2700c2f
16 changed files with 429 additions and 26 deletions

View File

@@ -5,20 +5,18 @@ import type { CommandData } from "./index";
import type { User } from "../db";
import config from "../config.json";
import { get_user } from "../db";
import { BotError } from "./error";
import { BotError } from "./common/error";
async function run(interaction: ChatInputCommandInteraction, user: User) {
const options = interaction.options;
const target = (await options.get("target"))?.user;
let embeds = [];
let bal_embed = new EmbedBuilder();
let bal_target = target ?? interaction.user;
let bal_user = target ? await get_user(target.id) : user;
if (!bal_user) throw new BotError("Target is not registered"); //must be target
bal_embed.setTitle(`${bal_target.tag}'s Balance`);
bal_embed.setDescription(`${bal_user.balance} ${ bal_user.balance === 1 ? config.currency : config.currency_plural }`);
embeds.push(bal_embed);
return await interaction.editReply({ embeds });
return await interaction.editReply({ embeds: [ bal_embed ] });
}
const data: CommandData = {