Zur Zeit habe ich dies:Befehlszeitlimit | Discord.js
const Discord = require("discord.js");
const PREFIX = ",";
const token = "my token";
var bot = new Discord.Client();
bot.on('ready',() => {
bot.on('message', message => {
if (!message.content.startsWith(PREFIX)) return; //if not command ignore message
var args = message.content.substring(PREFIX.length).split(" "); //splits commands so each word = pos in array
switch (args[0].toLowerCase()) { //not case-sensitive anymore
case "hello":
message.channel.send("hello");
break;
//rest of the commands
ich die Verwendung des Befehls möchte „hallo“ begrenzen. Ich möchte, dass es für jedes Mal, wenn ein Benutzer ", hallo" eingibt, eine Zeitüberschreitung von 10 Sekunden gibt. Und wenn ein Benutzer vor dieser Abklingzeit den Befehl eingibt, wird eine Nachricht gesendet, die sagt, wer den Befehl zuletzt benutzt hat und wie lange er noch in der Abklingzeit bleibt. Diese
ist, was ich will das Ergebnis aussehen:
User1: ,hello
Bot: hello
(After 1 second)
User2: ,hello
Bot: User1 has already used this command, please wait another 9 seconds to use it again
(After 9 seconds)
User 2: ,hello
Bot: hello
Alle Hilfe ist willkommen. Danke,
Ja, 'lastHelloCommandDate' sollte auf '0' initialisiert werden. Wenn es "undefiniert" ist (wie oben beschrieben), ist das Ergebnis "new Date() - undefined", was zu "NaN" führt (was nicht größer als eine Zahl ist). –