Esempio n. 1
0
    async def update(self, ctx):
        """
		Git Pulls and updates the bot code
		"""
        log.info(
            emb(f'Git pull called, Caller:[{ctx.author.id}][{ctx.author.name}]'
                ))
        bash_cmd = "git pull"
        process = subprocess.Popen(bash_cmd.split(), stdout=subprocess.PIPE)
        output, error = process.communicate()
        output = output.decode("utf-8")
        log.info(output)
        await ctx.send(emb(output))

        if error is not None:
            log.error(error)
Esempio n. 2
0
    async def unload(self, ctx, extension_name: str):
        """
		Unloads an extension.
		"""
        try:
            self.bot.unload_extension(f'cogs.{extension_name}')
            await ctx.message.channel.send(
                emb("Module [{}] Unloaded!.".format(extension_name)))
        except (AttributeError, ImportError) as e:
            await ctx.message.channel.send("```py\n{}: {}\n```".format(
                type(e).__name__, str(e)))
Esempio n. 3
0
    async def achievements(self, ctx):
        """
		Displays users current achievements.
		"""
        achievements = get_achievements(ctx.author.id, ctx.guild.id)
        if len(achievements) == 0:
            await ctx.send('You have not unlocked any achievements yet.')
            return

        x = PrettyTable()
        x.field_names = ["Name", "Description"]
        x.align["Name"] = "l"
        x.align["Description"] = "l"
        t_data = [self.achievement_types[x[2]] for x in achievements]
        for item in t_data:
            x.add_row([item['name'], item['description']])
        message = emb(
            x
        ) + f'\n Progress: {len(achievements)}/{len(self.achievement_types)}'
        await send_dm(self.bot, ctx.author.id, message)
Esempio n. 4
0
    async def on_member_remove(self, member):
        """
		Checks if user was kicked or banned and then get the users kick/ban history.
		If the user has kicked or banned more than 3 times in 1 day, remove all roles with kick/ban privileges.
		"""
        b_k = await member.guild.audit_logs(limit=None).flatten()
        b_k = [
            x for x in b_k
            if x.created_at > (datetime.utcnow() - timedelta(minutes=1))
        ]
        ba = [entry for entry in b_k if entry.target.id == member.id]
        if len(ba):
            b_k_user = ba[0].user
            bans = await member.guild.audit_logs(
                user=b_k_user,
                after=datetime.utcnow() - timedelta(days=1),
                action=AuditLogAction.ban).flatten()
            kicks = await member.guild.audit_logs(
                user=b_k_user,
                after=datetime.utcnow() - timedelta(days=1),
                action=AuditLogAction.kick).flatten()
            if len(bans) > 3 or len(
                    kicks
            ) > 3 and not b_k_user.top_role.permissions.administrator:
                if not b_k_user.guild.owner_id == b_k_user.id:
                    roles_to_remove = [
                        role for role in b_k_user.roles
                        if role.permissions.ban_members
                        or role.permissions.kick_members
                    ]
                    await b_k_user.remove_roles(
                        roles_to_remove,
                        reason=
                        'RougeGuard: User banned/kicked more than 3 times in 1 day',
                        atomic=True)
                    log.info(f'RougeGuard Triggered: [{b_k_user.id}] removed\
						more than 3 users from guild [{b_k_user.guild.id}]- Removed users roles')
                    message = emb(
                        'You have removed more than 3 users, your mod roles are temporarily removed until further investigation'
                    )
                    await send_dm(self.bot, b_k_user.id, message)
Esempio n. 5
0
    async def reload(self, ctx, extension_name: str):
        """
		Reloads an extension.
		"""
        self.bot.reload_extension(f'cogs.{extension_name.lower()}')
        await ctx.send(emb(f'{extension_name.lower()} reloaded!'))