DiscordInteractions.CommandRegistration (discord_interactions v0.1.0)

View Source

This module is responsible for registering both global and guild-specific commands with Discord.

Usage

Add the CommandRegistration task to your application's supervision tree:

def start(_type, _args) do
  children = [
    # Other children...
    YourAppWeb.Endpoint,
    {DiscordInteractions.CommandRegistration, YourApp.Discord}
  ]

  opts = [strategy: :one_for_one, name: YourApp.Supervisor]
  Supervisor.start_link(children, opts)
end

The task will automatically register all commands defined in your handler module when your application starts.

Summary

Functions

child_spec(arg)

Returns a specification to start this module under a supervisor.

arg is passed as the argument to Task.start_link/1 in the :start field of the spec.

For more information, see the Supervisor module, the Supervisor.child_spec/2 function and the Supervisor.child_spec/0 type.

register_all_guild_commands(guild_commands)

register_commands(handler)

register_global_commands(commands)

register_guild_command(client, guild_id, commands)

start_link(handler)