Can you help me with a Discord bot?
Hello,
I wrote a Discord bot, but it won't go online. This is the error code:
And here are the codes:
const Discord = resquire('discord.js'); const prefix = '/' const client = new Discord.Client({ allsowedMentions: { parse: [`users`, `roles`], repliedUser: true, }, intents: [ "Guilds", "GuildMessages", "GuildPresences", "GuildMembers", "GuildMessageReactions", ], }); client.on("ready", () => { console.log("Bot is online!") }) client.on('message', message => { if (!message.content.startsWith(prefix) || message.author.bot) return; const args = message.content.slice(prefix.lenght).split(/ +/); const command = args.shift().toLowerCase(); // test command if (command === 'test') { message.channel.send('The bot is currently working') } }) client.login("Bleibt geheim")
Can someone please help me?
read the error message.
because resquire does not exist, you certainly wanted to use require.
also your code is very faulty and uncertain
ToDo:
-Corrigate allsowedMentions zu allowedMentions
-For intents, the corresponding flags from the Discord.Intents.FLAGS enumeration must be used.
-Use the messageCreate event instead of message, because message is out of date.
-Corrigate prefix.lenght to prefix.length and add .trim() to remove superfluous spaces.
Just give the code to ChatGPT, he can correct it all.
The code currently fails in the first line as you need to use “require(…)” and not “resquire(…)”.
Seems pretty good here too: https://www.freecodecamp.org/news/how-to-use-the-javascript-require-function/
Hope that helped:)