Class: ESM::Command::My::Preferences
- Inherits:
-
ApplicationCommand
- Object
- Base
- ApplicationCommand
- ESM::Command::My::Preferences
- Defined in:
- lib/esm/command/my/preferences.rb
Constant Summary collapse
- TYPES =
%w[ all custom base_raid flag_stolen flag_restored flag_steal_started protection_money_due protection_money_paid grind_started hack_started charge_plant_started marxet_item_sold ].freeze
Instance Method Summary collapse
Instance Method Details
#on_execute ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/esm/command/my/preferences.rb', line 55 def on_execute return send_preferences if arguments.action.blank? # Creates an array of ["custom"] or ["base-raid", "flag-stolen", "flag-restored", etc...] types = if arguments.type == "all" # Remove "all" from the list TYPES.dup[1..] else [arguments.type] end # Converts the array of types to { custom: true }, or { "base-raid": false, "flag-stolen": false, "flag-restored": false, etc... } query = types.index_with { |type| allowed? } # Update the preference preference.update!(query) reply( ESM::Embed.build( :success, description: ":white_check_mark: Your preferences for `#{target_server.server_id}` have been updated" ) ) end |