Search code examples
rubydiscord

Get the User ID of who sent the slash command in Discordrb


I have a slash command written in the discordrb library. I want to know how I can get the user_id of who sent that slash command.

I've looked around the documentation and wiki for Discordrb and I haven't been able to find anything. I know it's possible using the discord.py library using interaction.author, so I know it's possible, just not sure how to do it in discordrb.


Solution

  • The event given when a command is invoked should have a user attribute with which you can access the author object.

    Here is where its define: https://github.com/shardlab/discordrb/blob/f2a313b795ecba34b99239db9627bdcbdeddbd46/lib/discordrb/events/interactions.rb#L30-L30