diff --git a/src/lib/util/smallUtils.ts b/src/lib/util/smallUtils.ts index d84a838087..1eaca1be36 100644 --- a/src/lib/util/smallUtils.ts +++ b/src/lib/util/smallUtils.ts @@ -332,3 +332,10 @@ export function containsBlacklistedWord(str: string): boolean { } return false; } + +export function ellipsize(str: string, maxLen: number = 2000) { + if (str.length > maxLen) { + return `${str.substring(0, maxLen - 3)}...`; + } + return str; +} diff --git a/src/mahoji/commands/drop.ts b/src/mahoji/commands/drop.ts index 88f4d3ffec..3840391128 100644 --- a/src/mahoji/commands/drop.ts +++ b/src/mahoji/commands/drop.ts @@ -1,7 +1,7 @@ import { ApplicationCommandOptionType, CommandRunOptions } from 'mahoji'; import { ClueTiers } from '../../lib/clues/clueTiers'; -import { itemNameFromID } from '../../lib/util'; +import { ellipsize, itemNameFromID, returnStringOrFile } from '../../lib/util'; import { handleMahojiConfirmation } from '../../lib/util/handleMahojiConfirmation'; import { parseBank } from '../../lib/util/parseStringBank'; import { updateBankSetting } from '../../lib/util/updateBankSetting'; @@ -66,23 +66,25 @@ export const dropCommand: OSBMahojiCommand = { ].flat(1); const doubleCheckItems = itemsToDoubleCheck.filter(f => bank.has(f)); + await handleMahojiConfirmation( + interaction, + `${user}, are you sure you want to drop ${ellipsize( + bank.toString(), + 1800 + )}? This is irreversible, and you will lose the items permanently.` + ); if (doubleCheckItems.length > 0) { await handleMahojiConfirmation( interaction, - `${user}, some of the items you are dropping look valuable, are you *really* sure you want to drop them? **${doubleCheckItems + `${user}, some of the items you are dropping are on your **favorites** or look valuable, are you *really* sure you want to drop them?\n**${doubleCheckItems .map(itemNameFromID) - .join(', ')}**` - ); - } else { - await handleMahojiConfirmation( - interaction, - `${user}, are you sure you want to drop ${bank}? This is irreversible, and you will lose the items permanently.` + .join(', ')}**\n\nDropping: ${ellipsize(bank.toString(), 1000)}` ); } await user.removeItemsFromBank(bank); updateBankSetting('dropped_items', bank); - return `Dropped ${bank}.`; + return returnStringOrFile(`Dropped ${bank}.`); } }; diff --git a/src/mahoji/commands/sell.ts b/src/mahoji/commands/sell.ts index 994fbd3587..c79979b8f6 100644 --- a/src/mahoji/commands/sell.ts +++ b/src/mahoji/commands/sell.ts @@ -7,7 +7,7 @@ import { Item, ItemBank } from 'oldschooljs/dist/meta/types'; import { MAX_INT_JAVA } from '../../lib/constants'; import { prisma } from '../../lib/settings/prisma'; import { NestBoxesTable } from '../../lib/simulation/misc'; -import { itemID, toKMB } from '../../lib/util'; +import { itemID, returnStringOrFile, toKMB } from '../../lib/util'; import { handleMahojiConfirmation } from '../../lib/util/handleMahojiConfirmation'; import { parseBank } from '../../lib/util/parseStringBank'; import { updateBankSetting } from '../../lib/util/updateBankSetting'; @@ -234,8 +234,10 @@ export const sellCommand: OSBMahojiCommand = { prisma.botItemSell.createMany({ data: botItemSellData }) ]); - return `Sold ${bankToSell} for **${totalPrice.toLocaleString()}gp (${toKMB(totalPrice)})**${ - user.isIronman ? ' (General store price)' : ` (${taxRatePercent}% below market price)` - }.`; + return returnStringOrFile( + `Sold ${bankToSell} for **${totalPrice.toLocaleString()}gp (${toKMB(totalPrice)})**${ + user.isIronman ? ' (General store price)' : ` (${taxRatePercent}% below market price)` + }.` + ); } }; diff --git a/src/mahoji/lib/abstracted_commands/statCommand.ts b/src/mahoji/lib/abstracted_commands/statCommand.ts index 4ac6cc766f..7b422798cf 100644 --- a/src/mahoji/lib/abstracted_commands/statCommand.ts +++ b/src/mahoji/lib/abstracted_commands/statCommand.ts @@ -3,7 +3,7 @@ import { sumArr, Time } from 'e'; import { CommandResponse } from 'mahoji/dist/lib/structures/ICommand'; import { Bank, Monsters } from 'oldschooljs'; import { SkillsEnum } from 'oldschooljs/dist/constants'; -import { ItemBank } from 'oldschooljs/dist/meta/types'; +import { ItemBank, SkillsScore } from 'oldschooljs/dist/meta/types'; import { TOBRooms } from 'oldschooljs/dist/simulation/misc/TheatreOfBlood'; import { toKMB } from 'oldschooljs/dist/util'; @@ -11,6 +11,7 @@ import { ClueTiers } from '../../../lib/clues/clueTiers'; import { getClueScoresFromOpenables } from '../../../lib/clues/clueUtils'; import { Emoji, PerkTier } from '../../../lib/constants'; import { calcCLDetails, isCLItem } from '../../../lib/data/Collections'; +import { skillEmoji } from '../../../lib/data/emojis'; import { getBankBgById } from '../../../lib/minions/data/bankBackgrounds'; import killableMonsters from '../../../lib/minions/data/killableMonsters'; import { RandomEvents } from '../../../lib/randomEvents'; @@ -952,6 +953,27 @@ GROUP BY "bankBackground";`); ).toLocaleString()}** XP from using the Ash Sanctifier.`; } }, + { + name: 'Personal XP gained from Tears of Guthix', + perkTierNeeded: PerkTier.Four, + run: async (user: MUser) => { + const result = await prisma.$queryRawUnsafe( + `SELECT skill, + SUM(xp) AS total_xp + FROM xp_gains + WHERE source = 'TearsOfGuthix' + AND user_id = ${BigInt(user.id)} + GROUP BY skill` + ); + + return `**Personal XP gained from Tears of Guthix**\n${result + .map( + (i: any) => + `${skillEmoji[i.skill as keyof typeof skillEmoji] as keyof SkillsScore} ${toKMB(i.total_xp)}` + ) + .join('\n')}`; + } + }, { name: 'Bird Eggs Offered', perkTierNeeded: null,