Class: ESM::Command::Community::Servers

Inherits:
ApplicationCommand show all
Defined in:
lib/esm/command/community/servers.rb

Instance Method Summary collapse

Instance Method Details

#on_executeObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/esm/command/community/servers.rb', line 25

def on_execute
  servers = ESM::Server.where(community_id: target_community.id, server_visibility: :public)
    .sort_by { |s| s.server_name.downcase }
    .sort { |s| s.connected? ? 0 : 1 }

  check_for_no_servers!(servers)

  servers.each do |server|
    reply(build_server_embed(server))
  end
end