museofficial / muse

🎧 a self-hosted midwestern Discord music bot that doesn't suck
MIT License
882 stars 231 forks source link

Discord Bot Token Reset Due to Potential Abuse #505

Closed LoopsFroot closed 2 years ago

LoopsFroot commented 2 years ago

Yesterday night I got a mail that my Discord Bot Token got reset. My bot had connected over a 1000 times in a short period.

That evening I had problems with my internet, maybe that the problem? But a 1000 times seems a little much.

Anyone else having/ had this problem?

codetheweb commented 2 years ago

Hmm, could you post some of the logs from your bot? It's likely that it's repeatedly crashing and restarting.

Makifun commented 2 years ago

I also got the same issue after the latest update, here is what my logs says.

I reverted back to 0.5.4 and it started working again.

> yarn run v1.22.15
> $ npm run env:set-database-url -- node --experimental-json-modules dist/src/scripts/migrate-and-start.js
> 
> > muse@1.0.0 env:set-database-url
> > node dist/src/scripts/run-with-database-url.js "node" "--experimental-json-modules" "dist/src/scripts/migrate-and-start.js"
> 
> (node:52) ExperimentalWarning: Importing JSON modules is an experimental feature. This feature could change at any time
> (Use `node --trace-warnings ...` to show where the warning was created)
> ========================================
> ========================================
> ================= muse =================
> ========================================
> =========== Made with 🎶 by ============
> ==== https://github.com/codetheweb =====
> ========================================
> ========================================
> 
> Running version 1.0.0 built on Invalid Date (commit unknown)
> 
> 🔧 Need help? https://github.com/codetheweb/muse/discussions/new
> 🐛 Bug? https://github.com/codetheweb/muse/issues/new
> ✨ New feature? https://github.com/codetheweb/muse/issues/new
> ☕ Discussion? https://github.com/codetheweb/muse/discussions/new
> 💰 Help me? https://www.paypal.me/codetheweb https://github.com/sponsors/codetheweb
> 
> 
> - Applying database migrations...
> ✔ Database migrations applied.
> - 📡 connecting to Discord...
> file:///usr/app/node_modules/@discordjs/rest/dist/index.mjs:7
> `)),q){let S=!u(this,c);S&&(g(this,c,new se),u(this,c).wait(),u(this,w).shift()),u(this,b)?.resolve(),g(this,b,null),await W(q,void 0,{ref:!1});let O,ie=new Promise(re=>O=re);g(this,b,{promise:ie,resolve:                                                                                   O}),S&&(await u(this,w).wait(),g(this,k,!0))}return this.runRequest(e,t,s,i,r)}else if(o.status>=500&&o.status<600){if(r!==this.manager.options.retries)return this.runRequest(e,t,s,i,++r);throw new B(o.st                                                                                   atusText,o.constructor.name,o.status,a,t,i)}else{if(o.status>=400&&o.status<500){o.status===401&&this.manager.setToken(null);let p=await M(o);throw new D(p,"code"in p?p.code:p.error,o.status,a,t,i)}return                                                                                    null}}};w=new WeakMap,c=new WeakMap,b=new WeakMap,k=new WeakMap;var K=(r=>(r.Delete="delete",r.Get="get",r.Patch="patch",r.Post="post",r.Put="put",r))(K||{}),I,G=class extends ge{constructor(e){super();l                                                                                   (this,"globalRemaining");l(this,"globalDelay",null);l(this,"globalReset",-1);l(this,"hashes",new U);l(this,"handlers",new U);L(this,I,null);l(this,"hashTimer");l(this,"handlerTimer");l(this,"agent",null);                                                                                   l(this,"options");this.options={...x,...e},this.options.offset=Math.max(0,this.options.offset),this.globalRemaining=this.options.globalRequestsPerSecond,this.setupSweepers()}setupSweepers(){let e=t=>{if(t                                                                                   >144e5)throw new Error("Cannot set an interval greater than 4 hours")};this.options.hashSweepInterval!==0&&this.options.hashSweepInterval!==1/0&&(e(this.options.hashSweepInterval),this.hashTimer=setInterv                                                                                   al(()=>{let t=new U,s=Date.now();this.hashes.sweep((i,r)=>{if(i.lastAccess===-1)return!1;let a=Math.floor(s-i.lastAccess)>this.options.hashLifetime;return a&&t.set(r,i),this.emit("restDebug",`Hash ${i.val                                                                                   ue} for ${r} swept due to lifetime being exceeded`),a}),this.emit("hashSweep",t)},this.options.hashSweepInterval).unref()),this.options.handlerSweepInterval!==0&&this.options.handlerSweepInterval!==1/0&&(                                                                                   e(this.options.handlerSweepInterval),this.handlerTimer=setInterval(()=>{let t=new U;this.handlers.sweep((s,i)=>{let{inactive:r}=s;return r&&t.set(i,s),this.emit("restDebug",`Handler ${s.id} for ${i} swept                                                                                    due to being inactive`),r}),this.emit("handlerSweep",t)},this.options.handlerSweepInterval).unref())}setToken(e){return g(this,I,e),this}async queueRequest(e){let t=G.generateRouteData(e.fullRoute,e.meth                                                                                   od),s=this.hashes.get(`${e.method}:${t.bucketRoute}`)??{value:`Global(${e.method}:${t.bucketRoute})`,lastAccess:-1},i=this.handlers.get(`${s.value}:${t.majorParameter}`)??this.createHandler(s.value,t.majo                                                                                   rParameter),{url:r,fetchOptions:a}=this.resolveRequest(e);return i.queueRequest(t,r,a,{body:e.body,files:e.files})}createHandler(e,t){let s=new C(this,e,t);return this.handlers.set(s.id,s),s}resolveReques                                                                                   t(e){let{options:t}=this;this.agent??=t.api.startsWith("https")?new fe({...t.agent,keepAlive:!0}):new Re({...t.agent,keepAlive:!0});let s="";if(e.query){let o=e.query.toString();o!==""&&(s=`?${o}`)}let i=                                                                                   {...this.options.headers,"User-Agent":`${Y} ${t.userAgentAppendix}`.trim()};if(e.auth!==!1){if(!u(this,I))throw new Error("Expected token to be set for this request, but none was present");i.Authorization                                                                                   =`${e.authPrefix??"Bot"} ${u(this,I)}`}e.reason?.length&&(i["X-Audit-Log-Reason"]=encodeURIComponent(e.reason));let r=`${t.api}${e.versioned===!1?"":`/v${t.version}`}${e.fullRoute}${s}`,a,m={};if(e.files?                                                                                   .length){let o=new he;for(let[d,y]of e.files.entries())o.append(y.key??`files[${d}]`,y.fileData,y.fileName);if(e.body!=null)if(e.appendToFormData)for(let[d,y]of Object.entries(e.body))o.append(d,y);else o                                                                                   .append("payload_json",JSON.stringify(e.body));a=o,m=o.getHeaders()}else e.body!=null&&(e.passThroughBody?a=e.body:(a=JSON.stringify(e.body),m={"Content-Type":"application/json"}));let E={agent:this.agent                                                                                   ,body:a,headers:{...e.headers??{},...m,...i},method:e.method};return{url:r,fetchOptions:E}}clearHashSweeper(){clearInterval(this.hashTimer)}clearHandlerSweeper(){clearInterval(this.handlerTimer)}static ge                                                                                   nerateRouteData(e,t){let i=/^\/(?: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==="delete"&&r                                                                                   ==="/channels/:id/messages/:id"){let m=/\d{16,19}$/.exec(e)[0],E=de.deconstruct(m);Date.now()-Number(E.timestamp)>1e3*60*60*24*14&&(a+="/Delete Old Message")}return{majorParameter:i,bucketRoute:r+a,origin                                                                                   al:e}}},F=G;I=new WeakMap;import{EventEmitter as be}from"node:events";var ye=class extends be{constructor(e={}){super();l(this,"cdn");l(this,"requestManager");this.cdn=new N(e.cdn??x.cdn),this.requestMana                                                                                   ger=new F(e).on("restDebug",this.emit.bind(this,"restDebug")).on("rateLimited",this.emit.bind(this,"rateLimited")).on("invalidRequestWarning",this.emit.bind(this,"invalidRequestWarning")).on("hashSweep",t                                                                                   his.emit.bind(this,"hashSweep")),this.on("newListener",(t,s)=>{(t==="request"||t==="response")&&this.requestManager.on(t,s)}),this.on("removeListener",(t,s)=>{(t==="request"||t==="response")&&this.request                                                                                   Manager.off(t,s)})}setToken(e){return this.requestManager.setToken(e),this}get(e,t={}){return this.request({...t,fullRoute:e,method:"get"})}delete(e,t={}){return this.request({...t,fullRoute:e,method:"del                                                                                   ete"})}post(e,t={}){return this.request({...t,fullRoute:e,method:"post"})}put(e,t={}){return this.request({...t,fullRoute:e,method:"put"})}patch(e,t={}){return this.request({...t,fullRoute:e,method:"patch                                                                                   "})}request(e){return this.requestManager.queueRequest(e)}};export{ee as ALLOWED_EXTENSIONS,_ as ALLOWED_SIZES,te as ALLOWED_STICKER_EXTENSIONS,N as CDN,x as DefaultRestOptions,Y as DefaultUserAgent,D as                                                                                    DiscordAPIError,B as HTTPError,ye as REST,j as RESTEvents,A as RateLimitError,F as RequestManager,K as RequestMethod};
>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ^
> 
> D[50001]: Missing Access
>     at C.runRequest (file:///usr/app/node_modules/@discordjs/rest/dist/index.mjs:7:557)
>     at processTicksAndRejections (node:internal/process/task_queues:96:5)
>     at async C.queueRequest (file:///usr/app/node_modules/@discordjs/rest/dist/index.mjs:5:3022)
>     at async file:///usr/app/dist/src/bot.js:126:25
>     at async Promise.all (index 0)
>     at async Client.<anonymous> (file:///usr/app/dist/src/bot.js:124:17) {
>   rawError: { message: 'Missing Access', code: 50001 },
>   code: 50001,
>   status: 403,
>   method: 'put',
>   url: 'https://discord.com/api/v9/applications/-snip-',
>   requestBody: {
>     files: undefined,
>     json: [
>       {
>         name: 'clear',
>         description: 'clears all songs in queue except currently playing song',
>         options: [],
>         default_permission: undefined
>       },
>       {
>         name: 'config',
>         description: 'configure bot settings',
>         options: [
>           {
>             type: 1,
>             name: 'set-playlist-limit',
>             description: 'set the maximum number of tracks that can be added from a playlist',
>             options: [Array]
>           },
>           {
>             type: 1,
>             name: 'set-role',
>             description: 'set the role that is allowed to use the bot',
>             options: [Array]
>           },
>           {
>             type: 1,
>             name: 'get',
>             description: 'show all settings',
>             options: []
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'disconnect',
>         description: 'pause and disconnect Muse',
>         options: [],
>         default_permission: undefined
>       },
>       {
>         name: 'favorites',
>         description: 'add a song to your favorites',
>         options: [
>           {
>             type: 1,
>             name: 'use',
>             description: 'use a favorite',
>             options: [Array]
>           },
>           {
>             type: 1,
>             name: 'list',
>             description: 'list all favorites',
>             options: []
>           },
>           {
>             type: 1,
>             name: 'create',
>             description: 'create a new favorite',
>             options: [Array]
>           },
>           {
>             type: 1,
>             name: 'remove',
>             description: 'remove a favorite',
>             options: [Array]
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'fseek',
>         description: 'seek forward in the current song',
>         options: [
>           {
>             max_value: undefined,
>             min_value: undefined,
>             choices: undefined,
>             autocomplete: undefined,
>             type: 10,
>             name: 'seconds',
>             description: 'the number of seconds to skip forward',
>             required: true
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'pause',
>         description: 'pause the current song',
>         options: [],
>         default_permission: undefined
>       },
>       {
>         name: 'play',
>         description: 'play a song or resume playback',
>         options: [
>           {
>             choices: undefined,
>             autocomplete: true,
>             type: 3,
>             name: 'query',
>             description: 'YouTube URL, Spotify URL, or search query',
>             required: false
>           },
>           {
>             name: 'immediate',
>             description: 'add track to the front of the queue',
>             required: false,
>             type: 5
>           },
>           {
>             name: 'shuffle',
>             description: "shuffle the input if you're adding multiple tracks",
>             required: false,
>             type: 5
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'queue',
>         description: 'show the current queue',
>         options: [
>           {
>             max_value: undefined,
>             min_value: undefined,
>             choices: undefined,
>             autocomplete: undefined,
>             type: 4,
>             name: 'page',
>             description: 'page of queue to show [default: 1]',
>             required: false
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'remove',
>         description: 'remove songs from the queue',
>         options: [
>           {
>             max_value: undefined,
>             min_value: undefined,
>             choices: undefined,
>             autocomplete: undefined,
>             type: 4,
>             name: 'position',
>             description: 'position of the song to remove [default: 1]',
>             required: false
>           },
>           {
>             max_value: undefined,
>             min_value: undefined,
>             choices: undefined,
>             autocomplete: undefined,
>             type: 4,
>             name: 'range',
>             description: 'number of songs to remove [default: 1]',
>             required: false
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'seek',
>         description: 'seek to a position from beginning of song',
>         options: [
>           {
>             choices: undefined,
>             autocomplete: undefined,
>             type: 3,
>             name: 'time',
>             description: 'time to seek',
>             required: true
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'shuffle',
>         description: 'shuffle the current queue',
>         options: [],
>         default_permission: undefined
>       },
>       {
>         name: 'skip',
>         description: 'skip the next songs',
>         options: [
>           {
>             max_value: undefined,
>             min_value: undefined,
>             choices: undefined,
>             autocomplete: undefined,
>             type: 4,
>             name: 'number',
>             description: 'number of songs to skip [default: 1]',
>             required: false
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'unskip',
>         description: 'go back in the queue by one song',
>         options: [],
>         default_permission: undefined
>       }
>     ]
>   }
> }
> file:///usr/app/node_modules/execa/lib/error.js:59
>                 error = new Error(message);
>                         ^
> 
> Error: Command failed with exit code 1: node --experimental-json-modules dist/src/scripts/migrate-and-start.js
>     at makeError (file:///usr/app/node_modules/execa/lib/error.js:59:11)
>     at handlePromise (file:///usr/app/node_modules/execa/index.js:119:26)
>     at processTicksAndRejections (node:internal/process/task_queues:96:5)
>     at async file:///usr/app/dist/src/scripts/run-with-database-url.js:5:5 {
>   shortMessage: 'Command failed with exit code 1: node --experimental-json-modules dist/src/scripts/migrate-and-start.js',
>   command: 'node --experimental-json-modules dist/src/scripts/migrate-and-start.js',
>   escapedCommand: 'node --experimental-json-modules "dist/src/scripts/migrate-and-start.js"',
>   exitCode: 1,
>   signal: undefined,
>   signalDescription: undefined,
>   stdout: undefined,
>   stderr: undefined,
>   failed: true,
>   timedOut: false,
>   isCanceled: false,
>   killed: false
> }
> error Command failed with exit code 1.
> info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
> yarn run v1.22.15
codetheweb commented 2 years ago

@Makifun did you kick and re-invite the bot like the release notes instruct? I'm guessing that's the source of the error.

Makifun commented 2 years ago

I did not. 1.0.0 works great now, love the slash commands! 5/7 perfect score!

mzrimsek commented 2 years ago

I am having this exact error today after updating to 1.0.0.

  1. Updated image
  2. Removed from server
  3. Removed persisted files from folder mapped in volume
  4. Refreshed discord token
  5. Recreated container
  6. Reinvited to server
>      {
>         name: 'seek',
>         description: 'seek to a position from beginning of song',
>         options: [
>           {
>             choices: undefined,
>             autocomplete: undefined,
>             type: 3,
>             name: 'time',
>             description: 'time to seek',
>             required: true
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'shuffle',
>         description: 'shuffle the current queue',
>         options: [],
>         default_permission: undefined
>       },
>       {
>         name: 'skip',
>         description: 'skip the next songs',
>         options: [
>           {
>             max_value: undefined,
>             min_value: undefined,
>             choices: undefined,
>             autocomplete: undefined,
>             type: 4,
>             name: 'number',
>             description: 'number of songs to skip [default: 1]',
>             required: false
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'unskip',
>         description: 'go back in the queue by one song',
>         options: [],
>         default_permission: undefined
>       }
>     ]
>   }
> }
> file:///usr/app/node_modules/execa/lib/error.js:59
>       error = new Error(message);
>               ^
> 
> Error: Command failed with exit code 1: node --experimental-json-modules dist/src/scripts/migrate-and-start.js
>     at makeError (file:///usr/app/node_modules/execa/lib/error.js:59:11)
>     at handlePromise (file:///usr/app/node_modules/execa/index.js:119:26)
>     at processTicksAndRejections (node:internal/process/task_queues:96:5)
>     at async file:///usr/app/dist/src/scripts/run-with-database-url.js:5:5 {
>   shortMessage: 'Command failed with exit code 1: node --experimental-json-modules dist/src/scripts/migrate-and-start.js',
>   command: 'node --experimental-json-modules dist/src/scripts/migrate-and-start.js',
>   escapedCommand: 'node --experimental-json-modules "dist/src/scripts/migrate-and-start.js"',
>   exitCode: 1,
>   signal: undefined,
>   signalDescription: undefined,
>   stdout: undefined,
>   stderr: undefined,
>   failed: true,
>   timedOut: false,
>   isCanceled: false,
>   killed: false
> }
> error Command failed with exit code 1.
> info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
> yarn run v1.22.15
> $ npm run env:set-database-url -- node --experimental-json-modules dist/src/scripts/migrate-and-start.js
> 
> > muse@1.0.0 env:set-database-url
> > node dist/src/scripts/run-with-database-url.js "node" "--experimental-json-modules" "dist/src/scripts/migrate-and-start.js"
> 
> (node:52) ExperimentalWarning: Importing JSON modules is an experimental feature. This feature could change at any time
> (Use `node --trace-warnings ...` to show where the warning was created)
> ========================================
> ========================================
> ================= muse =================
> ========================================
> =========== Made with 🎶 by ============
> ==== https://github.com/codetheweb =====
> ========================================
> ========================================
> 
> Running version 1.0.0 built on Invalid Date (commit unknown)
> 
> 🔧 Need help? https://github.com/codetheweb/muse/discussions/new
> 🐛 Bug? https://github.com/codetheweb/muse/issues/new
> ✨ New feature? https://github.com/codetheweb/muse/issues/new
> ☕ Discussion? https://github.com/codetheweb/muse/discussions/new
> 💰 Help me? https://www.paypal.me/codetheweb https://github.com/sponsors/codetheweb
> 
> 
> - Applying database migrations...
> ✔ Database migrations applied.
> - 📡 connecting to Discord...

This just prints repeatedly in the logs. Help?

codetheweb commented 2 years ago

@mzrimsek I think you're missing part of your logs.

mzrimsek commented 2 years ago
> Error: Command failed with exit code 1: node --experimental-json-modules dist/src/scripts/migrate-and-start.js
>     at makeError (file:///usr/app/node_modules/execa/lib/error.js:59:11)
>     at handlePromise (file:///usr/app/node_modules/execa/index.js:119:26)
>     at processTicksAndRejections (node:internal/process/task_queues:96:5)
>     at async file:///usr/app/dist/src/scripts/run-with-database-url.js:5:5 {
>   shortMessage: 'Command failed with exit code 1: node --experimental-json-modules dist/src/scripts/migrate-and-start.js',
>   command: 'node --experimental-json-modules dist/src/scripts/migrate-and-start.js',
>   escapedCommand: 'node --experimental-json-modules "dist/src/scripts/migrate-and-start.js"',
>   exitCode: 1,
>   signal: undefined,
>   signalDescription: undefined,
>   stdout: undefined,
>   stderr: undefined,
>   failed: true,
>   timedOut: false,
>   isCanceled: false,
>   killed: false
> }
> error Command failed with exit code 1.
> info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
> yarn run v1.22.15
> $ npm run env:set-database-url -- node --experimental-json-modules dist/src/scripts/migrate-and-start.js
> 
> > muse@1.0.0 env:set-database-url
> > node dist/src/scripts/run-with-database-url.js "node" "--experimental-json-modules" "dist/src/scripts/migrate-and-start.js"
> 
> (node:52) ExperimentalWarning: Importing JSON modules is an experimental feature. This feature could change at any time
> (Use `node --trace-warnings ...` to show where the warning was created)
> ========================================
> ========================================
> ================= muse =================
> ========================================
> =========== Made with 🎶 by ============
> ==== https://github.com/codetheweb =====
> ========================================
> ========================================
> 
> Running version 1.0.0 built on Invalid Date (commit unknown)
> 
> 🔧 Need help? https://github.com/codetheweb/muse/discussions/new
> 🐛 Bug? https://github.com/codetheweb/muse/issues/new
> ✨ New feature? https://github.com/codetheweb/muse/issues/new
> ☕ Discussion? https://github.com/codetheweb/muse/discussions/new
> 💰 Help me? https://www.paypal.me/codetheweb https://github.com/sponsors/codetheweb
> 
> 
> - Applying database migrations...
> ✔ Database migrations applied.
> - 📡 connecting to Discord...
> file:///usr/app/node_modules/@discordjs/rest/dist/index.mjs:7
> `)),q){let S=!u(this,c);S&&(g(this,c,new se),u(this,c).wait(),u(this,w).shift()),u(this,b)?.resolve(),g(this,b,null),await W(q,void 0,{ref:!1});let O,ie=new Promise(re=>O=re);g(this,b,{promise:ie,resolve:O}),S&&(await u(this,w).wait(),g(this,k,!0))}return this.runRequest(e,t,s,i,r)}else if(o.status>=500&&o.status<600){if(r!==this.manager.options.retries)return this.runRequest(e,t,s,i,++r);throw new B(o.statusText,o.constructor.name,o.status,a,t,i)}else{if(o.status>=400&&o.status<500){o.status===401&&this.manager.setToken(null);let p=await M(o);throw new D(p,"code"in p?p.code:p.error,o.status,a,t,i)}return null}}};w=new WeakMap,c=new WeakMap,b=new WeakMap,k=new WeakMap;var K=(r=>(r.Delete="delete",r.Get="get",r.Patch="patch",r.Post="post",r.Put="put",r))(K||{}),I,G=class extends ge{constructor(e){super();l(this,"globalRemaining");l(this,"globalDelay",null);l(this,"globalReset",-1);l(this,"hashes",new U);l(this,"handlers",new U);L(this,I,null);l(this,"hashTimer");l(this,"handlerTimer");l(this,"agent",null);l(this,"options");this.options={...x,...e},this.options.offset=Math.max(0,this.options.offset),this.globalRemaining=this.options.globalRequestsPerSecond,this.setupSweepers()}setupSweepers(){let e=t=>{if(t>144e5)throw new Error("Cannot set an interval greater than 4 hours")};this.options.hashSweepInterval!==0&&this.options.hashSweepInterval!==1/0&&(e(this.options.hashSweepInterval),this.hashTimer=setInterval(()=>{let t=new U,s=Date.now();this.hashes.sweep((i,r)=>{if(i.lastAccess===-1)return!1;let a=Math.floor(s-i.lastAccess)>this.options.hashLifetime;return a&&t.set(r,i),this.emit("restDebug",`Hash ${i.value} for ${r} swept due to lifetime being exceeded`),a}),this.emit("hashSweep",t)},this.options.hashSweepInterval).unref()),this.options.handlerSweepInterval!==0&&this.options.handlerSweepInterval!==1/0&&(e(this.options.handlerSweepInterval),this.handlerTimer=setInterval(()=>{let t=new U;this.handlers.sweep((s,i)=>{let{inactive:r}=s;return r&&t.set(i,s),this.emit("restDebug",`Handler ${s.id} for ${i} swept due to being inactive`),r}),this.emit("handlerSweep",t)},this.options.handlerSweepInterval).unref())}setToken(e){return g(this,I,e),this}async queueRequest(e){let t=G.generateRouteData(e.fullRoute,e.method),s=this.hashes.get(`${e.method}:${t.bucketRoute}`)??{value:`Global(${e.method}:${t.bucketRoute})`,lastAccess:-1},i=this.handlers.get(`${s.value}:${t.majorParameter}`)??this.createHandler(s.value,t.majorParameter),{url:r,fetchOptions:a}=this.resolveRequest(e);return i.queueRequest(t,r,a,{body:e.body,files:e.files})}createHandler(e,t){let s=new C(this,e,t);return this.handlers.set(s.id,s),s}resolveRequest(e){let{options:t}=this;this.agent??=t.api.startsWith("https")?new fe({...t.agent,keepAlive:!0}):new Re({...t.agent,keepAlive:!0});let s="";if(e.query){let o=e.query.toString();o!==""&&(s=`?${o}`)}let i={...this.options.headers,"User-Agent":`${Y} ${t.userAgentAppendix}`.trim()};if(e.auth!==!1){if(!u(this,I))throw new Error("Expected token to be set for this request, but none was present");i.Authorization=`${e.authPrefix??"Bot"} ${u(this,I)}`}e.reason?.length&&(i["X-Audit-Log-Reason"]=encodeURIComponent(e.reason));let r=`${t.api}${e.versioned===!1?"":`/v${t.version}`}${e.fullRoute}${s}`,a,m={};if(e.files?.length){let o=new he;for(let[d,y]of e.files.entries())o.append(y.key??`files[${d}]`,y.fileData,y.fileName);if(e.body!=null)if(e.appendToFormData)for(let[d,y]of Object.entries(e.body))o.append(d,y);else o.append("payload_json",JSON.stringify(e.body));a=o,m=o.getHeaders()}else e.body!=null&&(e.passThroughBody?a=e.body:(a=JSON.stringify(e.body),m={"Content-Type":"application/json"}));let E={agent:this.agent,body:a,headers:{...e.headers??{},...m,...i},method:e.method};return{url:r,fetchOptions:E}}clearHashSweeper(){clearInterval(this.hashTimer)}clearHandlerSweeper(){clearInterval(this.handlerTimer)}static generateRouteData(e,t){let i=/^\/(?: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==="delete"&&r==="/channels/:id/messages/:id"){let m=/\d{16,19}$/.exec(e)[0],E=de.deconstruct(m);Date.now()-Number(E.timestamp)>1e3*60*60*24*14&&(a+="/Delete Old Message")}return{majorParameter:i,bucketRoute:r+a,original:e}}},F=G;I=new WeakMap;import{EventEmitter as be}from"node:events";var ye=class extends be{constructor(e={}){super();l(this,"cdn");l(this,"requestManager");this.cdn=new N(e.cdn??x.cdn),this.requestManager=new F(e).on("restDebug",this.emit.bind(this,"restDebug")).on("rateLimited",this.emit.bind(this,"rateLimited")).on("invalidRequestWarning",this.emit.bind(this,"invalidRequestWarning")).on("hashSweep",this.emit.bind(this,"hashSweep")),this.on("newListener",(t,s)=>{(t==="request"||t==="response")&&this.requestManager.on(t,s)}),this.on("removeListener",(t,s)=>{(t==="request"||t==="response")&&this.requestManager.off(t,s)})}setToken(e){return this.requestManager.setToken(e),this}get(e,t={}){return this.request({...t,fullRoute:e,method:"get"})}delete(e,t={}){return this.request({...t,fullRoute:e,method:"delete"})}post(e,t={}){return this.request({...t,fullRoute:e,method:"post"})}put(e,t={}){return this.request({...t,fullRoute:e,method:"put"})}patch(e,t={}){return this.request({...t,fullRoute:e,method:"patch"})}request(e){return this.requestManager.queueRequest(e)}};export{ee as ALLOWED_EXTENSIONS,_ as ALLOWED_SIZES,te as ALLOWED_STICKER_EXTENSIONS,N as CDN,x as DefaultRestOptions,Y as DefaultUserAgent,D as DiscordAPIError,B as HTTPError,ye as REST,j as RESTEvents,A as RateLimitError,F as RequestManager,K as RequestMethod};
>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ^
> 
> D[50001]: Missing Access
>     at C.runRequest (file:///usr/app/node_modules/@discordjs/rest/dist/index.mjs:7:557)
>     at processTicksAndRejections (node:internal/process/task_queues:96:5)
>     at async C.queueRequest (file:///usr/app/node_modules/@discordjs/rest/dist/index.mjs:5:3022)
>     at async file:///usr/app/dist/src/bot.js:126:25
>     at async Promise.all (index 0)
>     at async Client.<anonymous> (file:///usr/app/dist/src/bot.js:124:17) {
>   rawError: { message: 'Missing Access', code: 50001 },
>   code: 50001,
>   status: 403,
>   method: 'put',
>   url: 'https://discord.com/api/v9/applications/894753865851875399/guilds/519983649785905164/commands',
>   requestBody: {
>     files: undefined,
>     json: [
>       {
>         name: 'clear',
>         description: 'clears all songs in queue except currently playing song',
>         options: [],
>         default_permission: undefined
>       },
>       {
>         name: 'config',
>         description: 'configure bot settings',
>         options: [
>           {
>             type: 1,
>             name: 'set-playlist-limit',
>             description: 'set the maximum number of tracks that can be added from a playlist',
>             options: [Array]
>       
>           },
>           {
>             type: 1,
>             name: 'set-role',
>             description: 'set the role that is allowed to use the bot',
>             options: [Array]
>       
>           },
>           {
>             type: 1,
>             name: 'get',
>             description: 'show all settings',
>             options: []
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'disconnect',
>         description: 'pause and disconnect Muse',
>         options: [],
>         default_permission: undefined
>       },
>       {
>         name: 'favorites',
>         description: 'add a song to your favorites',
>         options: [
>           {
>             type: 1,
>             name: 'use',
>             description: 'use a favorite',
>             options: [Array]
>       
>           },
>           {
>             type: 1,
>             name: 'list',
>             description: 'list all favorites',
>             options: []
>       
>           },
>           {
>             type: 1,
>             name: 'create',
>             description: 'create a new favorite',
>             options: [Array]
>       
>           },
>           {
>             type: 1,
>             name: 'remove',
>             description: 'remove a favorite',
>             options: [Array]
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'fseek',
>         description: 'seek forward in the current song',
>         options: [
>           {
>             max_value: undefined,
>             min_value: undefined,
>             choices: undefined,
>             autocomplete: undefined,
>             type: 10,
>             name: 'seconds',
>             description: 'the number of seconds to skip forward',
>             required: true
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'pause',
>         description: 'pause the current song',
>         options: [],
>         default_permission: undefined
>       },
>       {
>         name: 'play',
>         description: 'play a song or resume playback',
>         options: [
>           {
>             choices: undefined,
>             autocomplete: true,
>             type: 3,
>             name: 'query',
>             description: 'YouTube URL, Spotify URL, or search query',
>             required: false
>       
>           },
>           {
>             name: 'immediate',
>             description: 'add track to the front of the queue',
>             required: false,
>             type: 5
>       
>           },
>           {
>             name: 'shuffle',
>             description: "shuffle the input if you're adding multiple tracks",
>             required: false,
>             type: 5
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'queue',
>         description: 'show the current queue',
>         options: [
>           {
>             max_value: undefined,
>             min_value: undefined,
>             choices: undefined,
>             autocomplete: undefined,
>             type: 4,
>             name: 'page',
>             description: 'page of queue to show [default: 1]',
>             required: false
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'remove',
>         description: 'remove songs from the queue',
>         options: [
>           {
>             max_value: undefined,
>             min_value: undefined,
>             choices: undefined,
>             autocomplete: undefined,
>             type: 4,
>             name: 'position',
>             description: 'position of the song to remove [default: 1]',
>             required: false
>       
>           },
>           {
>             max_value: undefined,
>             min_value: undefined,
>             choices: undefined,
>             autocomplete: undefined,
>             type: 4,
>             name: 'range',
>             description: 'number of songs to remove [default: 1]',
>             required: false
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'seek',
>         description: 'seek to a position from beginning of song',
>         options: [
>           {
>             choices: undefined,
>             autocomplete: undefined,
>             type: 3,
>             name: 'time',
>             description: 'time to seek',
>             required: true
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'shuffle',
>         description: 'shuffle the current queue',
>         options: [],
>         default_permission: undefined
>       },
>       {
>         name: 'skip',
>         description: 'skip the next songs',
>         options: [
>           {
>             max_value: undefined,
>             min_value: undefined,
>             choices: undefined,
>             autocomplete: undefined,
>             type: 4,
>             name: 'number',
>             description: 'number of songs to skip [default: 1]',
>             required: false
>           }
>         ],
>         default_permission: undefined
>       },
>       {
>         name: 'unskip',
>         description: 'go back in the queue by one song',
>         options: [],
>         default_permission: undefined
>       }
>     ]
>   }
> }
> file:///usr/app/node_modules/execa/lib/error.js:59
>       error = new Error(message);

I think this should be all the relevant log information? Let me know if there's anything else I can provide that would be helpful. I've loved using this bot in a server with some friends for months and would love to get it working again.

codetheweb commented 2 years ago

Looks like you have the same error: D[50001]: Missing Access. This is caused by your bot not having proper permissions to create slash commands within your guild. Please try kicking and re-inviting the bot once again, making sure that the invite URL contains &scope=bot%20applications.commands (should be automatically generated by Muse).

mzrimsek commented 2 years ago

Hmm what do I need to do to get Muse to generate the link for me? I feel like it should just be in the logs for the container but every time I spin up a new container it just prints the logs I've posted previously.

mzrimsek commented 2 years ago

Holy shit I forgot I had my bot in two servers and I had to kick it from both for it to work. I am so sorry for wasting your time.