diff --git a/app/services/gamebridge/payloads/ErrorPayload.ts b/app/services/gamebridge/payloads/ErrorPayload.ts index de7b8702..6d4e8cea 100644 --- a/app/services/gamebridge/payloads/ErrorPayload.ts +++ b/app/services/gamebridge/payloads/ErrorPayload.ts @@ -3,7 +3,7 @@ import * as responseSchema from "./structures/ErrorResponse.json"; import { APIEmbed } from "discord.js"; import { ErrorRequest, ErrorResponse } from "./structures"; import { GameServer } from ".."; -import { getOrFetchLuaFile } from "@/utils"; +import { getOrFetchGmodFile } from "@/utils"; import Payload from "./Payload"; import dayjs from "dayjs"; @@ -27,9 +27,8 @@ export default class ErrorPayload extends Payload { const lines = hook_error.errormsg.split(/\r?\n/); const err = lines[0]; const path = err.split(":")[0]; - const linenr = err.split(":")[1]; const stack = lines.splice(2).map((l, i) => `${i + 1}. ${l}`); - const file = await getOrFetchLuaFile(path, Number(linenr)); + const file = await getOrFetchGmodFile(path); const embeds: APIEmbed[] = []; const embed = { title: hook_error.name, diff --git a/app/services/webapp/api/gmod-error-handler.ts b/app/services/webapp/api/gmod-error-handler.ts index 6e25a0f1..664e49be 100644 --- a/app/services/webapp/api/gmod-error-handler.ts +++ b/app/services/webapp/api/gmod-error-handler.ts @@ -1,4 +1,4 @@ -import { AddonURIS, getOrFetchLuaFile } from "@/utils"; +import { AddonURIS, getOrFetchGmodFile } from "@/utils"; import { GameBridge, GameServer, Player } from "../../gamebridge"; import { WebApp } from ".."; import Discord from "discord.js"; @@ -29,19 +29,20 @@ type StackMatchGroups = { ext?: string; filename?: string; fn: string; - lino: string; + fpath?: string; + lineno: string; nick?: string; partialsteamid?: string; path?: string; - runnables?: string; rfilename?: string; + runnables?: string; stacknr: string; steamid: string; steamnick?: string; }; const megaRex = - /(?\d+)\. (?\S+) - (?RunString|LuaCmd|LUACMD)?(\[(?STEAM_\d:\d:\d+)\](?.+))?(<(?\d:\d:\d+)\|(?.+?)>)?(<(?[^:]+)>)?(<(?.+):(?.+)>)?(?\[C\])?(?(?:lua|gamemodes)\/(?[-_.A-Za-z0-9]+?)(?:\/.*)?\/(?[-_.A-Za-z0-9]+)\.(?lua))?:(?-?\d+)/g; + /(?\d+)\. (?\S+) - (?RunString|LuaCmd|LUACMD)?(\[(?STEAM_\d:\d:\d+)\](?.+))?(<(?\d:\d:\d+)\|(?.+?)>)?(<(?[^:]+)>)?(<(?.+):(?.+)>)?(?\[C\])?(?(?(?:lua|gamemodes)\/(?[-_.A-Za-z0-9]+?)(?:\/.*)?\/(?[-_.A-Za-z0-9]+)\.(?lua)):-?(?\d+))?/g; const SuperReplacer = (_: string, ...args: any[]) => { const groups = args.at(-1) as StackMatchGroups; @@ -69,10 +70,10 @@ const SuperReplacer = (_: string, ...args: any[]) => { ? "mta_gamemode" : groups.addon ] - ? `[${groups.path}](${AddonURIS[groups.addon] + groups.path}#L${groups.lino})` + ? `[${groups.path}](${AddonURIS[groups.addon] + groups.path}#L${groups.lineno})` : groups.path : groups.engine - }:${groups.lino}`; + }:${groups.lineno}`; }; const gamemodes = ["sandbox_modded", "mta", "jazztronauts"]; //proper gamemode support when??? @@ -235,8 +236,8 @@ export default (webApp: WebApp): void => { ); if (filematch.length > 0) { const smg = filematch[0].groups as StackMatchGroups; - if (!smg.path) return; - await getOrFetchLuaFile(smg.path, Number(smg.lino), smg.addon).then(res => { + if (!smg.fpath) return; + await getOrFetchGmodFile(smg.fpath).then(res => { if (res && smg.filename) { payload.files = [ {