ifheroes / infinityheroes-bot

Dieser Bot erlaubt die Synchronisation zwischen der Webseite von ifheroes.de und unserem Discord Server.
GNU General Public License v3.0
2 stars 2 forks source link

Discord Bot installieren schlägt bei Deploy fehl #1

Closed chrischivlog closed 2 years ago

chrischivlog commented 2 years ago

Habe die Installation durchgeführt gab leider einen Fehler beim Setup

root@debian:/home/discord-bot# npm run deploy

> discord-web-bot-ifheroes@1.0.0 deploy
> node ./src/deploy-commands.js

/home/discord-bot/node_modules/@discordjs/rest/dist/index.js:1
var Re=Object.create;var A=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var ve=Object.getPrototypeOf,we=Object.prototype.hasOwnProperty;var Ee=(r,e,t)=>e in r?A(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var te=r=>A(r,"__esModule",{value:!0});var Le=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Se=(r,e)=>{for(var t in e)A(r,t,{get:e[t],enumerable:!0})},se=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ye(e))!we.call(r,i)&&(t||i!=="default")&&A(r,i,{get:()=>e[i],enumerable:!(s=be(e,i))||s.enumerable});return r},W=(r,e)=>se(te(A(r!=null?Re(ve(r)):{},"default",!e&&r&&r.__esModule?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r),xe=(r=>(e,t)=>r&&r.get(e)||(t=se(te({}),e,1),r&&r.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var l=(r,e,t)=>(Ee(r,typeof e!="symbol"?e+"":e,t),t),ie=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var u=(r,e,t)=>(ie(r,e,"read from private field"),t?t.call(r):e.get(r)),E=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},g=(r,e,t,s)=>(ie(r,e,"write to private field"),s?s.call(r,t):e.set(r,t),t);var re=Le((Oe,De)=>{De.exports={name:"@discordjs/rest",version:"0.3.0",description:"The REST API for discord.js",scripts:{build:"tsup && tsc --emitDeclarationOnly --incremental",test:"jest --pass-with-no-tests --collect-coverage",lint:"prettier --check . && eslint src __tests__ --ext mjs,js,ts",format:"prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",docs:"typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs",prepublishOnly:"yarn build && yarn lint && yarn test",changelog:"git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/rest/*'"},main:"./dist/index.js",module:"./dist/index.mjs",typings:"./dist/index.d.ts",exports:{import:"./dist/index.mjs",require:"./dist/index.js"},directories:{lib:"src",test:"__tests__"},files:["dist"],contributors:["Crawl <icrawltogo@gmail.com>","Amish Shah <amishshah.2k@gmail.com>","SpaceEEC <spaceeec@yahoo.com>","Vlad Frangu <kingdgrizzle@gmail.com>","Antonio Roman <kyradiscord@gmail.com>"],license:"Apache-2.0",keywords:["discord","api","rest","discordapp","discordjs"],repository:{type:"git",url:"git+https://github.com/discordjs/discord.js.git"},bugs:{url:"https://github.com/discordjs/discord.js/issues"},homepage:"https://discord.js.org",dependencies:{"@discordjs/collection":"^0.4.0","@sapphire/async-queue":"^1.1.9","@sapphire/snowflake":"^3.0.1","discord-api-types":"^0.26.1","form-data":"^4.0.0","node-fetch":"^2.6.5",tslib:"^2.3.1"},devDependencies:{"@babel/core":"^7.16.12","@babel/plugin-proposal-decorators":"^7.16.7","@babel/preset-env":"^7.16.11","@babel/preset-typescript":"^7.16.7","@discordjs/ts-docgen":"^0.3.4","@types/jest":"^27.4.0","@types/node-fetch":"^2.5.10","@typescript-eslint/eslint-plugin":"^5.10.0","@typescript-eslint/parser":"^5.10.0","babel-plugin-const-enum":"^1.2.0","babel-plugin-transform-typescript-metadata":"^0.3.2",eslint:"^8.7.0","eslint-config-marine":"^9.3.2","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^4.0.0",jest:"^27.4.7",nock:"^13.2.2",prettier:"^2.5.1",tsup:"^5.11.11",typedoc:"^0.22.11",typescript:"^4.5.5"},engines:{node:">=16.9.0"},publishConfig:{access:"public"}}});var $e={};Se($e,{ALLOWED_EXTENSIONS:()=>F,ALLOWED_SIZES:()=>P,ALLOWED_STICKER_EXTENSIONS:()=>G,CDN:()=>U,DefaultRestOptions:()=>L,DefaultUserAgent:()=>C,DiscordAPIError:()=>S,HTTPError:()=>_,REST:()=>de,RESTEvents:()=>j,RateLimitError:()=>D,RequestManager:()=>K,RequestMethod:()=>N});var ne=require("discord-api-types/v9"),ae=re(),C=`DiscordBot (${ae.homepage}, ${ae.version})`,L={agent:{},api:"https://discord.com/api",cdn:"https://cdn.discordapp.com",headers:{},invalidRequestWarningInterval:0,globalRequestsPerSecond:50,offset:50,rejectOnRateLimit:null,retries:3,timeout:15e3,userAgentAppendix:`Node.js ${process.version}`,version:ne.APIVersion,hashSweepInterval:144e5,hashLifetime:864e5,handlerSweepInterval:36e5},j=(m=>(m.Debug="restDebug",m.InvalidRequestWarning="invalidRequestWarning",m.RateLimited="rateLimited",m.Request="request",m.Response="response",m.HashSweep="hashSweep",m.HandlerSweep="handlerSweep",m))(j||{}),F=["webp","png","jpg","jpeg","gif"],G=["png","json"],P=[16,32,64,128,256,512,1024,2048,4096];var U=class{constructor(e=L.cdn){this.base=e}appAsset(e,t,s){return this.makeURL(`/app-assets/${e}/${t}`,s)}appIcon(e,t,s){return this.makeURL(`/app-icons/${e}/${t}`,s)}avatar(e,t,s){return this.dynamicMakeURL(`/avatars/${e}/${t}`,t,s)}banner(e,t,s){return this.dynamicMakeURL(`/banners/${e}/${t}`,t,s)}channelIcon(e,t,s){return this.makeURL(`/channel-icons/${e}/${t}`,s)}defaultAvatar(e){return this.makeURL(`/embed/avatars/${e}`)}discoverySplash(e,t,s){return this.makeURL(`/discovery-splashes/${e}/${t}`,s)}emoji(e,t){return this.makeURL(`/emojis/${e}`,{extension:t})}guildMemberAvatar(e,t,s,i){return this.dynamicMakeURL(`/guilds/${e}/users/${t}/avatars/${s}`,s,i)}icon(e,t,s){return this.dynamicMakeURL(`/icons/${e}/${t}`,t,s)}roleIcon(e,t,s){return this.makeURL(`/role-icons/${e}/${t}`,s)}splash(e,t,s){return this.makeURL(`/splashes/${e}/${t}`,s)}sticker(e,t){return this.makeURL(`/stickers/${e}`,{allowedExtensions:G,extension:t??"png"})}stickerPackBanner(e,t){return this.makeURL(`/app-assets/710982414301790216/store/${e}`,t)}teamIcon(e,t,s){return this.makeURL(`/team-icons/${e}/${t}`,s)}dynamicMakeURL(e,t,{forceStatic:s=!1,...i}={}){return this.makeURL(e,!s&&t.startsWith("a_")?{...i,extension:"gif"}:i)}makeURL(e,{allowedExtensions:t=F,extension:s="webp",size:i}={}){if(s=String(s).toLowerCase(),!t.includes(s))throw new RangeError(`Invalid extension provided: ${s}

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/discord-bot/src/deploy-commands.js:2:18)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
npm ERR! code 1
npm ERR! path /home/discord-bot
npm ERR! command failed
npm ERR! command sh -c node ./src/deploy-commands.js

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-06-25T16_15_38_445Z-debug.log
root@debian:/home/discord-bot# 

Log vom NPM 2022-06-25T16_07_08_753Z-debug.log

EckigerLuca commented 2 years ago

Tatsächlich weiß ich jetzt nicht wo der Fehler her kommt. In der Datei ist kein '?' vorhanden. Sicher das du nicht aus Versehen ein '?' hinzugefügt hast?

Und versuch mal alle modules neu installieren. Also den Ordner node_modules löschen und npm i ausführen.

chrischivlog commented 2 years ago

Hab mal in der Config nachgesehen habe an der stelle wo der Token ist auch den Token hin Platziert :D

Allerdings ist mir nicht so klar was bei Color hin soll....

Hier ein ausschnitt aus der Konsole als ich die Module neu installiert habe. Kann es sein das hier neue Versionen verlangt werden?

root@debian:/home/discord-bot# rm -r node_modules/
root@debian:/home/discord-bot# npm i
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@discordjs/builders@0.12.0',
npm WARN EBADENGINE   required: { node: '>=16.9.0' },
npm WARN EBADENGINE   current: { node: 'v12.22.5', npm: '7.5.2' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@discordjs/collection@0.4.0',
npm WARN EBADENGINE   required: { node: '>=16.0.0', npm: '>=7.0.0' },
npm WARN EBADENGINE   current: { node: 'v12.22.5', npm: '7.5.2' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@discordjs/rest@0.3.0',
npm WARN EBADENGINE   required: { node: '>=16.9.0' },
npm WARN EBADENGINE   current: { node: 'v12.22.5', npm: '7.5.2' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@sapphire/async-queue@1.2.0',
npm WARN EBADENGINE   required: { node: '>=v14.0.0', npm: '>=7.0.0' },
npm WARN EBADENGINE   current: { node: 'v12.22.5', npm: '7.5.2' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@sapphire/snowflake@3.1.0',
npm WARN EBADENGINE   required: { node: '>=v14.0.0', npm: '>=7.0.0' },
npm WARN EBADENGINE   current: { node: 'v12.22.5', npm: '7.5.2' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'discord.js@13.6.0',
npm WARN EBADENGINE   required: { node: '>=16.6.0', npm: '>=7.0.0' },
npm WARN EBADENGINE   current: { node: 'v12.22.5', npm: '7.5.2' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@discordjs/builders@0.11.0',
npm WARN EBADENGINE   required: { node: '>=16.0.0', npm: '>=7.0.0' },
npm WARN EBADENGINE   current: { node: 'v12.22.5', npm: '7.5.2' }
npm WARN EBADENGINE }

added 115 packages, and audited 116 packages in 3s

15 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
root@debian:/home/discord-bot# npm fund
discord-web-bot-ifheroes@1.0.0
├─┬ https://opencollective.com/eslint
│ │ └── eslint@8.8.0
│ ├── https://github.com/sponsors/epoberezkin
│ │   └── ajv@6.12.6
│ ├─┬ https://github.com/chalk/chalk?sponsor=1
│ │ │ └── chalk@4.1.2
│ │ └── https://github.com/chalk/ansi-styles?sponsor=1
│ │     └── ansi-styles@4.3.0
│ ├── https://github.com/sponsors/sindresorhus
│ │   └── escape-string-regexp@4.0.0, globals@13.12.1, type-fest@0.20.2, import-fresh@3.3.0, strip-json-comments@3.1.1
│ ├── https://github.com/sponsors/mysticatea
│ │   └── eslint-utils@3.0.0, regexpp@3.2.0
│ └── https://github.com/sponsors/isaacs
│     └── rimraf@3.0.2, glob@7.2.0
├── https://github.com/sindresorhus/is?sponsor=1
│   └── @sindresorhus/is@4.4.0
└── https://github.com/sponsors/colinhacks
    └── zod@3.11.6

root@debian:/home/discord-bot# ./start.sh 
./start.sh: Zeile 3: Syntaxfehler beim unerwarteten Symbol »done«
./start.sh: Zeile 3: `done'
root@debian:/home/discord-bot# 
EckigerLuca commented 2 years ago
  1. Color ist wegen dem Embed.
  2. Deine node version ist zu alt. Installier am besten 16.x oder 17.x. Also die neuste Version. Das löst alles.
chrischivlog commented 2 years ago

Hat funktioniert allerdings rennt er jetzt in einen neuen Fehler.

Man muss dazu sagen das ich dem Bot auch vorher die Berechtigungen gegeben habe, sollte ich hier noch was ergänzen?

image

root@debian:/home/discord-bot# npm start

> discord-web-bot-ifheroes@1.0.0 start
> node ./src/index.js

Ready! Logged in as Py-test-bot#4611

Successfully updated Guild Command Permissions!

/home/discord-bot/node_modules/discord.js/src/rest/RequestHandler.js:350
      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: Bots cannot use this endpoint
    at RequestHandler.execute (/home/discord-bot/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/home/discord-bot/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
    at async ApplicationCommandPermissionsManager.set (/home/discord-bot/node_modules/discord.js/src/managers/ApplicationCommandPermissionsManager.js:168:20) {
  method: 'put',
  path: '/applications/829318719138299934/guilds/876387207458455582/commands/990524906578010122/permissions',
  code: 20001,
  httpStatus: 403,
  requestData: {
    json: {
      permissions: [ { id: '990280061145985075', permission: true, type: 1 } ]
    },
    files: []
  }
}
root@debian:/home/discord-bot#  
EckigerLuca commented 2 years ago

Soooo, Problem gefunden, Lösung in Arbeit. Discord hat den API-Endpoint den ich benutzt habe, um den Command nur von einer bestimmten Rolle ausführen zu lassen, deaktiviert und durch etwas anderes ersetzt. Siehe hier.

EckigerLuca commented 2 years ago

Weitere Sache, Slash Commands sind nun nicht nur von bestimmten Personen oder Rollen ausführbar (im Sinne von angezeigt werden). Nun gibt es zwei Möglichkeiten:

  1. Jeder kann versuchen den Command auszuführen, es würde sich an den Configs nichts ändern, lediglich am Code selbst. Derjenige der es nicht darf kriegt dann eine Fehler Nachricht an den Kopf geworfen im Sinne von "Du darfst diesen Command nicht ausführen" oder
  2. Nur Leute mit bestimmten Rechten wie z.B. Administrator können den Command ausführen. Dabei würden sich u. a. auch die Config Dateien ändern.

Bitte um schnelle Antwort.

chrischivlog commented 2 years ago

Würde zweitens bevorzugen da man nicht immer feststeht wer news veröffentlicht. Sorry für die lange Wartezeit

EckigerLuca commented 2 years ago

Ich hab vergessen zu erwähnen, dass beim ersten eine Rolle überprüft wird ^^

EckigerLuca commented 2 years ago

Also nicht die Person selbst sondern ob er/sie/es (sorry musste sein) die in der Config festgelegte Rolle hat.

chrischivlog commented 2 years ago

Perfekt, ja.

EckigerLuca commented 2 years ago

Gut, wäre dann auch gleich fertig. Ich mach dann gleich einen Push und schließe dann auch das Issue :)

chrischivlog commented 2 years ago

Du bisch ein Gott 😍

EckigerLuca commented 2 years ago

Sooo: Alles ist online. Bei mir funktioniert alles. Sofern was nicht läuft einfach nochmal ein Issue aufmachen 👍🏻