Skip to content

Commit

Permalink
Merge branch 'feature/dpy-voiceprotocol-changes' of https://github.co…
Browse files Browse the repository at this point in the history
…m/PredaaA/Red-DiscordBot into feature/dpy-voiceprotocol-changes
  • Loading branch information
PredaaA committed Feb 21, 2022
2 parents 68ce7b7 + 0515e90 commit e48fbc0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Red is built with cogs, a fancy term for plugins. They are
modules that add functionality to Red. They contain
commands to use.

Red comes with 19 cogs containing the basic features, such
Red comes with 18 cogs containing the basic features, such
as moderation, utility, music, streams...

You can see your loaded and unloaded cogs with the ``[p]cogs``
Expand Down
40 changes: 39 additions & 1 deletion redbot/core/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import collections.abc
import json
import logging
import pickle
import weakref
Expand Down Expand Up @@ -807,7 +808,8 @@ def _register_default(self, key: str, **kwargs: Any):
if key not in self._defaults:
self._defaults[key] = {}

data = pickle.loads(pickle.dumps(kwargs, -1))
# this serves as a 'deep copy' and verification that the default is serializable to JSON
data = json.loads(json.dumps(kwargs))

for k, v in data.items():
to_add = self._get_defaults_dict(k, v)
Expand Down Expand Up @@ -956,7 +958,13 @@ def guild_from_id(self, guild_id: int) -> Group:
`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:
Expand Down Expand Up @@ -990,7 +998,15 @@ def channel_from_id(self, channel_id: int) -> Group:
`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:
Expand Down Expand Up @@ -1024,7 +1040,13 @@ def role_from_id(self, role_id: int) -> Group:
`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:
Expand Down Expand Up @@ -1056,7 +1078,13 @@ def user_from_id(self, user_id: int) -> Group:
`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:
Expand Down Expand Up @@ -1090,7 +1118,17 @@ def member_from_ids(self, guild_id: int, member_id: int) -> Group:
`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:
Expand Down

0 comments on commit e48fbc0

Please sign in to comment.