Exemple #1
0
 async def afk(self, ctx, txt: str = None):
     """Set your Discord status for when you aren't online. Ex: >afk idle"""
     with open('settings/optional_config.json', 'r+') as fp:
         opt = json.load(fp)
         info = parse_prefix(self.bot, 'Current status returned by Discord: `{}` | Current Default status: `{}`\n'.format(str(ctx.message.author.status).title(), opt['default_status'].title())+\
         'Options: ``idle``, ``dnd``, ``offline``. When the status is set, the bot will set you to this by default when you are not on Discord. Ex: [c]afk idle')
         info = parse_prefix(self.bot, info)
         if txt:
             if txt.strip() == 'idle':
                 opt['default_status'] = 'idle'
                 self.bot.default_status = 'idle'
             elif txt.strip() == 'dnd' or txt.strip() == 'do not disturb':
                 opt['default_status'] = 'dnd'
                 self.bot.default_status = 'dnd'
             elif txt.strip() == 'offline' or 'invis' in txt.strip(
             ) or txt.strip() == 'incognito':
                 opt['default_status'] = 'invisible'
                 self.bot.default_status = 'invisible'
             else:
                 return await self.bot.send_message(
                     ctx.message.channel,
                     self.bot.bot_prefix + 'Invalid status. %s' % info)
         else:
             return await self.bot.send_message(ctx.message.channel,
                                                self.bot.bot_prefix + info)
         fp.seek(0)
         fp.truncate()
         json.dump(opt, fp, indent=4)
         await self.bot.send_message(
             ctx.message.channel, self.bot.bot_prefix +
             'Set default afk status. You will now appear as ``{}`` when not on Discord.'
             .format(opt['default_status']))
Exemple #2
0
 async def afk(self, ctx, txt: str = None):
     """Set your Discord status for when you aren't online. Ex: [p]afk idle"""
     with open('settings/optional_config.json', 'r+') as fp:
         opt = json.load(fp)
         usage = parse_prefix(self.bot, 'Options: ``idle``, ``dnd``, ``offline``. When the status is set, the bot will set you to this by default when you are not on Discord. Ex: [c]afk idle')
         if txt:
             if txt.strip() == 'idle':
                 opt['default_status'] = 'idle'
                 self.bot.default_status = 'idle'
             elif txt.strip() == 'dnd' or txt.strip() == 'do not disturb':
                 opt['default_status'] = 'dnd'
                 self.bot.default_status = 'dnd'
             elif txt.strip() == 'offline' or 'invis' in txt.strip() or txt.strip() == 'incognito':
                 opt['default_status'] = 'invisible'
                 self.bot.default_status = 'invisible'
             else:
                 return await ctx.send(self.bot.bot_prefix + 'Invalid status.\n' + usage)
         else:
             if isinstance(ctx.message.author, discord.Member):
                 info = 'Current status returned by Discord: `{}` | Current Default status: `{}`\n'.format(str(ctx.message.author.status).title(), opt['default_status'].title())
             else:
                 info = 'Current Default status: `{}`\n'.format(opt['default_status'].title())
             return await ctx.send(self.bot.bot_prefix + info + usage)
         fp.seek(0)
         fp.truncate()
         json.dump(opt, fp, indent=4)
         await ctx.send(self.bot.bot_prefix + 'Set default afk status. You will now appear as ``{}`` when not on Discord.'.format(
                                         opt['default_status']))