Node.JS Discord Bot?
Hi ich brauche Hilfe wenn ich den Bot starten möchte kommt: internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module 'C:\Users\Username'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Der Code ist: const Discord = require("discord.js");
const bot = new Discord.Client();
const token = "OTAwNzI3OTQxNDE0MTQ2MDk4.YXFiQw.wApS2slBTTHBFH23-sdxJiJuDok";
bot.login(token);
2 Antworten
Hast du discord.js überhaupt installiert? Du musst es erst noch installieren:
npm i discord.js
{
"name": "discord-bot-gaming",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^13.2.0"
}
}
Ehm ist mir bissl peinlich aber hab es doch nicht installiert aber jetzt kommt immernoch eine Fehlermeldung undzwar: internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module 'node:events'
Require stack:
- C:\Users\UsernameDesktop\BOTS\Discord\Discord Bot Gaming\node_modules\discord.js\src\client\BaseClient.js
- C:\Users\Username\Desktop\BOTS\Discord\Discord Bot Gaming\node_modules\discord.js\src\index.js
- C:\Users\Username\Desktop\BOTS\Discord\Discord Bot Gaming\index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (C:\Users\Username\Desktop\BOTS\Discord\Discord Bot Gaming\node_modules\discord.js\src\client\BaseClient.js:3:22)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
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:14)
at Module.require (internal/modules/cjs/loader.js:974:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Username\\Desktop\\BOTS\\Discord\\Discord Bot Gaming\\node_modules\\discord.js\\src\\client\\BaseClient.js',
'C:\\Users\\Username\\Desktop\\BOTS\\Discord\\Discord Bot Gaming\\node_modules\\discord.js\\src\\index.js',
'C:\\Users\\Username\\Desktop\\BOTS\\Discord\\Discord Bot Gaming\\index.js'
]
}
Du brauchst Version 16.6 oder höhe, also Current, nicht LTSr: https://nodejs.org/en/
Muss ich Node.JS erst löschen (Wenn ja kannst du mir dann ein paar Befehle die ich dazu brauche?) oder einfach updaten? Wenn ich da nicht einfach nur es installieren muss auch sagen wie es geht?
Einfach den aktuellsten Installer herunterladen und ausführen.
Würde mal Node neuinstallieren -> https://nodejs.org/de/download/
Bei mir funktioniert der Code ohne Probleme... und besorg dir einen neuen Discord Token von deinem Bot. Mit dem Token können andere auf den Bot zugreifen und Schaden anrichten.
Klar hab ich es schon installiert!