[FR/EN][ESX] Discord bot alert

ESX Discord bot

FX Server Discord bot

Github

https://github.com/ElNelyo/esx_discord_bot

Description

This bot will send alert directly on your discord server , easy to install.

Requirements

esx_society
es_extended

Installation

1 .CD in your resources/[esx]folder

2.Clone the repository

https://github.com/ElNelyo/esx_discord_bot.git

3.Add " start esx_discord_bot " to your server.cfg

4.Create your Discord Bot

  1. Go to your server settings :
    display image

  2. Create webhooks (you can change image and name):
    display image

  3. Copy the webhook link

5.Edit config.lua from esx_discord_bot and paste your webhook link

6.Add these lines in esx_extended/server/main.lua

In RegisterServerEvent('esx:giveInventoryItem')

item_standart :

TriggerEvent("esx:giveitemalert",sourceXPlayer.name,targetXPlayer.name,ESX.Items[itemName].label,itemCount)

item_money:

TriggerEvent("esx:givemoneyalert",sourceXPlayer.name,targetXPlayer.name,itemCount)

item_account:

TriggerEvent("esx:givemoneybankalert",sourceXPlayer.name,targetXPlayer.name,itemCount)

item_weapon:

TriggerEvent("esx:giveweaponalert",sourceXPlayer.name,targetXPlayer.name,weaponLabel)

You should have something like this
display image

7.Add this line in esx_society/server/main.lua

In RegisterServerEvent('esx_society:washMoney')

TriggerEvent("esx:washingmoneyalert",xPlayer.name,amount)

You should have something like this
display image

Feature

Discord alert :

  • Kill
  • Enter in a police vehicle (exept for policeman)
  • Chat
  • Connecting / Disconnecting
  • Steal a vehicle
  • Giving Item / Money / Weapon
  • Blacklisted vehicle

Screenshot






13 Likes

its amazing very good work Nelyo !

2 Likes

Good Work For Es please…

Really Nice work!! Thanks for sharing!!

1 Like

Is this in English? If not how can we make it into English.

It’s strange, I have this but it doesn’t work :confused: :

