async def parse_message_reaction_add(self, data, old): emoji = PartialEmoji.with_state( self, id=utils._get_as_snowflake(data["emoji"], "id"), animated=data["emoji"].get("animated", False), name=data["emoji"]["name"], ) raw = RawReactionActionEvent(data, emoji, "REACTION_ADD") member = data.get("member") if member: guild = await self._get_guild(raw.guild_id) if guild: raw.member = Member(guild=guild, state=self, data=member) self.dispatch("raw_reaction_add", raw) message = await self._get_message(raw.message_id) if message: reaction = Reaction(message=message, data=data, emoji=await self._upgrade_partial_emoji(emoji)) user = raw.member or await self._get_reaction_user( message.channel, raw.user_id) if user: self.dispatch("reaction_add", reaction, user)
async def get_member(self, user_id): member = await self._state.get(f"member:{self.id}:{user_id}") if member: return Member(guild=self, state=self._state, data=member) return None
def __init__(self, space=10, population=None, action=None): self.pop = population self.space = space if self.pop is None: self.pop = [Member() for i in xrange(space)] self.action = action if self.action == None: self.action = ['actions']
async def convert(self, ctx, argument): match = self._get_id_match(argument) or re.match(r"<@!?([0-9]+)>$", argument) if match: try: return await ctx.guild.fetch_member(int(match.group(1))) except discord.NotFound: pass members = await ctx.bot.http.request_guild_members(ctx.guild.id, argument) if len(members) > 0: return Member(guild=ctx.guild, state=ctx.bot.state, data=members[0]) raise MemberNotFound(argument)
async def parse_guild_member_remove(self, data, old): if old: guild = await self._get_guild(int(data["guild_id"])) if guild: member = Member(guild=guild, data=old, state=self) self.dispatch("member_remove", member)
async def parse_guild_member_add(self, data, old): guild = await self._get_guild(int(data["guild_id"])) if guild: member = Member(guild=guild, data=data, state=self) self.dispatch("member_join", member)
async def _members(self): return [ Member(guild=self, state=self._state, data=x) for x in await self._state._members_get_all("guild", key_id=self.id, name="member") ]
async def fetch_member(self, member_id): data = await self._state.http.get_member(self.id, member_id) return Member(data=data, state=self._state, guild=self)