async def long(self, ctx): """Lists detailed version of customcmds. Ex: >customcmds long""" with open('settings/commands.json') as commands: if 'gist' in ctx.message.content or 'Gist' in ctx.message.content: cmds = commands.read() link = PythonGists.Gist(description='Full commands.json', content=cmds, name='commands.json') return await self.bot.send_message( ctx.message.channel, bot_prefix + 'Full commands.json: %s' % link) else: cmds = json.load(commands) msg = '' sortedcmds = sorted(cmds.keys(), key=lambda x: x.lower()) if ctx.message.content[17:] and ctx.message.content[17:] != 'gist': one_cmd = True list_cmd = ctx.message.content.strip().split('long')[1].strip() for cmd in sortedcmds: if one_cmd and list_cmd == cmd: msg += '"' + cmd + '" : "' if type(cmds[cmd]) == list: for i in cmds[cmd]: msg += str(i) + ', ' msg = msg[:-2] + '",\n\n' else: msg += str(cmds[cmd]) + '",\n\n' else: for cmd in sortedcmds: msg += '"' + cmd + '" : "' if type(cmds[cmd]) == list: for i in cmds[cmd]: msg += str(i) + ', ' msg = msg[:-2] + '",\n\n' else: msg += str(cmds[cmd]) + '",\n\n' msg = msg[:-3] msg += '}```' part = int(math.ceil(len(msg) / 1900)) if part == 1: await self.bot.send_message( ctx.message.channel, bot_prefix + '```json\nList of Custom Commands: {\n' + msg) else: msg = msg[7:-3] splitList = [msg[i:i + 1900] for i in range(0, len(msg), 1900)] allWords = [] splitmsg = '' for i, blocks in enumerate(splitList): splitmsg += 'List of Custom Commands: %s of %s\n\n' % (i + 1, part) for b in blocks.split('\n'): splitmsg += b + '\n' allWords.append(splitmsg) splitmsg = '' for i in allWords: await self.bot.send_message(ctx.message.channel, '```%s```' % i)
async def long(self, ctx): """Lists detailed version of customcmds. Ex: [p]customcmds long""" with open('settings/commands.json') as commands: if 'haste' in ctx.message.content or 'Haste' in ctx.message.content: cmds = commands.read() link = await hastebin(cmds, self.bot.session) return await ctx.send(self.bot.bot_prefix + 'Full commands.json: %s' % link) else: cmds = json.load(commands) msg = '' sortedcmds = sorted(cmds.keys(), key=lambda x: x.lower()) if ctx.message.content[17:] and ctx.message.content[17:] != 'haste': one_cmd = True list_cmd = ctx.message.content.strip().split('long')[1].strip() for cmd in sortedcmds: if one_cmd and list_cmd == cmd: msg += '"' + cmd + '" : "' if type(cmds[cmd]) == list: for i in cmds[cmd]: msg += str(i) + ', ' msg = msg[:-2] + '",\n\n' else: msg += str(cmds[cmd]) + '",\n\n' else: for cmd in sortedcmds: msg += '"' + cmd + '" : "' if type(cmds[cmd]) == list: for i in cmds[cmd]: msg += str(i) + ', ' msg = msg[:-2] + '",\n\n' else: msg += str(cmds[cmd]) + '",\n\n' msg = msg[:-3] msg += '}```' part = int(math.ceil(len(msg) / 1900)) if part == 1: await ctx.send(self.bot.bot_prefix + '```json\nList of Custom Commands: {\n' + msg) else: msg = msg[7:-3] splitList = [msg[i:i + 1900] for i in range(0, len(msg), 1900)] allWords = [] splitmsg = '' for i, blocks in enumerate(splitList): splitmsg += 'List of Custom Commands: %s of %s\n\n' % (i + 1, part) for b in blocks.split('\n'): splitmsg += b + '\n' allWords.append(splitmsg) splitmsg = '' for i in allWords: await ctx.send('```%s```' % i)
def __init__(self, bot): self.bot = bot commands = open("cogs/commandlist.txt", "r") self.commands = commands.read().split("&&&") commands.close()