Browse Source

[lint] Fix incorrect and inconsistent whitespace

Adjust whitespace to be consistent with the rest of the library.
pull/1521/merge
Hornwitser 7 years ago
committed by Rapptz
parent
commit
c8b49d37be
  1. 2
      discord/__main__.py
  2. 4
      discord/abc.py
  3. 1
      discord/calls.py
  4. 9
      discord/channel.py
  5. 6
      discord/client.py
  6. 2
      discord/embeds.py
  7. 1
      discord/ext/commands/context.py
  8. 10
      discord/ext/commands/converter.py
  9. 1
      discord/ext/commands/cooldowns.py
  10. 8
      discord/ext/commands/core.py
  11. 7
      discord/ext/commands/errors.py
  12. 1
      discord/ext/commands/view.py
  13. 8
      discord/gateway.py
  14. 19
      discord/http.py
  15. 4
      discord/invite.py
  16. 4
      discord/iterators.py
  17. 4
      discord/member.py
  18. 14
      discord/message.py
  19. 1
      discord/object.py
  20. 4
      discord/permissions.py
  21. 2
      discord/player.py
  22. 2
      discord/raw_models.py
  23. 2
      discord/role.py
  24. 6
      discord/shard.py
  25. 4
      discord/state.py
  26. 2
      discord/webhook.py

2
discord/__main__.py

@ -197,7 +197,7 @@ def newbot(parser, args):
with open(str(new_directory / 'config.py'), 'w', encoding='utf-8') as fp: with open(str(new_directory / 'config.py'), 'w', encoding='utf-8') as fp:
fp.write('token = "place your token here"\ncogs = []\n') fp.write('token = "place your token here"\ncogs = []\n')
except OSError as e: except OSError as e:
parser.error('could not create config file ({})'.format(e)) parser.error('could not create config file ({})'.format(e))
try: try:
with open(str(new_directory / 'bot.py'), 'w', encoding='utf-8') as fp: with open(str(new_directory / 'bot.py'), 'w', encoding='utf-8') as fp:

4
discord/abc.py

@ -742,7 +742,7 @@ class Messageable(metaclass=abc.ABCMeta):
try: try:
data = await state.http.send_files(channel.id, files=[(file.open_file(), file.filename)], data = await state.http.send_files(channel.id, files=[(file.open_file(), file.filename)],
content=content, tts=tts, embed=embed, nonce=nonce) content=content, tts=tts, embed=embed, nonce=nonce)
finally: finally:
file.close() file.close()
@ -753,7 +753,7 @@ class Messageable(metaclass=abc.ABCMeta):
try: try:
param = [(f.open_file(), f.filename) for f in files] param = [(f.open_file(), f.filename) for f in files]
data = await state.http.send_files(channel.id, files=param, content=content, tts=tts, data = await state.http.send_files(channel.id, files=param, content=content, tts=tts,
embed=embed, nonce=nonce) embed=embed, nonce=nonce)
finally: finally:
for f in files: for f in files:
f.close() f.close()

1
discord/calls.py

@ -153,4 +153,3 @@ class GroupCall:
""" """
return self._voice_states.get(user.id) return self._voice_states.get(user.id)

9
discord/channel.py

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
The MIT License (MIT) The MIT License (MIT)
@ -79,8 +80,8 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
top channel is position 0. top channel is position 0.
""" """
__slots__ = ( 'name', 'id', 'guild', 'topic', '_state', 'nsfw', __slots__ = ('name', 'id', 'guild', 'topic', '_state', 'nsfw',
'category_id', 'position', '_overwrites' ) 'category_id', 'position', '_overwrites')
def __init__(self, *, state, guild, data): def __init__(self, *, state, guild, data):
self._state = state self._state = state
@ -414,8 +415,8 @@ class VoiceChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable):
The channel's limit for number of members that can be in a voice channel. The channel's limit for number of members that can be in a voice channel.
""" """
__slots__ = ('name', 'id', 'guild', 'bitrate', 'user_limit', __slots__ = ('name', 'id', 'guild', 'bitrate', 'user_limit',
'_state', 'position', '_overwrites', 'category_id' ) '_state', 'position', '_overwrites', 'category_id')
def __init__(self, *, state, guild, data): def __init__(self, *, state, guild, data):
self._state = state self._state = state

