2025-08-15 17:03:12 -04:00
|
|
|
module Commands
|
|
|
|
@@commands = []
|
|
|
|
|
|
|
|
def self.register_command(command_class)
|
|
|
|
@@commands << command_class
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.registered_commands
|
|
|
|
@@commands
|
|
|
|
end
|
|
|
|
|
|
|
|
class Command
|
|
|
|
def self.inherited(klass)
|
|
|
|
Commands.register_command klass
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.for(ika, message)
|
|
|
|
Commands.registered_commands.find do |command_class|
|
2025-08-23 14:38:42 -04:00
|
|
|
command_class.matches? message.content
|
2025-08-15 17:03:12 -04:00
|
|
|
end&.new(ika, message)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.matches?(message_text)
|
|
|
|
message_text == "!#{command_string}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.help
|
|
|
|
"!#{command_string} - #{description}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.description
|
|
|
|
"blah blah blah"
|
|
|
|
end
|
|
|
|
|
|
|
|
attr_reader :ika, :message
|
|
|
|
|
|
|
|
def initialize(ika, message)
|
|
|
|
@ika = ika
|
|
|
|
@message = message
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
|
|
|
puts "This is a generic command! I can't execute anything!"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|