Reply to message?

Posted in General by SixtenDK Thu Aug 24 2017 08:40:48 GMT+0000 (UTC)·3·Viewed 499 times

Hey When i do this $discord->on('ready', function ($discord) { echo "Bot is ready!", PHP_EOL; // Listen for messages. $discord->on('message', function ($message, $discord) { $message->reply("Hi!"); }); }); It replys 1 time to the name and 4 times to it self? 5 times in totalt How can i workaround this? [10:24] SixtenDk: s [10:24] BOTmyliferp: @SixtenDk, 1 [10:24] BOTmyliferp: @myliferp, 1 [10:24] BOTmyliferp: @myliferp, 1 [10:24] BOTmyliferp: @myliferp, 1 [10:24] BOTmyliferp: @myliferp, 1
SixtenDK
Aug 24, 2017

Hmm got it nvm but why does it answer so many times?

Mitch
Aug 28, 2017

It is simply stuck in a loop, because every time the bot detects a message it replies to the user of said message.

Akira
Oct 13, 2017

I'm not sure if you are very new to PHP but this is quite simple honestly.

What you want to do is make an if statement where If ($author !== "Bots Name").
Now that is not exactly how the code would be, i haven't read too much into the lib specifics but you should at least get the concept.

  
Markdown is allowed