Class: Botiasloop::Commands::Help

Inherits:
Base
  • Object
show all
Defined in:
lib/botiasloop/commands/help.rb

Overview

Help command - displays available slash commands

Instance Method Summary collapse

Methods inherited from Base

command, description, inherited

Instance Method Details

#execute(context, _args = nil) ⇒ String

Execute the help command

Parameters:

  • context (Context)

    Execution context

  • _args (String, nil) (defaults to: nil)

    Unused arguments

Returns:

  • (String)

    Formatted list of commands



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/botiasloop/commands/help.rb', line 15

def execute(context, _args = nil)
  commands = Botiasloop::Commands.registry.all

  lines = ["**Available commands**"]

  commands.each do |cmd_class|
    name = cmd_class.command_name
    desc = cmd_class.description || "No description"
    lines << "/#{name} - #{desc}"
  end

  lines.join("\n")
end