Beispiel #1
0
    async def officer_mode(self, ctx, status: str):
        """Turns officer mode on or off: Officer mode limits list and lookup to officers only"""

        if status.lower() not in ['on', 'off']:
            await self.bot.say(codify('Command only accepts on or off'))
            return

        server = ctx.message.server.id
        roles = [r.name for r in ctx.message.author.roles]
        officer_mode = True if status.lower() == 'on' else False
        if ADMIN_USER not in roles:
            await self.bot.say(codify('Only officers can perform this action'))
            return

        try:
            server_setting = ServerSettings.objects(server=server).first()
            if not server_setting:
                setting = ServerSettings(server=server,
                                         officer_mode=officer_mode)
                setting.save()
            else:
                server_setting.update(officer_mode=officer_mode)
                server_setting.save()

            logActivity(
                'Server settings updated on {}'.format(
                    ctx.message.server.name), ctx.message.author.name)
            await self.bot.say(
                codify('Officer Mode successfuly changed to {}'.format(status))
            )
        except Exception as e:
            print_error(e)
            await self.bot.say(
                "Could not change officer mode to {}".format(status))
Beispiel #2
0
def is_officer_mode(server: int):
    setting = ServerSettings.objects(server=server).first()
    if setting:
        return setting.officer_mode
    return False