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) p klass Commands.register_command klass end def self.for(ika, message) Commands.registered_commands.find do |command_class| command_class.matches? message.message.content 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