Skip to content

Commit

Permalink
Merge branch 'oldschoolgg:master' into Farming-Button
Browse files Browse the repository at this point in the history
  • Loading branch information
I-am-TURBO authored Feb 7, 2024
2 parents e3c46d6 + 1c328cf commit ff99124
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 14 deletions.
7 changes: 7 additions & 0 deletions src/lib/util/smallUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
20 changes: 11 additions & 9 deletions src/mahoji/commands/drop.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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}.`);
}
};
10 changes: 6 additions & 4 deletions src/mahoji/commands/sell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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)`
}.`
);
}
};
24 changes: 23 additions & 1 deletion src/mahoji/lib/abstracted_commands/statCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ 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';

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';
Expand Down Expand Up @@ -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<any>(
`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,
Expand Down

0 comments on commit ff99124

Please sign in to comment.