msudol / hubot-discobot

A Hubot adapter for Discord, using the Discord.js API supporting the latest versions of Discord.js and Hubot. Make your own highly customizable Discord Bot.
GNU General Public License v3.0
2 stars 1 forks source link

How to get DiscordJS Message in robot.hear() scripts? #7

Open betaMFD opened 2 years ago

betaMFD commented 2 years ago

Is the DiscordJS Message easily accessible somehow from a robot.hear() or robot.respond() script?

I "cheated" on my fork and just saved it raw to the robot robot.discordJsMessage = message in onmessage so I can access it easily but that doesn't feel very clean or correct. But I'm using it constantly because all the good features are in the DiscordJS Message.

msudol commented 2 years ago

What do you mean exactly? Like take parts of the message and use them in the response?

betaMFD commented 2 years ago

While I'd be happy if it were set in the response, I want the DiscordJS Message object because it has a lot of DiscordJs functionality. So I don't want parts of it, I want the whole object. I can't see where I can get it right now without having the robot save it for me in the adapter's onmessage function, or forgoing robot.hear()/robot.respond() all together and using robot.client.on() which feels like I'm wasting the hubot infrastructure.

Does that make sense?

In the adapter's onmessage, I've tried just passing the DiscordJs Message object to @robot.receive instead of creating and passing the Hubot TextMessage object, but I end up with an error because the DiscordJs User object doesn't have the "room" in it.