Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add help command #53

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/extensions/help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import hikari
import arc
import itertools

plugin = arc.GatewayPlugin(name="Help Command Plugin")


def gather_commands(client: arc.GatewayClient):
command_list = []
for command in itertools.chain(client.walk_commands(hikari.CommandType.SLASH)):
novanai marked this conversation as resolved.
Show resolved Hide resolved
command_list.append(
{
"name": command.name,
"description": command.description or "No description provided.",
}
)
return command_list


@plugin.include
@arc.slash_command("help", "Displays a list of all commands.")
async def help_command(ctx: arc.GatewayContext) -> None:
"""Displays a simple list of all bot commands."""

commands = gather_commands(ctx.client)
embed = hikari.Embed(title="Bot Commands", color=0x00FF00)

for command in commands:
novanai marked this conversation as resolved.
Show resolved Hide resolved
embed.add_field(
name=f"/{command['name']}", value=command["description"], inline=False
)

await ctx.respond(embed=embed)


@arc.loader
def load(client: arc.GatewayClient) -> None:
client.add_plugin(plugin)