From 15ee06a88e8d3153c27fed9f9e2eac13267ebc0d Mon Sep 17 00:00:00 2001 From: toast-ts <96593068+toast-ts@users.noreply.github.com> Date: Sun, 27 Aug 2023 15:56:12 +1000 Subject: [PATCH] Rename fetch, as Nodejs uses undici under the hood --- src/client.ts | 2 +- src/commands/mp.ts | 2 +- src/funcs/MPLoop.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client.ts b/src/client.ts index 8813094..56bb430 100644 --- a/src/client.ts +++ b/src/client.ts @@ -178,7 +178,7 @@ export default class TClient extends Client { let Data:any; try { - await fetch(`https://www.youtube.com/feeds/videos.xml?channel_id=${YTChannelID}`, {signal: AbortSignal.timeout(6000),headers:{'User-Agent':`Daggerbot - Notification/fetch`}}).then(async xml=>Data = this.xjs.xml2js(await xml.text(), {compact: true})) + await fetch(`https://www.youtube.com/feeds/videos.xml?channel_id=${YTChannelID}`, {signal: AbortSignal.timeout(6000),headers:{'User-Agent':`Daggerbot - Notification/undici`}}).then(async xml=>Data = this.xjs.xml2js(await xml.text(), {compact: true})) } catch(err){ console.log(this.logTime(), `${YTChannelName} YT fail`) } diff --git a/src/commands/mp.ts b/src/commands/mp.ts index da11e50..7f87ade 100644 --- a/src/commands/mp.ts +++ b/src/commands/mp.ts @@ -17,7 +17,7 @@ export default { if (interaction.channelId === '468835769092669461' && !client.isStaff(interaction.member) && ['status', 'players'].includes(interaction.options.getSubcommand())) return interaction.reply('Please use <#739084625862852715> for `/mp status/players` commands to prevent clutter in this channel.').then(()=>setTimeout(()=>interaction.deleteReply(), 6000)); const database = await client.MPServer._content.findById(interaction.guildId); - const endpoint = await fetch(database[serverSelector].ip+'/feed/dedicated-server-stats.json?code='+database[serverSelector].code, {signal: AbortSignal.timeout(7500),headers:{'User-Agent':`Daggerbot - MPdata/fetch`}}).then(r=>r.json() as Promise); + const endpoint = await fetch(database[serverSelector].ip+'/feed/dedicated-server-stats.json?code='+database[serverSelector].code, {signal: AbortSignal.timeout(7500),headers:{'User-Agent':`Daggerbot - MPdata/undici`}}).then(r=>r.json() as Promise); const embed = new client.embed(); ({ players: async()=>{ diff --git a/src/funcs/MPLoop.ts b/src/funcs/MPLoop.ts index 2277882..91a6428 100644 --- a/src/funcs/MPLoop.ts +++ b/src/funcs/MPLoop.ts @@ -19,7 +19,7 @@ export default async(client:TClient, Channel:string, Message:string, Server:TSer } const HITALL = async()=>{ - let sessionInit = {signal: AbortSignal.timeout(7500),headers:{'User-Agent':`Daggerbot - HITALL/fetch`}}; + let sessionInit = {signal: AbortSignal.timeout(7500),headers:{'User-Agent':`Daggerbot - HITALL/undici`}}; try { const hitDSS = await fetch(Server.ip+'/feed/dedicated-server-stats.json?code='+Server.code, sessionInit).then(r=>r.json() as Promise); const hitCSG = await fetch(Server.ip+'/feed/dedicated-server-savegame.html?code='+Server.code+'&file=careerSavegame', sessionInit).then(async r=>(client.xjs.xml2js(await r.text(), {compact: true}) as any).careerSavegame as FSCareerSavegame);