예제 #1
0
 async def on_raw_reaction_add(self, payload):
     channel = self.bot.get_channel(payload.channel_id)
     try:
         message = await channel.fetch_message(payload.message_id)
     except (discord.errors.NotFound, AttributeError):
         return
     guild = message.guild
     try:
         user = guild.get_member(payload.user_id)
     except AttributeError:
         return
     pvp_dict = self.bot.guild_dict[guild.id].setdefault('pvp_dict', {})
     if message.id in pvp_dict and user.id != self.bot.user.id:
         trainer = pvp_dict[message.id]['reportauthor']
         if str(payload.emoji) == '🚫':
             if trainer == payload.user_id or utils.can_manage(
                     user, self.bot.config):
                 return await self.expire_pvp(message)
         if str(payload.emoji) == '\u2694':
             attacker = guild.get_member(payload.user_id)
             defender = guild.get_member(
                 pvp_dict[message.id]['reportauthor'])
             if attacker == defender:
                 return
             battle_msg = await channel.send(
                 content=f"{defender.mention} you have been challenged "
                 f"by {attacker.mention}!",
                 embed=discord.Embed(
                     colour=discord.Colour.red(),
                     description=
                     f"{defender.mention} you have been challenged "
                     f"by {attacker.mention}!"),
                 delete_after=30)
             await battle_msg.edit(content="")
예제 #2
0
 async def on_raw_reaction_add(self, payload):
     channel = self.bot.get_channel(payload.channel_id)
     try:
         message = await channel.fetch_message(payload.message_id)
     except (discord.errors.NotFound, AttributeError):
         return
     ctx = await self.bot.get_context(message)
     guild = message.guild
     if not guild:
         return
     try:
         utilities_cog = self.bot.cogs.get('Utilities')
         if not utilities_cog.can_manage(guild.get_member(payload.user_id)):
             return
     except:
         pass
     react_user = guild.get_member(payload.user_id)
     if not utils.can_manage(react_user, self.bot.config):
         return
     nest_dict = self.bot.guild_dict[guild.id]['configure_dict']\
         .get('nests', self.nest_dict_default)
     if payload.channel_id not in nest_dict['listen_channels']:
         return
     if str(payload.emoji) == self.bot.success_react:
         try:
             target_user = ctx.guild.get_member(ctx.message.author.id)
         except AttributeError:
             return
         nests = self.bot.guild_dict[guild.id]['trainers'].setdefault('nests', {})\
             .setdefault(target_user.id, 0) + 1
         self.bot.guild_dict[guild.id]['trainers']['nests'][target_user.id] = nests
예제 #3
0
 async def on_raw_reaction_add(self, payload):
     if payload.user_id == self.bot.user.id:
         return
     guild_dict = self.bot.guild_dict
     channel = self.bot.get_channel(payload.channel_id)
     try:
         message = await channel.fetch_message(payload.message_id)
     except (discord.errors.NotFound, AttributeError):
         return
     guild = message.guild
     try:
         user = guild.get_member(payload.user_id)
     except AttributeError:
         return
     utils_cog = self.bot.cogs.get('Utilities')
     regions = utils_cog.get_channel_regions(channel, 'raid')
     listmgmt_cog = self.bot.cogs.get('ListManagement')
     questreport_dict = guild_dict[guild.id].setdefault(
         'questreport_dict', {})
     if message.id in questreport_dict:
         quest_dict = questreport_dict.get(message.id, None)
         if quest_dict and (quest_dict['reportauthor'] == payload.user_id
                            or utils.can_manage(user, self.bot.config)):
             if str(payload.emoji) == '\u270f':
                 await self.modify_research_report(payload)
             elif str(payload.emoji) == '🚫':
                 try:
                     await message.edit(embed=discord.Embed(
                         description="Research report cancelled",
                         colour=message.embeds[0].colour.value))
                     await message.clear_reactions()
                     await self._cancel_db_research_report(message)
                 except discord.errors.NotFound:
                     pass
                 del questreport_dict[message.id]
                 await listmgmt_cog.update_listing_channels(guild,
                                                            "research",
                                                            edit=True,
                                                            regions=regions)
             await message.remove_reaction(payload.emoji, user)
예제 #4
0
 async def on_raw_reaction_add(self, payload):
     if payload.user_id == self.bot.user.id:
         return
     channel = self.bot.get_channel(payload.channel_id)
     try:
         message = await channel.fetch_message(payload.message_id)
     except (discord.errors.NotFound, AttributeError):
         return
     guild = message.guild
     try:
         user = guild.get_member(payload.user_id)
     except AttributeError:
         return
     for i, d in self.bot.active_invasions.items():
         if d["message"].id == message.id:
             if d["author"] == payload.user_id or utils.can_manage(
                     user, self.bot.config):
                 if str(payload.emoji) == '💨':
                     await self.expire_invasion(i)
                     break
                 elif str(payload.emoji) in ['🇵', '\u270f']:
                     await self.modify_report(payload)
