"chat" event is emitted when commands are run. #3464
Labels
possible bug
Stage1
just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Versions
Steps to reproduce
bot.on('chat', (username, message) => { console.log(username); console.log(message) }
Connect to the same server as the bot.
Run any command. I ran
/give andy stick 2
. (andy was the name of the bot)Observed behavior
The following was logged in console:
Expected behavior
Nothing should be logged in console. The 'chat' event should not be triggered. No one has chatted.
If this is intended behavior, why don't command blocks emit the same message?
Additional context
When the command is run the following system message is sent:
[BF5258: Gave 2 [stick] to andy]
The regular expression used to detect chat catches this despite it being in square brackets.
The expression used:
/^(?:\(.{1,15}\)|\[.{1,15}\]|.){0,5}?(\w+)\s?[>:\-»\]\)~]+\s(.*)$
mineflayer\lib\plugins\chat.js line 3,4:
Solutions include changing
USERNAME_REGEX
to not match the square brackets or ignoring'chat.type.admin'
messages.Why does the username regex have wildcards on the start and end?
The text was updated successfully, but these errors were encountered: