def setup_module(): register( category=None, names=["test4"] )(None) register( category=None, names=["test5"] )(None)
def setup_module(): register(category="category", names=["name", "alias"], required_args=["required"], optional_args=["optional"], description="description", example_args=["example1", "example2"])(None)
def test_general_help_embed(): registered_commands.clear() registered_categories.clear() register( category="A Test Category", names=["test", "alias"], required_args=["one", "two"], optional_args=["three"], description= "A command that uses `<one>`, `<two>`, and `[three]` to do stuff.", example_args=["one two", "1 2 3", "\"o n e\" two three"])(None) register(category="Other Test Category", names=["test2"])(None) embed = general_help_embed() assert embed assert "Commands" in embed.title assert "/" in embed.description # Should explain that this denotes aliases. assert "<>" in embed.description # Should explain that these two denote required/optional args. assert "[]" in embed.description assert embed.fields assert embed.fields[0].name == "A Test Category" assert embed.fields[1].name == "Other Test Category" assert f"**`{DEFAULT_PREFIX}test/{DEFAULT_PREFIX}alias <one> <two> [three]`**" in embed.fields[ 0].value assert f"**`{DEFAULT_PREFIX}test2`**" in embed.fields[1].value
def setup_module(): register(category="category", names=["test", "alias"])(lambda command: command.respond("hi")) register(category="category", names=["greet"], required_args=["name"], optional_args=["comment"])(greet)
def test_get_wrapper(): register( category="Some Category", names=["test", "alias"], required_args=["one", "two"], optional_args=["three"], description= "A command that uses `<one>`, `<two>`, and `[three]` to do stuff.", example_args=["one two", "1 2 3", "\"o n e\" two three"])(None) assert get_wrapper("test") == registered_commands["test"] assert get_wrapper("alias") == registered_commands["test"]
def test_command_help_embed(): register( category="Some Category", names=["test"], required_args=["one", "two"], optional_args=["three"], description= "A command that uses `<one>`, `<two>`, and `[three]` to do stuff.", example_args=["one two", "1 2 3", "\"o n e\" two three"])(None) embed1 = Command("test").help_embed() embed2 = help_embed("test") assert embed1.fields[0].name == embed2.fields[0].name assert embed1.fields[0].value == embed2.fields[0].value
def test_help_embed_custom_prefix(): register( category="Some Category", names=["test"], required_args=["one", "two"], optional_args=["three"], description= "A command that uses `<one>`, `<two>`, and `[three]` to do stuff.", example_args=["one two", "1 2 3", "\"o n e\" two three"])(None) embed = help_embed("test", prefix="&") assert embed.fields[0].name == "**`&test <one> <two> [three]`**" assert "A command that uses `<one>`, `<two>`, and `[three]` to do stuff." in embed.fields[ 0].value for example_args in ["one two", "1 2 3", "\"o n e\" two three"]: assert f"`&test {example_args}`" in embed.fields[1].value
def test_general_help_embed_custom_prefix(): registered_commands.clear() registered_categories.clear() register( category="A Test Category", names=["test", "alias"], required_args=["one", "two"], optional_args=["three"], description= "A command that uses `<one>`, `<two>`, and `[three]` to do stuff.", example_args=["one two", "1 2 3", "\"o n e\" two three"])(None) register(category="Other Test Category", names=["test2"])(None) embed = general_help_embed(prefix="&") assert "**`&test/&alias <one> <two> [three]`**" in embed.fields[0].value assert "**`&test2`**" in embed.fields[1].value
async def test_command_respond_err(): register( category="Some Category", names=["test"], required_args=["one", "two"], optional_args=["three"], description= "A command that uses `<one>`, `<two>`, and `[three]` to do stuff.", example_args=["one two", "1 2 3", "\"o n e\" two three"])(None) embed = help_embed("test") mock_channel = MockChannel() mock_message = MockMessage("+test 1 2 3", channel=mock_channel) command = Command("test", "1", "2", "3", context=mock_message) assert await command.respond_err("error") assert command.response == "✗ error" assert command.response_embed.fields[0].name == embed.fields[0].name assert command.response_embed.fields[0].value == embed.fields[0].value
def setup_module(): register(category=None, names=["test1", "test2", "test3"])(None)