Drop support for Python 3.4 and make minimum version 3.5.2.

This commit is contained in:
Rapptz
2018-06-10 18:09:14 -04:00
parent 7eb918b19e
commit f25091efe1
35 changed files with 626 additions and 1069 deletions

View File

@ -183,9 +183,8 @@ class Member(discord.abc.Messageable, _BaseUser):
def __hash__(self):
return hash(self._user.id)
@asyncio.coroutine
def _get_channel(self):
ch = yield from self.create_dm()
async def _get_channel(self):
ch = await self.create_dm()
return ch
def _update_roles(self, data):
@ -341,32 +340,28 @@ class Member(discord.abc.Messageable, _BaseUser):
"""Optional[:class:`VoiceState`]: Returns the member's current voice state."""
return self.guild._voice_state_for(self._user.id)
@asyncio.coroutine
def ban(self, **kwargs):
async def ban(self, **kwargs):
"""|coro|
Bans this member. Equivalent to :meth:`Guild.ban`
"""
yield from self.guild.ban(self, **kwargs)
await self.guild.ban(self, **kwargs)
@asyncio.coroutine
def unban(self, *, reason=None):
async def unban(self, *, reason=None):
"""|coro|
Unbans this member. Equivalent to :meth:`Guild.unban`
"""
yield from self.guild.unban(self, reason=reason)
await self.guild.unban(self, reason=reason)
@asyncio.coroutine
def kick(self, *, reason=None):
async def kick(self, *, reason=None):
"""|coro|
Kicks this member. Equivalent to :meth:`Guild.kick`
"""
yield from self.guild.kick(self, reason=reason)
await self.guild.kick(self, reason=reason)
@asyncio.coroutine
def edit(self, *, reason=None, **fields):
async def edit(self, *, reason=None, **fields):
"""|coro|
Edits the member's data.
@ -423,7 +418,7 @@ class Member(discord.abc.Messageable, _BaseUser):
else:
nick = nick if nick else ''
if self._state.self_id == self.id:
yield from http.change_my_nickname(guild_id, nick, reason=reason)
await http.change_my_nickname(guild_id, nick, reason=reason)
else:
payload['nick'] = nick
@ -449,12 +444,11 @@ class Member(discord.abc.Messageable, _BaseUser):
else:
payload['roles'] = tuple(r.id for r in roles)
yield from http.edit_member(guild_id, self.id, reason=reason, **payload)
await http.edit_member(guild_id, self.id, reason=reason, **payload)
# TODO: wait for WS event for modify-in-place behaviour
@asyncio.coroutine
def move_to(self, channel, *, reason=None):
async def move_to(self, channel, *, reason=None):
"""|coro|
Moves a member to a new voice channel (they must be connected first).
@ -471,10 +465,9 @@ class Member(discord.abc.Messageable, _BaseUser):
reason: Optional[str]
The reason for doing this action. Shows up on the audit log.
"""
yield from self.edit(voice_channel=channel, reason=reason)
await self.edit(voice_channel=channel, reason=reason)
@asyncio.coroutine
def add_roles(self, *roles, reason=None, atomic=True):
async def add_roles(self, *roles, reason=None, atomic=True):
"""|coro|
Gives the member a number of :class:`Role`\s.
@ -504,16 +497,15 @@ class Member(discord.abc.Messageable, _BaseUser):
if not atomic:
new_roles = utils._unique(Object(id=r.id) for s in (self.roles[1:], roles) for r in s)
yield from self.edit(roles=new_roles, reason=reason)
await self.edit(roles=new_roles, reason=reason)
else:
req = self._state.http.add_role
guild_id = self.guild.id
user_id = self.id
for role in roles:
yield from req(guild_id, user_id, role.id, reason=reason)
await req(guild_id, user_id, role.id, reason=reason)
@asyncio.coroutine
def remove_roles(self, *roles, reason=None, atomic=True):
async def remove_roles(self, *roles, reason=None, atomic=True):
"""|coro|
Removes :class:`Role`\s from this member.
@ -549,10 +541,10 @@ class Member(discord.abc.Messageable, _BaseUser):
except ValueError:
pass
yield from self.edit(roles=new_roles, reason=reason)
await self.edit(roles=new_roles, reason=reason)
else:
req = self._state.http.remove_role
guild_id = self.guild.id
user_id = self.id
for role in roles:
yield from req(guild_id, user_id, role.id, reason=reason)
await req(guild_id, user_id, role.id, reason=reason)