RegisterServerEvent('esx:giveInventoryItem')
AddEventHandler('esx:giveInventoryItem', function(target, type, itemName, itemCount)

  local _source = source

  local sourceXPlayer = ESX.GetPlayerFromId(_source)
  local targetXPlayer = ESX.GetPlayerFromId(target)

  if type == 'item_standard' then

    local sourceItem    = sourceXPlayer.getInventoryItem(itemName)
    local targetItem    = targetXPlayer.getInventoryItem(itemName)
	

    if itemCount > 0 and sourceItem.count >= itemCount then

      if targetItem.limit ~= -1 and (targetItem.count + itemCount) > targetItem.limit then
        TriggerClientEvent('esx:showNotification', target, _U('ex_inv_lim') .. targetXPlayer.name)
      else
        sourceXPlayer.removeInventoryItem(itemName, itemCount)
        targetXPlayer.addInventoryItem   (itemName, itemCount)

        TriggerClientEvent('esx:showNotification', _source, _U('yougave') .. ' ~g~x' .. itemCount .. ' ' .. ESX.Items[itemName].label .. _U('to')   .. targetXPlayer.name)
        TriggerClientEvent('esx:showNotification', target,  _U('youreceived') .. ' ~g~x'  .. itemCount .. ' ' .. ESX.Items[itemName].label .. _U('by') .. sourceXPlayer.name)
		
		TriggerEvent("esx:giveitemalert",sourceXPlayer.name,targetXPlayer.name,ESX.Items[itemName].label,itemCount)
	  end

    else
      TriggerClientEvent('esx:showNotification', target, _U('imp_invalid_quantity'))
    end

  elseif type == 'item_money' then

    if itemCount > 0 and sourceXPlayer.player.get('money') >= itemCount then

      sourceXPlayer.removeMoney(itemCount)
      targetXPlayer.addMoney(itemCount)
	  
	  TriggerEvent("esx:givemoneyalert",sourceXPlayer.name,targetXPlayer.name,itemCount)
	  
      TriggerClientEvent('esx:showNotification', _source, _U('yougave') .. ' ~g~$' .. itemCount .. _U('to')   .. targetXPlayer.name)
      TriggerClientEvent('esx:showNotification', target,  _U('youreceived') .. ' ~g~$'  .. itemCount .. _U('by') .. sourceXPlayer.name)
      
	  TriggerEvent("esx:givemoneyalert",sourceXPlayer.name,targetXPlayer.name,itemCount)
    else
      TriggerClientEvent('esx:showNotification', target, _U('imp_invalid_amount'))
    end

  elseif type == 'item_account' then

    if itemCount > 0 and sourceXPlayer.getAccount(itemName).money >= itemCount then

      sourceXPlayer.removeAccountMoney(itemName, itemCount)
      targetXPlayer.addAccountMoney(itemName, itemCount)

      TriggerClientEvent('esx:showNotification', _source, _U('yougave') .. ' [' .. Config.AccountLabels[itemName] .. '] ~g~$' .. itemCount .. _U('to')   .. targetXPlayer.name)
      TriggerClientEvent('esx:showNotification', target,  _U('youreceived') .. ' ['  .. Config.AccountLabels[itemName] .. '] ~g~$' .. itemCount .. _U('by') .. sourceXPlayer.name)
		
	  TriggerEvent("esx:givemoneybankalert",sourceXPlayer.name,targetXPlayer.name,itemCount)

    else
      TriggerClientEvent('esx:showNotification', target, _U('imp_invalid_amount'))
    end

  elseif type == 'item_weapon' then

    sourceXPlayer.removeWeapon(itemName)
    targetXPlayer.addWeapon(itemName, itemCount)

    local weaponLabel = itemName

    for i=1, #Config.Weapons, 1 do
      if Config.Weapons[i].name == itemName then
        weaponLabel = Config.Weapons[i].label
        break
      end
    end

    TriggerClientEvent('esx:showNotification', _source, _U('yougave') .. ' x1 ~g~' .. weaponLabel .. _U('to')   .. targetXPlayer.name)
    TriggerClientEvent('esx:showNotification', target,  _U('youreceived')  .. ' x1 ~g~' .. weaponLabel .. _U('by') .. sourceXPlayer.name)
	
	TriggerEvent("esx:giveweaponalert",sourceXPlayer.name,targetXPlayer.name,weaponLabel)

  end

end)

Hello, your bot discord alert works for the server es? If yes, how ?

How can i add alert when someone buy weapons in wshop?

It’s not logging commands.

hey its not logging items? esx using es extended

Doesn’t log blacklisted vehicles

Is there a option to notify about using bossmenu, or putting someone in jail with a nickname of who used that?

Killing a player doesn’t work, it always show that the player died by : suicide or attack npc

1 Like

I just installed, everything works for player information and server status. Thanks for this script !:slight_smile:

However for money alert, gun nothing works. When I started the server after the saving files… the files reset… :open_mouth: Why :open_mouth:
Sorry for my english

Anyone able to get this working fof es_extended to get it to show the money etc?

For some reason it alerts for everything except when someone gets killed but amazing script and thanks for releasing

the hook is it within the “put your hook here” or is it without?? (newbie) :stuck_out_tongue:

Why carjack, police car and blacklisted vehicle alerts dont work

I cant get “esx:givedirtymoneyalert” work.

	elseif type == 'item_account' then

		if itemCount > 0 and sourceXPlayer.getAccount(itemName).money >= itemCount then

			sourceXPlayer.removeAccountMoney(itemName, itemCount)
			targetXPlayer.addAccountMoney   (itemName, itemCount)

			TriggerClientEvent('esx:showNotification', _source, _U('gave_account_money', ESX.Math.GroupDigits(itemCount), Config.AccountLabels[itemName], targetXPlayer.name))
			TriggerClientEvent('esx:showNotification', target,  _U('received_account_money', ESX.Math.GroupDigits(itemCount), Config.AccountLabels[itemName], sourceXPlayer.name))

			TriggerEvent("esx:givedirtymoneyalert",sourceXPlayer.name,targetXPlayer.name,itemCount) -- esx_discord_bot
		else
			TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_amount'))
		end

I added it correctly?

1 Like

easy exploit, don’t use it. webhook is stored clientside for god knows why; won’t post proof but jesus don’t use it.

1 Like