6
discord/client.py

@ -369,10 +369,8 @@ class Client:
await self.ws.poll_event() await self.ws.poll_event()
except ResumeWebSocket: except ResumeWebSocket:
log.info('Got a request to RESUME the websocket.') log.info('Got a request to RESUME the websocket.')
coro = DiscordWebSocket.from_client(self, shard_id=self.shard_id, coro = DiscordWebSocket.from_client(self, shard_id=self.shard_id, session=self.ws.session_id,
session=self.ws.session_id, sequence=self.ws.sequence, resume=True)
sequence=self.ws.sequence,
resume=True)
self.ws = await asyncio.wait_for(coro, timeout=180.0, loop=self.loop) self.ws = await asyncio.wait_for(coro, timeout=180.0, loop=self.loop)
async def connect(self, *, reconnect=True): async def connect(self, *, reconnect=True):

2
discord/embeds.py

@ -119,7 +119,7 @@ class Embed:
# fill in the basic fields # fill in the basic fields
self.title = data.get('title', EmptyEmbed) self.title = data.get('title', EmptyEmbed)
self.type = data.get('type', EmptyEmbed) self.type = data.get('type', EmptyEmbed)
self.description = data.get('description', EmptyEmbed) self.description = data.get('description', EmptyEmbed)
self.url = data.get('url', EmptyEmbed) self.url = data.get('url', EmptyEmbed)

1
discord/ext/commands/context.py

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
The MIT License (MIT) The MIT License (MIT)

10
discord/ext/commands/converter.py

@ -30,11 +30,11 @@ import inspect
from .errors import BadArgument, NoPrivateMessage from .errors import BadArgument, NoPrivateMessage
__all__ = [ 'Converter', 'MemberConverter', 'UserConverter', __all__ = ['Converter', 'MemberConverter', 'UserConverter',
'TextChannelConverter', 'InviteConverter', 'RoleConverter', 'TextChannelConverter', 'InviteConverter', 'RoleConverter',
'GameConverter', 'ColourConverter', 'VoiceChannelConverter', 'GameConverter', 'ColourConverter', 'VoiceChannelConverter',
'EmojiConverter', 'PartialEmojiConverter', 'CategoryChannelConverter', 'EmojiConverter', 'PartialEmojiConverter', 'CategoryChannelConverter',
'IDConverter', 'clean_content' ] 'IDConverter', 'clean_content']
def _get_from_guilds(bot, getter, argument): def _get_from_guilds(bot, getter, argument):
result = None result = None

1
discord/ext/commands/cooldowns.py

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
The MIT License (MIT) The MIT License (MIT)

8
discord/ext/commands/core.py

@ -35,10 +35,10 @@ from .cooldowns import Cooldown, BucketType, CooldownMapping
from .view import quoted_word from .view import quoted_word
from . import converter as converters from . import converter as converters
__all__ = [ 'Command', 'Group', 'GroupMixin', 'command', 'group', __all__ = ['Command', 'Group', 'GroupMixin', 'command', 'group',
'has_role', 'has_permissions', 'has_any_role', 'check', 'has_role', 'has_permissions', 'has_any_role', 'check',
'bot_has_role', 'bot_has_permissions', 'bot_has_any_role', 'bot_has_role', 'bot_has_permissions', 'bot_has_any_role',
'cooldown', 'guild_only', 'is_owner', 'is_nsfw', ] 'cooldown', 'guild_only', 'is_owner', 'is_nsfw']
def wrap_callback(coro): def wrap_callback(coro):
@functools.wraps(coro) @functools.wraps(coro)

