Class: ESM::Command::Community::Mode

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

Instance Method Summary collapse

Instance Method Details

#on_executeObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/esm/command/community/mode.rb', line 34

def on_execute
  check_for_owner!

  enable_player_mode = !target_community.player_mode_enabled?
  check_for_active_servers! if enable_player_mode

  # Flip it, flip it good
  target_community.update!(player_mode_enabled: enable_player_mode)

  # Reply back
  embed =
    ESM::Embed.build do |e|
      e.description = I18n.t(
        "commands.mode.#{enable_player_mode ? "enabled" : "disabled"}",
        community_name: target_community.name
      )
      e.color = :green
    end

  reply(embed)
end