<commit_before>import math
import re
from PythonGists import PythonGists
from appuselfbot import bot_prefix
from discord.ext import commands
from cogs.utils.checks import *

'''Module for custom commands adding, removing, and viewing.'''


class Customcmds:

    def __init__(self, bot):
        self.bot = bot

    # List all custom commands
    @commands.group(pass_context=True)
    async def customcmds(self, ctx):
        """Lists all customcmds."""
        if ctx.invoked_subcommand is None:
            with open('settings/commands.json', 'r') as c:
                cmds = json.load(c)
            sortedcmds = sorted(cmds.keys(), key=lambda x: x.lower())
            msgs = []
            part = ''
            for cmd in sortedcmds:
                if type(cmds[cmd]) is list:
                    check = cmd + ': '
                    for i in cmds[cmd]:
                        check += str(i[0]) + ' | '
                    check = check.rstrip(' | ') + '\n\n'
                else:
                    check = cmd + '\n\n'
                if len(part + check) > 1900:
                    msgs.append(part)
                    part = check
                else:
                    part += check
            msgs.append(part)
            if 'gist' in ctx.message.content or 'Gist' in ctx.message.content:
                msgs = '\n'.join(msgs)
                url = PythonGists.Gist(description='Custom Commands', content=str(msgs), name='commands.txt')
                await self.bot.send_message(ctx.message.channel, bot_prefix + 'List of Custom Commands: %s' % url)
            else:
                if len(msgs) == 1:
                    await self.bot.send_message(ctx.message.channel, '```css\n[List of Custom Commands]\n%s ```' % msgs[0].rstrip())
                else:
                    for b, i in enumerate(msgs):
                        await self.bot.send_message(ctx.message.channel, '```css\n[List of Custom Commands %s/%s]\n%s ```' % (b + 1, len(msgs), i.rstrip()))
        await self.bot.delete_message(ctx.message)

    @customcmds.command(pass_context=True)
    async def long(self, ctx):
        """Lists detailed version of customcmds."""
        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='a sample gist', content=cmds, name='test')
                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())
        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:<commit_msg>slight change for customcmds long gist<commit_after>import math
import re
from PythonGists import PythonGists
from appuselfbot import bot_prefix
from discord.ext import commands
from cogs.utils.checks import *

'''Module for custom commands adding, removing, and viewing.'''


class Customcmds:

    def __init__(self, bot):
        self.bot = bot

    # List all custom commands
    @commands.group(pass_context=True)
    async def customcmds(self, ctx):
        """Lists all customcmds."""
        if ctx.invoked_subcommand is None:
            with open('settings/commands.json', 'r') as c:
                cmds = json.load(c)
            sortedcmds = sorted(cmds.keys(), key=lambda x: x.lower())
            msgs = []
            part = ''
            for cmd in sortedcmds:
                if type(cmds[cmd]) is list:
                    check = cmd + ': '
                    for i in cmds[cmd]:
                        check += str(i[0]) + ' | '
                    check = check.rstrip(' | ') + '\n\n'
                else:
                    check = cmd + '\n\n'
                if len(part + check) > 1900:
                    msgs.append(part)
                    part = check
                else:
                    part += check
            msgs.append(part)
            if 'gist' in ctx.message.content or 'Gist' in ctx.message.content:
                msgs = '\n'.join(msgs)
                url = PythonGists.Gist(description='Custom Commands', content=str(msgs), name='commands.txt')
                await self.bot.send_message(ctx.message.channel, bot_prefix + 'List of Custom Commands: %s' % url)
            else:
                if len(msgs) == 1:
                    await self.bot.send_message(ctx.message.channel, '```css\n[List of Custom Commands]\n%s ```' % msgs[0].rstrip())
                else:
                    for b, i in enumerate(msgs):
                        await self.bot.send_message(ctx.message.channel, '```css\n[List of Custom Commands %s/%s]\n%s ```' % (b + 1, len(msgs), i.rstrip()))
        await self.bot.delete_message(ctx.message)

    @customcmds.command(pass_context=True)
    async def long(self, ctx):
        """Lists detailed version of customcmds."""
        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())
        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:
{'fraction_non_alphanumeric': 0.12770236299648063, 'fraction_numerical': 0.0030165912518853697, 'mean_word_length': 1.6798383475527616, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1954961', 'n_tokens_mistral': 1786, 'n_tokens_neox': 1709, 'n_words': 439}