Exemple #1
0
    async def on_reaction_add(self, reaction, user):
        server = config[str(user.guild.id)]
        tally = 0
        if user == self.bot.user:
            return
        if not reaction.message.channel.id == 137233143194320896:
            return
        db.try_create_table(f'pins_{user.guild.id}', ('message', 'users'))

        if not reaction.emoji == server['autopin']['reaction'] or reaction.message.pinned:
            return

        if reaction.message.id not in db.query(f'select message from pins_{user.guild.id}'):
            db.insert(f'pins_{user.guild.id}', (reaction.message.id, user.id))
            await reaction.message.add_reaction(reaction.emoji)
        else:
            users = db.query(f'select users from pins_{user.guild.id} where message = {reaction.message.id}')
            if user.id not in users:
                tally = len(db.query(f'select users from pins_{user.guild.id} where message = {reaction.message.id}'))
                db.insert(f'pins_{user.guild.id}', (reaction.message.id, user.id))
        await reaction.message.remove_reaction(reaction.emoji, user)

        if tally == server['autopin']['threshold']:
            await reaction.message.pin()
            db.remove(f'pins_{user.guild.id}', f'message = {reaction.message.id}')
Exemple #2
0
 async def watch_purge(self, ctx):
     """
     Removes users that are no longer in the server from the watchlist.
     """
     for id in db.query(f"SELECT DISTINCT id FROM eagleeye_{ctx.guild.id}"):
         if not self.bot.get_user(id):
             db.remove(f'eagleeye_{ctx.guild.id}', f'id = {id}')
     await ctx.send('Purged.')
Exemple #3
0
 async def unwatch(self, ctx, users: commands.Greedy[discord.Member]):
     """
     Removes users from the watchlist.
     """
     for user in users:
         db.remove(f'eagleeye_{ctx.guild.id}', f'id = {user.id}')
     await ctx.send(
         f'{list_prettyprint(user.name for user in users)} removed from the watchlist.'
     )
Exemple #4
0
async def unprobate_user(user):
    try:
        await remove_task(f'probation_{user.guild.id}_{user.id}')
    except JobLookupError:
        pass  # TODO proper error handling
    await user.remove_roles(
        discord.utils.get(user.guild.roles,
                          name=config[str(
                              user.guild.id)]['probate']['role_name']))
    channel = discord.utils.get(user.guild.text_channels,
                                name=f"probation_{user.id}")
    await channel.delete()
    db.remove(f'probations_{user.guild.id}', f'id = {user.id}')
Exemple #5
0
 async def delstrike(self, ctx, user: discord.Member, index: int):
     """
     Deletes a strike for a user.
     Automatically removes probation, if any.
     """
     server = config[str(ctx.guild.id)]
     strikes = db.query(f'SELECT reason from strikes_{ctx.guild.id} WHERE id = {user.id}')
     try:
         await remove_task(f'probation_{ctx.guild.id}_{user.id}')
     except JobLookupError:
         pass #TODO proper error handling
     try:
         await unprobate_user(user)
     except Exception as e:
         pass
     removal = strikes[index - 1]
     db.remove(f'strikes_{ctx.guild.id}', f'id = {user.id} and reason = "{removal}"')
     await user.send(f'You have been pardoned of a strike on {ctx.guild.name}. ' \
                    f'You now have {len(strikes) - 1} strikes. The removed strike was `{removal}`.')
Exemple #6
0
async def remove_strike(server, strike):
    db.remove(f'strikes_{server}', f'id = {strike[0]} and time = {strike[3]}')
    await write_embed(config[str(server)]['modlog_id'], member=None, color=config[str(server)]['strikes']['embed_color'],
                      title=strike[2], avatar=False,
                      message=f'**Strike removed:** A temporary strike for <@{strike[0]}> has expired.')