Skip to content

Commit

Permalink
Added docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip3314 committed Apr 18, 2023
1 parent 5e51839 commit d57cdd2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion discord/ext/test/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ async def _edit_member_callback(fields: typing.Any, member: discord.Member, reas
Internal callback. Updates a guild's voice states to reflect the given Member connecting to the given channel.
Other updates to members are handled in http.edit_member().
:param fields: Fields passed in from Member.edit()
:param fields: Fields passed in from Member.edit().
:param member: The Member to edit.
:param reason: The reason for editing. Not used.
"""
data = {'user_id': member.id}
guild = member.guild
Expand Down
6 changes: 6 additions & 0 deletions discord/ext/test/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ def _guild_needs_chunking(self, guild: discord.Guild):
return False

def parse_channel_create(self, data) -> None:
"""
Need to make sure that FakeVoiceChannels are created when this is called to create VoiceChannels. Otherwise,
guilds would not be set up correctly.
:param data: info to use in channel creation.
"""
if data['type'] == discord.ChannelType.voice.value:
factory, ch_type = FakeVoiceChannel, discord.ChannelType.voice.value
else:
Expand Down
9 changes: 9 additions & 0 deletions discord/ext/test/voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@


class FakeVoiceClient(VoiceClient):
"""
Mock implementation of a Discord VoiceClient. VoiceClient.connect tries to contact the Discord API and is called
whenever connect() is called on a VoiceChannel, so we need to override that method and pass in the fake version
to prevent the program from actually making calls to the Discord API.
"""
async def connect(self, *, reconnect: bool, timeout: float, self_deaf: bool = False,
self_mute: bool = False) -> None:
self._connected.set()


class FakeVoiceChannel(VoiceChannel):
"""
Mock implementation of a Discord VoiceChannel. Exists just to pass a FakeVoiceClient into the superclass connect()
method.
"""

async def connect(
self,
Expand Down

0 comments on commit d57cdd2

Please sign in to comment.