Class: Zephira::Completions::SlashCommands

Inherits:
Object
  • Object
show all
Defined in:
lib/zephira/completions/slash_commands.rb

Class Method Summary collapse

Class Method Details

.complete(input:, agent:) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/zephira/completions/slash_commands.rb', line 6

def self.complete(input:, agent:)
  return [] unless input.start_with?("/")

  prefix = input[1..] || ""
  agent.commands.constants
    .map(&:name)
    .grep(/\A#{Regexp.escape(prefix)}/)
    .map { |cmd| "/#{cmd}" }
end