Class: ESM::Command::Server::Player

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

Defined Under Namespace

Modules: V1

Instance Method Summary collapse

Instance Method Details

#on_executeObject



54
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
80
81
# File 'lib/esm/command/server/player.rb', line 54

def on_execute
  check_for_registered_target_user! if target_user.is_a?(ESM::User)

  result = call_sqf_function!(
    "ESMs_command_player",
    action: arguments.action,
    amount: arguments.amount
  ).data

  embed = ESM::Notification.build_random(
    community_id: target_community.id,
    type: arguments.action,
    category: "player",
    serverid: target_server.server_id,
    servername: target_server.server_name,
    communityid: target_community.community_id,
    username: current_user.username,
    usertag: current_user.mention,
    targetusername: target_user.username,
    targetusertag: target_user.mention,
    targetuid: target_uid,
    modifiedamount: result.modified_amount&.to_readable,
    previousamount: result.previous_amount&.to_readable,
    newamount: result.new_amount&.to_readable
  )

  reply(embed)
end