Browse Source

Internal consistency with message related HTTPClient methods

pull/2095/head
Rapptz 6 years ago
parent
commit
14d66e7b9c
  1. 2
      discord/client.py
  2. 14
      discord/http.py
  3. 6
      discord/iterators.py
  4. 10
      discord/message.py

2
discord/client.py

@ -1125,7 +1125,7 @@ class Client:
:class:`~discord.User`
The user you requested.
"""
data = await self.http.get_user_info(user_id)
data = await self.http.get_user(user_id)
return User(state=self._connection, data=data)
async def fetch_user_profile(self, user_id):

14
discord/http.py

@ -370,26 +370,26 @@ class HTTPClient:
return self.request(r, json=payload, reason=reason)
def edit_message(self, message_id, channel_id, **fields):
def edit_message(self, channel_id, message_id, **fields):
r = Route('PATCH', '/channels/{channel_id}/messages/{message_id}', channel_id=channel_id, message_id=message_id)
return self.request(r, json=fields)
def add_reaction(self, message_id, channel_id, emoji):
def add_reaction(self, channel_id, message_id, emoji):
r = Route('PUT', '/channels/{channel_id}/messages/{message_id}/reactions/{emoji}/@me',
channel_id=channel_id, message_id=message_id, emoji=emoji)
return self.request(r, header_bypass_delay=0.25)
def remove_reaction(self, message_id, channel_id, emoji, member_id):
def remove_reaction(self, channel_id, message_id, emoji, member_id):
r = Route('DELETE', '/channels/{channel_id}/messages/{message_id}/reactions/{emoji}/{member_id}',
channel_id=channel_id, message_id=message_id, member_id=member_id, emoji=emoji)
return self.request(r, header_bypass_delay=0.25)
def remove_own_reaction(self, message_id, channel_id, emoji):
def remove_own_reaction(self, channel_id, message_id, emoji):
r = Route('DELETE', '/channels/{channel_id}/messages/{message_id}/reactions/{emoji}/@me',
channel_id=channel_id, message_id=message_id, emoji=emoji)
return self.request(r, header_bypass_delay=0.25)
def get_reaction_users(self, message_id, channel_id, emoji, limit, after=None):
def get_reaction_users(self, channel_id, message_id, emoji, limit, after=None):
r = Route('GET', '/channels/{channel_id}/messages/{message_id}/reactions/{emoji}',
channel_id=channel_id, message_id=message_id, emoji=emoji)
@ -398,7 +398,7 @@ class HTTPClient:
params['after'] = after
return self.request(r, params=params)
def clear_reactions(self, message_id, channel_id):
def clear_reactions(self, channel_id, message_id):
r = Route('DELETE', '/channels/{channel_id}/messages/{message_id}/reactions',
channel_id=channel_id, message_id=message_id)
@ -805,7 +805,7 @@ class HTTPClient:
value = '{0}?encoding={1}&v={2}'
return data['shards'], value.format(data['url'], encoding, v)
def get_user_info(self, user_id):
def get_user(self, user_id):
return self.request(Route('GET', '/users/{user_id}', user_id=user_id))
def get_user_profile(self, user_id):

6
discord/iterators.py

@ -151,7 +151,7 @@ class ReactionIterator(_AsyncIterator):
retrieve = self.limit if self.limit <= 100 else 100
after = self.after.id if self.after else None
data = await self.getter(self.message.id, self.channel_id, self.emoji, retrieve, after=after)
data = await self.getter(self.channel_id, self.message.id, self.emoji, retrieve, after=after)
if data:
self.limit -= retrieve
@ -199,7 +199,7 @@ class HistoryIterator(_AsyncIterator):
Message around which all messages must be. Limit max 101. Note that if
limit is an even number, this will return at most limit+1 messages.
oldest_first: :class:`bool`
If set to true, return messages in oldest->newest order. Defaults to
If set to true, return messages in oldest->newest order. Defaults to
True if ``after`` is specified, otherwise False.
"""
@ -380,7 +380,7 @@ class AuditLogIterator(_AsyncIterator):
self.entries = asyncio.Queue(loop=self.loop)
if self.reverse:
self._strategy = self._after_strategy
if self.before:

10
discord/message.py

@ -623,7 +623,7 @@ class Message:
if embed is not None:
fields['embed'] = embed.to_dict()
data = await self._state.http.edit_message(self.id, self.channel.id, **fields)
data = await self._state.http.edit_message(self.channel.id, self.id, **fields)
self._update(channel=self.channel, data=data)
try:
@ -713,7 +713,7 @@ class Message:
"""
emoji = self._emoji_reaction(emoji)
await self._state.http.add_reaction(self.id, self.channel.id, emoji)
await self._state.http.add_reaction(self.channel.id, self.id, emoji)
async def remove_reaction(self, emoji, member):
"""|coro|
@ -750,9 +750,9 @@ class Message:
emoji = self._emoji_reaction(emoji)
if member.id == self._state.self_id:
await self._state.http.remove_own_reaction(self.id, self.channel.id, emoji)
await self._state.http.remove_own_reaction(self.channel.id, self.id, emoji)
else:
await self._state.http.remove_reaction(self.id, self.channel.id, emoji, member.id)
await self._state.http.remove_reaction(self.channel.id, self.id, emoji, member.id)
@staticmethod
def _emoji_reaction(emoji):
@ -782,7 +782,7 @@ class Message:
Forbidden
You do not have the proper permissions to remove all the reactions.
"""
await self._state.http.clear_reactions(self.id, self.channel.id)
await self._state.http.clear_reactions(self.channel.id, self.id)
def ack(self):
"""|coro|

Loading…
Cancel
Save