'Serenity get client ID

How do you get the id of the client in the EventHandler when using Serenity for a discord bot?

I am unsure of how to get the client and its id. I need this so that I can make sure that the message that the bot is responding to isn't its own. Also, no, checking if the message was sent by a bot won't work because I need to make it so that it can respond to the messages of other bots too. If there is another way without getting the id of the client in the EventHandler, I would be fine with that too. Static variables do not count.



Solution 1:[1]

One of the arguments you are given is a Context value, and you can get the current user through its cache, from Cache::current_user_id():

// Assuming ctx is the name of the Context argument:
let my_uid = ctx.cache.current_user_id();

This requires the cache feature of the serenity crate.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cdhowie