7
discord/ext/commands/errors.py

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
The MIT License (MIT) The MIT License (MIT)
@ -26,7 +27,7 @@ DEALINGS IN THE SOFTWARE.
from discord.errors import DiscordException from discord.errors import DiscordException
__all__ = [ 'CommandError', 'MissingRequiredArgument', 'BadArgument', __all__ = ['CommandError', 'MissingRequiredArgument', 'BadArgument',
'NoPrivateMessage', 'CheckFailure', 'CommandNotFound', 'NoPrivateMessage', 'CheckFailure', 'CommandNotFound',
'DisabledCommand', 'CommandInvokeError', 'TooManyArguments', 'DisabledCommand', 'CommandInvokeError', 'TooManyArguments',
'UserInputError', 'CommandOnCooldown', 'NotOwner', 'UserInputError', 'CommandOnCooldown', 'NotOwner',
@ -171,7 +172,7 @@ class MissingPermissions(CheckFailure):
missing = [perm.replace('_', ' ').replace('guild', 'server').title() for perm in missing_perms] missing = [perm.replace('_', ' ').replace('guild', 'server').title() for perm in missing_perms]
if len(missing) > 2: if len(missing) > 2:
fmt = '{}, and {}'.format(", ".join(missing[:-1]), missing[-1]) fmt = '{}, and {}'.format(", ".join(missing[:-1]), missing[-1])
else: else:
fmt = ' and '.join(missing) fmt = ' and '.join(missing)
message = 'You are missing {} permission(s) to run command.'.format(fmt) message = 'You are missing {} permission(s) to run command.'.format(fmt)
@ -191,7 +192,7 @@ class BotMissingPermissions(CheckFailure):
missing = [perm.replace('_', ' ').replace('guild', 'server').title() for perm in missing_perms] missing = [perm.replace('_', ' ').replace('guild', 'server').title() for perm in missing_perms]
if len(missing) > 2: if len(missing) > 2:
fmt = '{}, and {}'.format(", ".join(missing[:-1]), missing[-1]) fmt = '{}, and {}'.format(", ".join(missing[:-1]), missing[-1])
else: else:
fmt = ' and '.join(missing) fmt = ' and '.join(missing)
message = 'Bot requires {} permission(s) to run command.'.format(fmt) message = 'Bot requires {} permission(s) to run command.'.format(fmt)

1
discord/ext/commands/view.py

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
The MIT License (MIT) The MIT License (MIT)

8
discord/gateway.py

@ -40,8 +40,8 @@ import struct
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
__all__ = [ 'DiscordWebSocket', 'KeepAliveHandler', 'VoiceKeepAliveHandler', __all__ = ['DiscordWebSocket', 'KeepAliveHandler', 'VoiceKeepAliveHandler',
'DiscordVoiceWebSocket', 'ResumeWebSocket' ] 'DiscordVoiceWebSocket', 'ResumeWebSocket']
class ResumeWebSocket(Exception): class ResumeWebSocket(Exception):
"""Signals to initialise via RESUME opcode instead of IDENTIFY.""" """Signals to initialise via RESUME opcode instead of IDENTIFY."""
@ -381,7 +381,7 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol):
self.sequence = msg['s'] self.sequence = msg['s']
self.session_id = data['session_id'] self.session_id = data['session_id']
log.info('Shard ID %s has connected to Gateway: %s (Session ID: %s).', log.info('Shard ID %s has connected to Gateway: %s (Session ID: %s).',
self.shard_id, ', '.join(trace), self.session_id) self.shard_id, ', '.join(trace), self.session_id)
if event == 'RESUMED': if event == 'RESUMED':
self._trace = trace = data.get('_trace', []) self._trace = trace = data.get('_trace', [])
@ -684,5 +684,3 @@ class DiscordVoiceWebSocket(websockets.client.WebSocketClientProtocol):
self._keep_alive.stop() self._keep_alive.stop()
await super().close_connection(*args, **kwargs) await super().close_connection(*args, **kwargs)

19
discord/http.py

@ -339,8 +339,7 @@ class HTTPClient:
return self.request(r, data=form) return self.request(r, data=form)
async def ack_message(self, channel_id, message_id): async def ack_message(self, channel_id, message_id):
r = Route('POST', '/channels/{channel_id}/messages/{message_id}/ack', channel_id=channel_id, r = Route('POST', '/channels/{channel_id}/messages/{message_id}/ack', channel_id=channel_id, message_id=message_id)
message_id=message_id)
data = await self.request(r, json={'token': self._ack_token}) data = await self.request(r, json={'token': self._ack_token})
self._ack_token = data['token'] self._ack_token = data['token']
@ -348,8 +347,7 @@ class HTTPClient:
return self.request(Route('POST', '/guilds/{guild_id}/ack', guild_id=guild_id)) return self.request(Route('POST', '/guilds/{guild_id}/ack', guild_id=guild_id))
def delete_message(self, channel_id, message_id, *, reason=None): def delete_message(self, channel_id, message_id, *, reason=None):
r = Route('DELETE', '/channels/{channel_id}/messages/{message_id}', channel_id=channel_id, r = Route('DELETE', '/channels/{channel_id}/messages/{message_id}', channel_id=channel_id, message_id=message_id)
message_id=message_id)
return self.request(r, reason=reason) return self.request(r, reason=reason)
def delete_messages(self, channel_id, message_ids, *, reason=None): def delete_messages(self, channel_id, message_ids, *, reason=None):
@ -361,8 +359,7 @@ class HTTPClient:
return self.request(r, json=payload, reason=reason) return self.request(r, json=payload, reason=reason)
def edit_message(self, message_id, channel_id, **fields): def edit_message(self, message_id, channel_id, **fields):
r = Route('PATCH', '/channels/{channel_id}/messages/{message_id}', channel_id=channel_id, r = Route('PATCH', '/channels/{channel_id}/messages/{message_id}', channel_id=channel_id, message_id=message_id)
message_id=message_id)
return self.request(r, json=fields) return self.request(r, json=fields)
def add_reaction(self, message_id, channel_id, emoji): def add_reaction(self, message_id, channel_id, emoji):
@ -382,7 +379,7 @@ class HTTPClient:
def get_reaction_users(self, message_id, channel_id, emoji, limit, after=None): def get_reaction_users(self, message_id, channel_id, emoji, limit, after=None):
r = Route('GET', '/channels/{channel_id}/messages/{message_id}/reactions/{emoji}', r = Route('GET', '/channels/{channel_id}/messages/{message_id}/reactions/{emoji}',
channel_id=channel_id, message_id=message_id, emoji=emoji) channel_id=channel_id, message_id=message_id, emoji=emoji)
params = {'limit': limit} params = {'limit': limit}
if after: if after:
@ -415,11 +412,11 @@ class HTTPClient:
def pin_message(self, channel_id, message_id): def pin_message(self, channel_id, message_id):
return self.request(Route('PUT', '/channels/{channel_id}/pins/{message_id}', return self.request(Route('PUT', '/channels/{channel_id}/pins/{message_id}',
channel_id=channel_id, message_id=message_id)) channel_id=channel_id, message_id=message_id))
def unpin_message(self, channel_id, message_id): def unpin_message(self, channel_id, message_id):
return self.request(Route('DELETE', '/channels/{channel_id}/pins/{message_id}', return self.request(Route('DELETE', '/channels/{channel_id}/pins/{message_id}',
channel_id=channel_id, message_id=message_id)) channel_id=channel_id, message_id=message_id))
def pins_from(self, channel_id): def pins_from(self, channel_id):
return self.request(Route('GET', '/channels/{channel_id}/pins', channel_id=channel_id)) return self.request(Route('GET', '/channels/{channel_id}/pins', channel_id=channel_id))
@ -584,7 +581,7 @@ class HTTPClient:
return self.request(Route('GET', '/guilds/{guild_id}/vanity-url', guild_id=guild_id)) return self.request(Route('GET', '/guilds/{guild_id}/vanity-url', guild_id=guild_id))
def change_vanity_code(self, guild_id, code, *, reason=None): def change_vanity_code(self, guild_id, code, *, reason=None):
payload = { 'code': code } payload = {'code': code}
return self.request(Route('PATCH', '/guilds/{guild_id}/vanity-url', guild_id=guild_id), json=payload, reason=reason) return self.request(Route('PATCH', '/guilds/{guild_id}/vanity-url', guild_id=guild_id), json=payload, reason=reason)
def prune_members(self, guild_id, days, *, reason=None): def prune_members(self, guild_id, days, *, reason=None):
@ -622,7 +619,7 @@ class HTTPClient:
return self.request(r, json=payload, reason=reason) return self.request(r, json=payload, reason=reason)
def get_audit_logs(self, guild_id, limit=100, before=None, after=None, user_id=None, action_type=None): def get_audit_logs(self, guild_id, limit=100, before=None, after=None, user_id=None, action_type=None):
params = { 'limit': limit } params = {'limit': limit}
if before: if before:
params['before'] = before params['before'] = before
if after: if after:

4
discord/invite.py

@ -78,8 +78,8 @@ class Invite(Hashable):
""" """
__slots__ = ( 'max_age', 'code', 'guild', 'revoked', 'created_at', 'uses', __slots__ = ('max_age', 'code', 'guild', 'revoked', 'created_at', 'uses',
'temporary', 'max_uses', 'inviter', 'channel', '_state' ) 'temporary', 'max_uses', 'inviter', 'channel', '_state')
def __init__(self, *, state, data): def __init__(self, *, state, data):
self._state = state self._state = state

4
discord/iterators.py

@ -395,7 +395,7 @@ class AuditLogIterator(_AsyncIterator):
async def _before_strategy(self, retrieve): async def _before_strategy(self, retrieve):
before = self.before.id if self.before else None before = self.before.id if self.before else None
data = await self.request(self.guild.id, limit=retrieve, user_id=self.user_id, data = await self.request(self.guild.id, limit=retrieve, user_id=self.user_id,
action_type=self.action_type, before=before) action_type=self.action_type, before=before)
entries = data.get('audit_log_entries', []) entries = data.get('audit_log_entries', [])
if len(data) and entries: if len(data) and entries:
@ -407,7 +407,7 @@ class AuditLogIterator(_AsyncIterator):
async def _after_strategy(self, retrieve): async def _after_strategy(self, retrieve):
after = self.after.id if self.after else None after = self.after.id if self.after else None
data = await self.request(self.guild.id, limit=retrieve, user_id=self.user_id, data = await self.request(self.guild.id, limit=retrieve, user_id=self.user_id,
action_type=self.action_type, after=after) action_type=self.action_type, after=after)
entries = data.get('audit_log_entries', []) entries = data.get('audit_log_entries', [])
if len(data) and entries: if len(data) and entries:
if self.limit is not None: if self.limit is not None:

4
discord/member.py

@ -57,8 +57,8 @@ class VoiceState:
is not currently in a voice channel. is not currently in a voice channel.
""" """
__slots__ = ( 'session_id', 'deaf', 'mute', 'self_mute', __slots__ = ('session_id', 'deaf', 'mute', 'self_mute',
'self_deaf', 'afk', 'channel' ) 'self_deaf', 'afk', 'channel')
def __init__(self, *, data, channel=None): def __init__(self, *, data, channel=None):
self.session_id = data.get('session_id') self.session_id = data.get('session_id')

14
discord/message.py

@ -194,13 +194,13 @@ class Message:
- ``cover_image``: A string representing the embed's image asset ID. - ``cover_image``: A string representing the embed's image asset ID.
""" """
__slots__ = ( '_edited_timestamp', 'tts', 'content', 'channel', 'webhook_id', __slots__ = ('_edited_timestamp', 'tts', 'content', 'channel', 'webhook_id',
'mention_everyone', 'embeds', 'id', 'mentions', 'author', 'mention_everyone', 'embeds', 'id', 'mentions', 'author',
'_cs_channel_mentions', '_cs_raw_mentions', 'attachments', '_cs_channel_mentions', '_cs_raw_mentions', 'attachments',
'_cs_clean_content', '_cs_raw_channel_mentions', 'nonce', 'pinned', '_cs_clean_content', '_cs_raw_channel_mentions', 'nonce', 'pinned',
'role_mentions', '_cs_raw_role_mentions', 'type', 'call', 'role_mentions', '_cs_raw_role_mentions', 'type', 'call',
'_cs_system_content', '_cs_guild', '_state', 'reactions', '_cs_system_content', '_cs_guild', '_state', 'reactions',
'application', 'activity' ) 'application', 'activity')
def __init__(self, *, state, channel, data): def __init__(self, *, state, channel, data):
self._state = state self._state = state

1
discord/object.py

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
The MIT License (MIT) The MIT License (MIT)

4
discord/permissions.py

@ -493,7 +493,7 @@ class Permissions:
# after these 32 bits, there's 21 more unused ones technically # after these 32 bits, there's 21 more unused ones technically
def augment_from_permissions(cls): def augment_from_permissions(cls):
cls.VALID_NAMES = { name for name in dir(Permissions) if isinstance(getattr(Permissions, name), property) } cls.VALID_NAMES = {name for name in dir(Permissions) if isinstance(getattr(Permissions, name), property)}
# make descriptors for all the valid names # make descriptors for all the valid names
for name in cls.VALID_NAMES: for name in cls.VALID_NAMES:
@ -562,7 +562,7 @@ class PermissionOverwrite:
""" """
allow = Permissions.none() allow = Permissions.none()
deny = Permissions.none() deny = Permissions.none()
for key, value in self._values.items(): for key, value in self._values.items():
if value is True: if value is True:

2
discord/player.py

@ -36,7 +36,7 @@ from .opus import Encoder as OpusEncoder
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
__all__ = [ 'AudioSource', 'PCMAudio', 'FFmpegPCMAudio', 'PCMVolumeTransformer' ] __all__ = ['AudioSource', 'PCMAudio', 'FFmpegPCMAudio', 'PCMVolumeTransformer']
class AudioSource: class AudioSource:
"""Represents an audio stream. """Represents an audio stream.

2
discord/raw_models.py

@ -64,7 +64,7 @@ class RawBulkMessageDeleteEvent:
__slots__ = ('message_ids', 'channel_id', 'guild_id') __slots__ = ('message_ids', 'channel_id', 'guild_id')
def __init__(self, data): def __init__(self, data):
self.message_ids = { int(x) for x in data.get('ids', []) } self.message_ids = {int(x) for x in data.get('ids', [])}
self.channel_id = int(data['channel_id']) self.channel_id = int(data['channel_id'])
try: try:

2
discord/role.py

@ -92,7 +92,7 @@ class Role(Hashable):
""" """
__slots__ = ('id', 'name', 'permissions', 'color', 'colour', 'position', __slots__ = ('id', 'name', 'permissions', 'color', 'colour', 'position',
'managed', 'mentionable', 'hoist', 'guild', '_state' ) 'managed', 'mentionable', 'hoist', 'guild', '_state')
def __init__(self, *, guild, state, data): def __init__(self, *, guild, state, data):
self.guild = guild self.guild = guild

6
discord/shard.py

@ -76,10 +76,8 @@ class Shard:
await self.ws.poll_event() await self.ws.poll_event()
except ResumeWebSocket: except ResumeWebSocket:
log.info('Got a request to RESUME the websocket at Shard ID %s.', self.id) log.info('Got a request to RESUME the websocket at Shard ID %s.', self.id)
coro = DiscordWebSocket.from_client(self._client, resume=True, coro = DiscordWebSocket.from_client(self._client, resume=True, shard_id=self.id,
shard_id=self.id, session=self.ws.session_id, sequence=self.ws.sequence)
session=self.ws.session_id,
sequence=self.ws.sequence)
self.ws = await asyncio.wait_for(coro, timeout=180.0, loop=self.loop) self.ws = await asyncio.wait_for(coro, timeout=180.0, loop=self.loop)
def get_future(self): def get_future(self):

4
discord/state.py

@ -405,7 +405,7 @@ class ConnectionState:
raw = RawReactionClearEvent(data) raw = RawReactionClearEvent(data)
self.dispatch('raw_reaction_clear', raw) self.dispatch('raw_reaction_clear', raw)
message = self._get_message(raw.message_id) message = self._get_message(raw.message_id)
if message is not None: if message is not None:
old_reactions = message.reactions.copy() old_reactions = message.reactions.copy()
message.reactions.clear() message.reactions.clear()
@ -457,7 +457,7 @@ class ConnectionState:
self.user = ClientUser(state=self, data=data) self.user = ClientUser(state=self, data=data)
def parse_channel_delete(self, data): def parse_channel_delete(self, data):
guild = self._get_guild(utils._get_as_snowflake(data, 'guild_id')) guild = self._get_guild(utils._get_as_snowflake(data, 'guild_id'))
channel_id = int(data['id']) channel_id = int(data['id'])
if guild is not None: if guild is not None:
channel = guild.get_channel(channel_id) channel = guild.get_channel(channel_id)

2
discord/webhook.py

@ -222,7 +222,7 @@ class RequestsWebhookAdapter(WebhookAdapter):
data = utils.to_json(payload) data = utils.to_json(payload)
if multipart is not None: if multipart is not None:
data = { 'payload_json': multipart.pop('payload_json') } data = {'payload_json': multipart.pop('payload_json')}
for tries in range(5): for tries in range(5):
r = self.session.request(verb, url, headers=headers, data=data, files=multipart) r = self.session.request(verb, url, headers=headers, data=data, files=multipart)

Loading…
Cancel
Save