예제 #5
0
 async def on_raw_reaction_add(self, payload):
     channel = self.bot.get_channel(payload.channel_id)
     try:
         message = await channel.fetch_message(payload.message_id)
     except (discord.errors.NotFound, AttributeError):
         return
     guild = message.guild
     try:
         user = guild.get_member(payload.user_id)
     except AttributeError:
         return
     raid_notice_dict = self.bot.guild_dict[guild.id].setdefault('raid_notice_dict', {})
     if message.id in raid_notice_dict and user.id != self.bot.user.id:
         trainer = raid_notice_dict[message.id]['reportauthor']
         if trainer == payload.user_id or utils.can_manage(user, self.bot.config):
             if str(payload.emoji) == '🚫':
                 return await self.expire_raid_notice(message)
             if str(payload.emoji) == '\u23f2':
                 exp = raid_notice_dict[message.id]['exp'] + 1800
                 raid_notice_dict[message.id]['exp'] = exp
                 expire = datetime.datetime.fromtimestamp(exp)
                 expire_str = expire.strftime('%b %d %I:%M %p')
                 embed = message.embeds[0]
                 index = 0
                 found = False
                 for field in embed.fields:
                     if "expire" in field.name.lower():
                         found = True
                         break
                     index += 1
                 if found:
                     embed.set_field_at(index, name=embed.fields[index].name, value=expire_str, inline=True)
                 else:
                     embed.add_field(name='**Expires:**', value='{end}'.format(end=expire_str), inline=True)
                 await message.edit(embed=embed)
                 await message.remove_reaction(payload.emoji, user)
예제 #6
0
 async def on_raw_reaction_add(self, payload):
     if payload.user_id == self.bot.user.id:
         return
     channel = self.bot.get_channel(payload.channel_id)
     try:
         message = await channel.fetch_message(payload.message_id)
     except (discord.errors.NotFound, AttributeError):
         return
     guild = message.guild
     try:
         user = guild.get_member(payload.user_id)
     except AttributeError:
         return
     ctx = await self.bot.get_context(message)
     update = False
     active_hideouts = self.active_hideouts()
     for h in active_hideouts:
         if h.message == message.id:
             if h.trainer == payload.user_id or utils.can_manage(
                     user, self.bot.config):
                 if str(payload.emoji) == '\u270f':
                     await self.modify_report(ctx, payload, h.id)
                     update = True
                     break
                 elif str(payload.emoji) == '🚫':
                     await self.cancel_and_delete(ctx, h.id)
                     update = True
                     break
     if update:
         utils_cog = self.bot.cogs.get('Utilities')
         listmgmt_cog = self.bot.cogs.get('ListManagement')
         regions = utils_cog.get_channel_regions(channel, 'research')
         await listmgmt_cog.update_listing_channels(guild,
                                                    'hideout',
                                                    edit=True,
                                                    regions=regions)
예제 #7
0
    async def on_raw_reaction_add(self, payload):
        channel = self.bot.get_channel(payload.channel_id)
        try:
            message = await channel.fetch_message(payload.message_id)
        except (discord.errors.NotFound, AttributeError):
            return
        guild = message.guild
        if not guild:
            return
        try:
            utilities_cog = self.bot.cogs.get('Utilities')
            if not utilities_cog.can_manage(guild.get_member(payload.user_id)):
                return
        except:
            pass
        react_user = guild.get_member(payload.user_id)
        if not utils.can_manage(react_user, self.bot.config):
            return
        quick_badge_dict = self.bot.guild_dict[guild.id]['configure_dict']\
            .get('quick_badge', self.quick_badge_dict_default)
        if quick_badge_dict['pokenav_channel'] == 0 \
            or (payload.channel_id not in quick_badge_dict['listen_channels']
                and payload.channel_id not in quick_badge_dict.get('40_listen_channels', [])):
            return
        if payload.emoji.id in quick_badge_dict['badges']:
            try:
                target_user = guild.get_member(message.author.id)
            except AttributeError:
                return
            k_badge_id = quick_badge_dict['badges'][payload.emoji.id]['kyogre']
            p_badge_id = quick_badge_dict['badges'][payload.emoji.id]['pokenav']
            send_channel = self.bot.get_channel(quick_badge_dict['pokenav_channel'])
            badge_cog = self.bot.cogs.get('Badges')
            badge_to_give = BadgeTable.get(BadgeTable.id == k_badge_id)

            if not checks.is_user_owner_check(self.bot.config, react_user):
                check_message_str = f"{react_user.mention} do you want to give badge " \
                                    f"{badge_to_give.name} to {message.author.name}?"
                badge_check = await channel.send(check_message_str)
                try:
                    timeout = False
                    res, reactuser = await utils.simple_ask(self.bot, badge_check, channel, react_user.id)
                except TypeError:
                    timeout = True
                await badge_check.delete()
                if timeout or res.emoji == self.bot.failed_react:
                    return

            reaction, embed = await badge_cog.try_grant_badge(badge_to_give, payload.guild_id,
                                                              message.author.id, k_badge_id)
            if reaction == self.bot.success_react:
                await send_channel.send(f"$gb {p_badge_id} {target_user.mention}")
            badge_channel = self.bot.get_channel(quick_badge_dict['badge_channel'])
            await badge_channel.send(embed=embed)
        elif str(payload.emoji) == self.thumbsup_react \
                and payload.channel_id in quick_badge_dict.get('40_listen_channels', []):
            try:
                target_user = guild.get_member(message.author.id)
            except AttributeError:
                return
            forty_role_id = self.bot.guild_dict[guild.id]['configure_dict']\
                .get('quick_badge', self.quick_badge_dict_default).get('40_role', None)
            if forty_role_id is None:
                return
            forty_role = discord.utils.get(guild.roles, id=forty_role_id)
            if forty_role is None:
                return
            await target_user.add_roles(*[forty_role])
            await asyncio.sleep(0.1)
            if forty_role in target_user.roles:
                await channel.send(f"{target_user.mention} has been verified as level 40!")