Class: ESM::Command::Server::Reward

Inherits:
ApplicationCommand show all
Defined in:
lib/esm/command/server/reward.rb

Defined Under Namespace

Modules: V1

Instance Method Summary collapse

Instance Method Details

#on_executeObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/esm/command/server/reward.rb', line 25

def on_execute
  # Check for pending requests
  check_for_pending_request!

  # Check to see if the server has any rewards for the user before even sending the request
  check_for_reward_items!

  # Add the request
  add_request(
    to: current_user,
    description: I18n.t(
      "commands.reward_v1.request_description",
      user: current_user.mention,
      server: target_server.server_id
    )
  )

  # Remind them to check their PMs
  embed = ESM::Embed.build(
    :success,
    description: I18n.t("commands.request.check_pm", user: current_user.mention)
  )

  reply(embed)
end

#on_request_acceptedObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/esm/command/server/reward.rb', line 51

def on_request_accepted
  reward = target_server.server_reward

  response = call_sqf_function!(
    "ESMs_command_reward",
    items: reward.reward_items,
    locker: reward.locker_poptabs,
    money: reward.player_poptabs,
    respect: reward.respect
  )

  embed = embed_from_message!(response)
  reply(embed)
end