Skip to content

Commit

Permalink
Add Varlamore metrics (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
psikoi authored Mar 20, 2024
1 parent 8a48cc4 commit 3fc3f9d
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
],
"rules": {
"prettier/prettier": 2,
"@typescript-eslint/explicit-module-boundary-types": "off"
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-non-null-assertion": "off"
}
}
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wise-old-man-bot",
"version": "1.4.3",
"version": "1.4.4",
"description": "A Discord bot for the Wise Old Man projects (https://github.com/wise-old-man/wise-old-man/)",
"author": "Psikoi",
"license": "ISC",
Expand Down Expand Up @@ -46,7 +46,7 @@
"@sapphire/discord.js-utilities": "^7.1.6",
"@sentry/node": "^7.28.0",
"@sentry/tracing": "^7.28.0",
"@wise-old-man/utils": "^3.1.13",
"@wise-old-man/utils": "^3.2.1",
"canvas": "^2.6.1",
"cors": "^2.8.5",
"discord.js": "^14.14.1",
Expand Down
Binary file added public/x2/colosseum_glory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/x2/lunar_chests.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/x2/sol_heredit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/commands/instances/moderation/NameChangeCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ function buildReviewMessage(data: NonNullable<NameChangeDetails['data']>): strin
const { isNewOnHiscores, hasNegativeGains, hoursDiff, ehpDiff, ehbDiff, oldStats, newStats } = data;

const expDiff =
newStats.data.skills.overall && oldStats.data.skills.overall
newStats?.data.skills.overall && oldStats.data.skills.overall
? newStats.data.skills.overall.experience - oldStats.data.skills.overall.experience
: 0;

const oldTotalLevel = oldStats.data.skills.overall?.level;
const newTotalLevel = newStats.data.skills.overall?.level;
const newTotalLevel = newStats?.data.skills.overall?.level;

const lines: Array<string> = [];

Expand Down
9 changes: 8 additions & 1 deletion src/commands/instances/player/PlayerActivitiesCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ class PlayerActivitiesCommand extends Command {
);
});

if (!player.latestSnapshot) {
throw new CommandError(
`Could not find this player's stats.`,
'Tip: Try tracking them again using the /update command'
);
}

const { attachment, fileName } = await this.render(player, variant);

const embed = new EmbedBuilder()
Expand All @@ -82,7 +89,7 @@ class PlayerActivitiesCommand extends Command {

async render(playerDetails: PlayerDetails, variant: RenderVariant) {
const username = playerDetails.username;
const activities = playerDetails.latestSnapshot.data.activities;
const activities = playerDetails.latestSnapshot!.data.activities;

// Create a scaled empty canvas
const { canvas, ctx, width, height } = getScaledCanvas(RENDER_WIDTH, RENDER_HEIGHT);
Expand Down
15 changes: 11 additions & 4 deletions src/commands/instances/player/PlayerBossesCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '../../../utils';

const RENDER_WIDTH = 415;
const RENDER_HEIGHT = 325;
const RENDER_HEIGHT = 350;
const RENDER_PADDING = 15;

enum RenderVariant {
Expand Down Expand Up @@ -69,6 +69,13 @@ class PlayerBossesCommand extends Command {
);
});

if (!player.latestSnapshot) {
throw new CommandError(
`Could not find this player's stats.`,
'Tip: Try tracking them again using the /update command'
);
}

const { attachment, fileName } = await this.render(player, variant);

const embed = new EmbedBuilder()
Expand All @@ -84,7 +91,7 @@ class PlayerBossesCommand extends Command {

async render(playerDetails: PlayerDetails, variant: RenderVariant) {
const username = playerDetails.username;
const { bosses, computed } = playerDetails.latestSnapshot.data;
const { bosses, computed } = playerDetails.latestSnapshot!.data;

// Create a scaled empty canvas
const { canvas, ctx, width, height } = getScaledCanvas(RENDER_WIDTH, RENDER_HEIGHT);
Expand All @@ -103,8 +110,8 @@ class PlayerBossesCommand extends Command {
rank: number,
ehb?: number
) {
const x = Math.floor(index / 10);
const y = index % 10;
const x = Math.floor(index / 11);
const y = index % 11;

const originX = RENDER_PADDING - 7 + x * 67;
const originY = RENDER_PADDING - 5 + y * 31;
Expand Down
9 changes: 8 additions & 1 deletion src/commands/instances/player/PlayerStatsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ class PlayerStatsCommand extends Command {
);
});

if (!player.latestSnapshot) {
throw new CommandError(
`Could not find this player's stats.`,
'Tip: Try tracking them again using the /update command'
);
}

const { attachment, fileName } = await this.render(player, variant);

const embed = new EmbedBuilder()
Expand All @@ -114,7 +121,7 @@ class PlayerStatsCommand extends Command {

async render(playerDetails: PlayerDetails, variant: RenderVariant) {
const username = playerDetails.username;
const skills = playerDetails.latestSnapshot.data.skills;
const skills = playerDetails.latestSnapshot!.data.skills;

// Create a scaled empty canvas
const { canvas, ctx, width, height } = getScaledCanvas(RENDER_WIDTH, RENDER_HEIGHT);
Expand Down
3 changes: 3 additions & 0 deletions src/utils/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const MetricEmoji = {
[Metric.KRAKEN]: '<:kraken:729840084798406767>',
[Metric.KREEARRA]: '<:kreearra:729840085033287680>',
[Metric.KRIL_TSUTSAROTH]: '<:kril_tsutsaroth:729840084781760574>',
[Metric.LUNAR_CHESTS]: '<:lunar_chests:1220023608383115275>',
[Metric.MIMIC]: '<:mimic:730169728357761145>',
[Metric.NEX]: '<:nex:927846096611475466>',
[Metric.NIGHTMARE]: '<:nightmare:729840084844675103>',
Expand All @@ -84,6 +85,7 @@ const MetricEmoji = {
[Metric.SCORPIA]: '<:scorpia:729840084962115666>',
[Metric.SCURRIUS]: '<:scurrius:1199712038193217606>',
[Metric.SKOTIZO]: '<:skotizo:729840085398454273>',
[Metric.SOL_HEREDIT]: '<:sol_heredit:1220023750339334154>',
[Metric.SPINDEL]: '<:venenatis:729840086795157595>',
[Metric.TEMPOROSS]: '<:tempoross:823292463456059452>',
[Metric.THE_GAUNTLET]: '<:the_gauntlet:729840085473820805>',
Expand Down Expand Up @@ -113,6 +115,7 @@ const MetricEmoji = {
[Metric.CLUE_SCROLLS_ALL]: '<:clue_scrolls_all:729844134004785204>',
[Metric.SOUL_WARS_ZEAL]: '<:soul_wars_zeal:1011956473615630396>',
[Metric.GUARDIANS_OF_THE_RIFT]: '<:guardians_of_the_rift:963939589070934046>',
[Metric.COLOSSEUM_GLORY]: '<:colosseum_glory:1220023685881139312>',
// Computed metric emojis
[Metric.EHP]: '<:ehp:766260738221670432>',
[Metric.EHB]: '<:ehb:766260773617795103>'
Expand Down

0 comments on commit 3fc3f9d

Please sign in to comment.