Red-DiscordBot
Red-DiscordBot copied to clipboard
Allow discord.ClientUser or discord.BaseUser for Config.user
What component of Red (cog, command, API) would you like to see improvements on?
API: Config
Describe the enhancement you're suggesting.
Currently, the method Config.user's typehint only allow discord.User, but it may be common for certain developers to use Red's user instance when calling Config.user, it is my case, but doing self.bot.user (Where self.bot is a redbot.bot.Red instance) will return a discord.ClientUser, which does not inherit from discord.User.
Here is my proposal:
- Change the
user's typehint ofConfig.userto:discord.BaseUser(Which is both implemented bydiscord.Useranddiscord.ClientUser, and that contains the user's ID) - Change the
user's typehint ofConfig.userto:typing.Union[discord.User, discord.ClientUser]
Both solution shouldn't introduce any breaking changes. I can drop a PR ASAP if you are okay with such modification.
Anything else?
Here is a live action of the issue:

Alternative: Adding # type: ignore at the end of the affected line
The type hint is discord.abc.User so it accepts all user types. The docstring uses discord.User so that could be fixed.
The screenshotted error is about you trying to pass a variable that might be None, not because of you trying to pass ClientUser.
My bad on that one, I just paid too much attention to the docstring and VSC... Damn me.
I'll correct the docstring at least... Sorry for the wrong infos 😰