Javascript-forum
TypeError: Intents is not a constructor - Druckversion

+- Javascript-forum (https://javascript-forum.de)
+-- Forum: Entwicklung (https://javascript-forum.de/forumdisplay.php?fid=4)
+--- Forum: Javascript (https://javascript-forum.de/forumdisplay.php?fid=6)
+--- Thema: TypeError: Intents is not a constructor (/showthread.php?tid=2606)



TypeError: Intents is not a constructor - Chrisnoteto - 02.10.2023

hallo, 
ich habe das problem das bei einenm Skript für einen discord Bot diese Fehlermeldung Kommt :

TypeError: Intents is not a constructor

dakne für hilfe


RE: TypeError: Intents is not a constructor - rzscout - 03.10.2023

Hi Chrisnoteto,
das ganze sieht so aus, als ob das Problem mit der Verwendung von Intents zusammenhängt. Seit der Discord.js-Version 13 benötigt man Intents, um bestimmte Ereignisse zu verfolgen.

Vielleicht hilft dir das weiter - habe ich irgendwo im Netz aufgegabelt:

Code:
const { Client, Intents } = require('discord.js');

Damit stellst du sicher das die Dateien richtig importiert werden können.

Beim erstellen des Client-Objekts musst du die Intents verwenden die du vorher deklariert hast - hier ein Beispiel:

Code:
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

Je nach Bedarf kannst du die Funktionen deines Bots anpassen, und die bearbeiten bzw. hinzufügen. In dem Beispiel oben sind das GUILD und GUILD MESSAGE.

Schaue auch in die Dokumentation von Discord. Dort findest etliche Informationen zum Thema Bots und Funktionen.

VG

rzscout