Skip to content

Commit

Permalink
fix: agent detection
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishqmanuja committed Jan 28, 2024
1 parent c1e0884 commit 6901156
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/api/helpers/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import type { Agent } from "../types";
* @throws Error if agent not found
*/
export function getAgent(this: ValorantApi, agentUUID: string): Agent {
const agent = this.content.agents.find(a => a.uuid === agentUUID);
const agent = this.content.agents.find(
a => a.uuid === agentUUID.toLowerCase(),
);

if (!agent) {
throw Error(`Agent ${agentUUID} not found`);
Expand Down
8 changes: 7 additions & 1 deletion src/table/plugins/player-agent.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { match } from "ts-pattern";
import { ValorantApi } from "~/api";
import { GAMESTATES, KnownGameStates } from "~/api/types";
import { AgentEntity } from "~/entities/definitions/agent.entity";
import { LOGGER } from "~/logger";
import { inject } from "~/shared/dependencies";
import { RGBTuple } from "~/utils/colors";
import { tryCatch } from "~/utils/promise";
Expand Down Expand Up @@ -38,7 +39,12 @@ export const PlayerAgentPlugin = definePlugin({
value: formatAgent({
agent: tryCatch(
() => api.helpers.getAgent(agent!.id).displayName,
() => UNKNOWN_AGENT,
() => {
LOGGER.forModule("Agent-Plugin").error(
`Agent not found, aid ${agent!.id}, puuid ${puuid}`,
);
return UNKNOWN_AGENT;
},
),
isLocked: agent!.state === "locked",
state: data._state,
Expand Down

0 comments on commit 6901156

Please sign in to comment.