Beispiel #1
0
async def listcustom(ctx):
    custom_commands = split_dict(get_custom_dict(), DISCORD_EMBED_LIMIT)

    for page in custom_commands:
        embed = Embed(title="Custom Commands list", color=0x00ff75)

        for line in page:
            embed.add_field(name=".{}".format(line),
                            value=page[line],
                            inline=False)

        await ctx.author.send(embed=embed)
Beispiel #2
0
async def add(ctx, *args):

    command_name = args[0]
    command_url = args[1]
    try:
        data = get_custom_dict()
    except FileNotFoundError as e:
        print("creating file")
        data = dict()

    data[command_name] = command_url

    with open(os.environ["COMMANDS_DATA_FILE"], 'w') as f:
        yaml.dump(data, f, default_flow_style=False)
Beispiel #3
0
async def rm(ctx, command_name=""):
    try:
        if command_name == "":
            raise NoArgumentException("Are you dumb?")

        data = get_custom_dict()
        data.pop(command_name)

        with open(os.environ["COMMANDS_DATA_FILE"], 'w') as f:
            yaml.dump(data, f, default_flow_style=False)

    except FileNotFoundError as e:
        await ctx.send("buguei")
    except KeyError as e:
        await ctx.send("Tem esse comando ai não")
    except Exception as e:
        await ctx.send(e)
def test_get_custom_dict():
    os.environ["COMMANDS_DATA_FILE"] = os.path.dirname(
        os.path.abspath(__file__)) + "/../data_test.yml"
    data = get_custom_dict()
    assert data['test'] == "hi"
Beispiel #5
0
async def c(ctx, arg):
    data = get_custom_dict()
    await ctx.send(data[arg])