syqu22 / discord-bot-wow-helper

Discord bot for World of Warcraft
MIT License
0 stars 0 forks source link

Failure when npm run start #2

Closed vipii closed 2 years ago

vipii commented 2 years ago

I am getting these messages back while doing npm run test:

` FAIL tests/logs.test.js ● Console

console.error
  { status: 401, error: 'Invalid key specified.' }

  16 |     })
  17 |     .catch((err) => {
> 18 |       console.error(err.response.data);
     |               ^
  19 |     });
  20 | };
  21 |

  at api/logs.js:18:15
  at fetchLogs (api/logs.js:7:10)
  at Object.<anonymous>.exports.logsInfo (api/logs.js:113:16)

● logsInfo should return promise with correct logs data

TypeError: Cannot read property 'fights' of undefined

  112 | exports.logsInfo = async (code) => {
  113 |   const logs = await fetchLogs(code);
> 114 |   const fights = fightDetail(logs.fights);
      |                                   ^
  115 |
  116 |   return {
  117 |     title: logs.title,

  at Object.<anonymous>.exports.logsInfo (api/logs.js:114:35)`
vipii commented 2 years ago

Also noticed that the V1 API from warcraft logs is deprecated. Will there be an update to V2?

On Npm start I am getting this:

`Updating realms data... Realms data successfully updated.

discord-bot-wow-helper@2.0.0 commands /data/bots/wowhelper node util/deploy-commands.js

/data/bots/wowhelper/node_modules/@discordjs/rest/dist/index.js:7 )),P){let $=!u(this,d);$&&(b(this,d,new J.AsyncQueue),u(this,d).wait(),u(this,k).shift()),u(this,v)?.resolve(),b(this,v,null),await(0,W.setTimeout)(P,void 0,{ref:!1});let A,he=new Promise(Re=>A=Re);b(this,v,{promise:he,resolve:A}),$&&(await u(this,k).wait(),b(this,S,!0))}return this.runRequest(e,t,s,n,r)}else if(o.status>=500&&o.status<600){if(r!==this.manager.options.retries)return this.runRequest(e,t,s,n,++r);throw new K(o.statusText,o.constructor.name,o.status,a,t,n)}else{if(o.status>=400&&o.status<500){o.status===401&&this.manager.setToken(null);let c=await F(o);throw new w(c,c.code,o.status,a,t,n)}return null}}};k=new WeakMap,d=new WeakMap,v=new WeakMap,S=new WeakMap;var de=null,p;(function(r){r.Delete="delete",r.Get="get",r.Patch="patch",r.Post="post",r.Put="put"})(p||(p={}));var O,Q=class extends me.EventEmitter{constructor(e){super();l(this,"globalRemaining");l(this,"globalDelay",null);l(this,"globalReset",-1);l(this,"hashes",new V.default);l(this,"handlers",new V.default);D(this,O,null);l(this,"options");this.options={...q,...e},this.options.offset=Math.max(0,this.options.offset),this.globalRemaining=this.options.globalRequestsPerSecond}setToken(e){return b(this,O,e),this}async queueRequest(e){let t=Q.generateRouteData(e.fullRoute,e.method),s=this.hashes.get(${e.method}:${t.bucketRoute})??Global(${e.method}:${t.bucketRoute}),n=this.handlers.get(${s}:${t.majorParameter})??this.createHandler(s,t.majorParameter),{url:r,fetchOptions:a}=this.resolveRequest(e);return n.queueRequest(t,r,a,{body:e.body,attachments:e.attachments})}createHandler(e,t){let s=new Z(this,e,t);return this.handlers.set(s.id,s),s}resolveRequest(e){let{options:t}=this;de??=new ce.Agent({...t.agent,keepAlive:!0});let s="";e.query&&(s=?${e.query.toString()});let n={...this.options.headers,"User-Agent":${H} ${t.userAgentAppendix}.trim()};if(e.auth!==!1){if(!u(this,O))throw new Error("Expected token to be set for this request, but none was present");n.Authorization=${e.authPrefix??"Bot"} ${u(this,O)}}e.reason?.length&&(n["X-Audit-Log-Reason"]=encodeURIComponent(e.reason));let r=${t.api}${e.versioned===!1?"":/v${t.version}}${e.fullRoute}${s},a,g={};if(e.attachments?.length){let o=new le.default;for(let[f,E]of e.attachments.entries())o.append(E.key??files[${f}]`,E.rawBuffer,E.fileName);if(e.body!=null)if(e.appendToFormData)for(let[f,E]of Object.entries(e.body))o.append(f,E);else o.append("payloadjson",JSON.stringify(e.body));a=o,g=o.getHeaders()}else e.body!=null&&(a=JSON.stringify(e.body),g={"Content-Type":"application/json"});let x={agent:de,body:a,headers:{...e.headers??{},...g,...n},method:e.method};return{url:r,fetchOptions:x}}static generateRouteData(e,t){let n=/^\/(?:channels|guilds|webhooks)\/(\d{16,19})/.exec(e)?.[1]??"global",r=e.replace(/\d{16,19}/g,":id").replace(/\/reactions\/(.)/,"/reactions/:reaction"),a="";if(t===p.Delete&&r==="/channels/:id/messages/:id"){let g=/\d{16,19}$/.exec(e)[0],x=ue.DiscordSnowflake.deconstruct(g);Date.now()-Number(x.timestamp)>1e3606024*14&&(a+="/Delete Old Message")}return{majorParameter:n,bucketRoute:r+a,original:e}}},=Q;O=new WeakMap;var ge=R(require("events"));var pe=class extends ge.EventEmitter{constructor(e={}){super();l(this,"cdn");l(this,"requestManager");this.cdn=new B(e.cdn??q.cdn),this.requestManager=new _(e).on(m.Debug,this.emit.bind(this,m.Debug)).on(m.RateLimited,this.emit.bind(this,m.RateLimited)).on(m.InvalidRequestWarning,this.emit.bind(this,m.InvalidRequestWarning)),this.on("newListener",(t,s)=>{(t===m.Request||t===m.Response)&&this.requestManager.on(t,s)}),this.on("removeListener",(t,s)=>{(t===m.Request||t===m.Response)&&this.requestManager.off(t,s)})}setToken(e){return this.requestManager.setToken(e),this}get(e,t={}){return this.request({...t,fullRoute:e,method:p.Get})}delete(e,t={}){return this.request({...t,fullRoute:e,method:p.Delete})}post(e,t={}){return this.request({...t,fullRoute:e,method:p.Post})}put(e,t={}){return this.request({...t,fullRoute:e,method:p.Put})}patch(e,t={}){return this.request({...t,fullRoute:e,method:p.Patch})}request(e){return this.requestManager.queueRequest(e)}};0&&(module.exports={ALLOWED_EXTENSIONS,ALLOWED_SIZES,ALLOWED_STICKER_EXTENSIONS,CDN,DefaultRestOptions,DefaultUserAgent,DiscordAPIError,HTTPError,REST,RESTEvents,RateLimitError,RequestManager,RequestMethod});

SyntaxError: Unexpected token '??=' at wrapSafe (internal/modules/cjs/loader.js:1001:16) at Module._compile (internal/modules/cjs/loader.js:1049:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at Module.require (internal/modules/cjs/loader.js:974:19) at require (internal/modules/cjs/helpers.js:101:18) at Object. (/data/bots/wowhelper/util/deploy-commands.js:3:18) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! discord-bot-wow-helper@2.0.0 commands: node util/deploy-commands.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the discord-bot-wow-helper@2.0.0 commands script.`

vipii commented 2 years ago

V1 is back online from warcraftlogs and reports are going through, would suggest to update to V2 asap. But still same error message when doing npm start. =/

vipii commented 2 years ago

Nevermind... Found it, seems to be node was running on V14... Ugh, late nights.. sorry :-) #close