mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Add typechecking to config from_id methods (#5564)
* [config] Add typechecking for parameters * change instance check * Knew it, shouldnt have added these * black
This commit is contained in:
parent
b0ab6186ef
commit
8d46568180
@ -958,7 +958,13 @@ class Config(metaclass=ConfigMeta):
|
||||
`Group <redbot.core.config.Group>`
|
||||
The guild's Group object.
|
||||
|
||||
Raises
|
||||
------
|
||||
TypeError
|
||||
If the given guild_id parameter is not of type int
|
||||
"""
|
||||
if type(guild_id) is not int:
|
||||
raise TypeError(f"guild_id should be of type int, not {guild_id.__class__.__name__}")
|
||||
return self._get_base_group(self.GUILD, str(guild_id))
|
||||
|
||||
def guild(self, guild: discord.Guild) -> Group:
|
||||
@ -992,7 +998,15 @@ class Config(metaclass=ConfigMeta):
|
||||
`Group <redbot.core.config.Group>`
|
||||
The channel's Group object.
|
||||
|
||||
Raises
|
||||
------
|
||||
TypeError
|
||||
If the given channel_id parameter is not of type int
|
||||
"""
|
||||
if type(channel_id) is not int:
|
||||
raise TypeError(
|
||||
f"channel_id should be of type int, not {channel_id.__class__.__name__}"
|
||||
)
|
||||
return self._get_base_group(self.CHANNEL, str(channel_id))
|
||||
|
||||
def channel(self, channel: discord.abc.GuildChannel) -> Group:
|
||||
@ -1026,7 +1040,13 @@ class Config(metaclass=ConfigMeta):
|
||||
`Group <redbot.core.config.Group>`
|
||||
The role's Group object.
|
||||
|
||||
Raises
|
||||
------
|
||||
TypeError
|
||||
If the given role_id parameter is not of type int
|
||||
"""
|
||||
if type(role_id) is not int:
|
||||
raise TypeError(f"role_id should be of type int, not {role_id.__class__.__name__}")
|
||||
return self._get_base_group(self.ROLE, str(role_id))
|
||||
|
||||
def role(self, role: discord.Role) -> Group:
|
||||
@ -1058,7 +1078,13 @@ class Config(metaclass=ConfigMeta):
|
||||
`Group <redbot.core.config.Group>`
|
||||
The user's Group object.
|
||||
|
||||
Raises
|
||||
------
|
||||
TypeError
|
||||
If the given user_id parameter is not of type int
|
||||
"""
|
||||
if type(user_id) is not int:
|
||||
raise TypeError(f"user_id should be of type int, not {user_id.__class__.__name__}")
|
||||
return self._get_base_group(self.USER, str(user_id))
|
||||
|
||||
def user(self, user: discord.abc.User) -> Group:
|
||||
@ -1092,7 +1118,17 @@ class Config(metaclass=ConfigMeta):
|
||||
`Group <redbot.core.config.Group>`
|
||||
The member's Group object.
|
||||
|
||||
Raises
|
||||
------
|
||||
TypeError
|
||||
If the given guild_id or member_id parameter is not of type int
|
||||
"""
|
||||
if type(guild_id) is not int:
|
||||
raise TypeError(f"guild_id should be of type int, not {guild_id.__class__.__name__}")
|
||||
|
||||
if type(member_id) is not int:
|
||||
raise TypeError(f"member_id should be of type int, not {member_id.__class__.__name__}")
|
||||
|
||||
return self._get_base_group(self.MEMBER, str(guild_id), str(member_id))
|
||||
|
||||
def member(self, member: discord.Member) -> Group:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user