This will explain how to add a log to the ESX "giveitem" command
All edits will be made to es_extended/server/commands.lua
First we have to change the playerId arugment to return the playerId
Find this line:
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'},
And replace it with this:
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'playerId'},
The reason for doing this is that the ESX player object does not give you the target player's ID, but with that change, we can now get their playerId.
With that change, we also have to get the player object in order to give them an item.
Find this line:
args.playerId.addInventoryItem(args.item, args.count)
And replace it with this:
tPlayer = ESX.GetPlayerFromId(args.playerId)
This line gets the player object so we can do things like give them an item.
Now that we have the player object, we want to actually give them the item, so now below the previous line, add this
tPlayer.addInventoryItem(args.item, args.count)
Now to add the logs
Right below the previous line, add this
exports['JD_logs']:createLog({
EmbedMessage = GetPlayerName(xPlayer.source)..' gave '..GetPlayerName(args.playerId)..' **'..ESX.Math.GroupDigits(args.count)..' '..ESX.GetItemLabel(args.item)..'**',
player_id = xPlayer.source,
player_2_id = args.playerId,
color = '#000000',
channel = 'giveitem',
screenshot = false -- Set this to true if you want to screenshot the players screen
})
This line is sending the log to discord using JD_logs
And thats it
Final Result of the command:
ESX.RegisterCommand('giveitem', 'admin', function(xPlayer, args, showError)
tPlayer = ESX.GetPlayerFromId(args.playerId)
tPlayer.addInventoryItem(args.item, args.count)
exports['JD_logs']:createLog({
EmbedMessage = GetPlayerName(xPlayer.source)..' gave '..GetPlayerName(args.playerId)..' **'..ESX.Math.GroupDigits(args.count)..' '..ESX.GetItemLabel(args.item)..'**',
player_id = xPlayer.source,
player_2_id = args.playerId,
color = '#000000',
channel = 'giveitem',
screenshot = false -- Set this to true if you want to screenshot the players screen
})
end, true, {help = _U('command_giveitem'), validate = true, arguments = {
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'playerId'},
{name = 'item', help = _U('command_giveitem_item'), type = 'item'},
{name = 'count', help = _U('command_giveitem_count'), type = 'number'}
}})
Example log:

Make sure you set the channel argument (very last argument in the export) to a valid channel in JD_logs