From 9333d6ac6cbd97a70192eb56819a87bff73c111e Mon Sep 17 00:00:00 2001 From: syntaxbullet Date: Mon, 15 Dec 2025 22:21:29 +0100 Subject: [PATCH] feat: Prevent inventory, profile, balance, and pay commands from targeting bot users. --- src/commands/economy/balance.ts | 6 ++++++ src/commands/economy/pay.ts | 7 +++++++ src/commands/inventory/inventory.ts | 6 ++++++ src/commands/user/profile.ts | 7 +++++++ 4 files changed, 26 insertions(+) diff --git a/src/commands/economy/balance.ts b/src/commands/economy/balance.ts index 8306368..34a5386 100644 --- a/src/commands/economy/balance.ts +++ b/src/commands/economy/balance.ts @@ -1,6 +1,7 @@ import { createCommand } from "@/lib/utils"; import { SlashCommandBuilder, EmbedBuilder } from "discord.js"; import { userService } from "@/modules/user/user.service"; +import { createWarningEmbed } from "@/lib/embeds"; export const balance = createCommand({ data: new SlashCommandBuilder() @@ -15,6 +16,11 @@ export const balance = createCommand({ await interaction.deferReply(); const targetUser = interaction.options.getUser("user") || interaction.user; + + if (targetUser.bot) { + return; // Wait, I need to send the reply inside the if. + } + const user = await userService.getOrCreateUser(targetUser.id, targetUser.username); const embed = new EmbedBuilder() diff --git a/src/commands/economy/pay.ts b/src/commands/economy/pay.ts index 10668b4..e2f7a9c 100644 --- a/src/commands/economy/pay.ts +++ b/src/commands/economy/pay.ts @@ -23,6 +23,13 @@ export const pay = createCommand({ ), execute: async (interaction) => { const targetUser = await userService.getOrCreateUser(interaction.options.getUser("user", true).id, interaction.options.getUser("user", true).username); + const discordUser = interaction.options.getUser("user", true); + + if (discordUser.bot) { + await interaction.reply({ embeds: [createWarningEmbed("You cannot send money to bots.")], flags: MessageFlags.Ephemeral }); + return; + } + const amount = BigInt(interaction.options.getInteger("amount", true)); const senderId = interaction.user.id; const receiverId = targetUser.id; diff --git a/src/commands/inventory/inventory.ts b/src/commands/inventory/inventory.ts index fe6412e..3ba9894 100644 --- a/src/commands/inventory/inventory.ts +++ b/src/commands/inventory/inventory.ts @@ -17,6 +17,12 @@ export const inventory = createCommand({ await interaction.deferReply(); const targetUser = interaction.options.getUser("user") || interaction.user; + + if (targetUser.bot) { + await interaction.editReply({ embeds: [createWarningEmbed("Bots do not have inventories.", "Inventory Check")] }); + return; + } + const user = await userService.getOrCreateUser(targetUser.id, targetUser.username); const items = await inventoryService.getInventory(user.id); diff --git a/src/commands/user/profile.ts b/src/commands/user/profile.ts index a2c034e..ea4fcd6 100644 --- a/src/commands/user/profile.ts +++ b/src/commands/user/profile.ts @@ -2,6 +2,7 @@ import { createCommand } from "@/lib/utils"; import { SlashCommandBuilder, AttachmentBuilder } from "discord.js"; import { userService } from "@/modules/user/user.service"; import { generateStudentIdCard } from "@/graphics/studentID"; +import { createWarningEmbed } from "@/lib/embeds"; export const profile = createCommand({ data: new SlashCommandBuilder() @@ -16,6 +17,12 @@ export const profile = createCommand({ await interaction.deferReply(); const targetUser = interaction.options.getUser("user") || interaction.user; + + if (targetUser.bot) { + await interaction.editReply({ embeds: [createWarningEmbed("Bots do not have profiles.", "Profile Check")] }); + return; + } + const user = await userService.getOrCreateUser(targetUser.id, targetUser.username); const cardBuffer = await generateStudentIdCard({