Beispiel #1
0
async def remove(message: discord.Message, name: Annotate.LowerContent):
    """ Remove a pasta with the specified name. """
    # We don't even use spaces when removing pastas!
    parsed_name = name.replace(" ", "")

    assert parsed_name in pastas.data, "No pasta with name `{}`.".format(name)

    copypasta = pastas.data.pop(parsed_name)
    pastas.save()
    await client.say(message, "Pasta `{}` removed. In case this was a mistake, "
                                   "here's the pasta: ```{}```".format(name, copypasta))
Beispiel #2
0
async def pasta(message: discord.Message, name: Annotate.LowerContent):
    """ Use copypastas. Don't forget to enclose the copypasta in quotes: `"pasta goes here"` for multiline
        pasta action. You also need quotes around `<name>` if it has any spaces. """
    # Display a random pasta
    assert not name == ".", choice(list(pastas.data.values()))

    # We don't use spaces in pastas at all
    parsed_name = name.replace(" ", "")

    # Pasta might not be in the set
    assert parsed_name in pastas.data, "Pasta `{}` is undefined.\nPerhaps you meant: `{}`?".format(
        name, ", ".join(get_close_matches(parsed_name, pastas.data.keys(), cutoff=0.5)))

    # Display the specified pasta
    await client.say(message, pastas.data[parsed_name])