class Mod_RoleChooser < Vrobot4::Module::Module def self.type() "RoleChooser" end Vrobot4::Module.add_module_type self, server: "Discord" def initialize info super register :c_setcolor, "setcolor", "Sets your color." register :c_listcolors, "listcolors", "Lists available color roles." @info.map! {|id| id.resolve_id} end def c_setcolor m, argv roles = m.chan.real.server.roles role = roles.find {|r| r.name == argv} unless role and @info.any? {|id| role.id == id} raise ArgumentError, "Invalid color, use .listcolors for a list." end to_remove = roles.select {|r| @info.include? r.id and r != role} m.user.real.modify_roles role, to_remove end def c_listcolors m, argv text = "" for role in @info do text << m.chan.real.server.role(role).name + "\n" end m.reply text end end ## EOF