[Release] FiveM To Discord

From the OP:

–> [1.5.2] is currently buggy, please use [1.5.1] instead-

Perhaps roll back to .1?

ok i will try 1.5.1 instead of .2

its still not working

Hey Jelly, can you add me on discord and help me out with my bot? I’m having difficulties with it and I’m new to all of this

I have the webhooks in there, but nothing is logging please help me!!

Contact me on discord

L.Watkins#0118

is this right?

{
{’/ooc’, ‘[Ude af charecter]:’},
{’/tweet’, ‘[Twitter!]:’},
{’/me’, ‘[Mig]:’},
{’/ad’, ‘[Salgsannouncer]:’},
{’/911’, ‘[911]: (CALLER ID: [ USERNAME_NEEDED_HERE | USERID_NEEDED_HERE ])’},
}

is there a way to create log who is giving someone money or weapon?

the ever helpful fivem community as always thanks for the help on your wonky ass resource

this has been working perfectly for me. The guy did say to use 1.5.1, not 1.5.2. He left plenty of instructions to get it working. this is not a “wonky ass resource” you just have no clue what you are doing if you can’t install this. Don’t be rude on someone else’s work unless you want them to shit all over your work as well. Now with that said, if you want some actual help getting it to work, you can message me on here or discord (which is xrxextxrxox#0489)

1 Like

why my in game chat (/me and /ooc) doesn´t show in logs? any idea?

I downloaded this, added it to my server, added the webhook links, started it, started my server but it never said “FiveM Server Webhook Started”. Why?

Same…

check if you add the webhook in chat

1 Like

It doesnt work with esx_rpchat. Does anyone know how to fix it???

i fixed it to work with esx_rpchat and it shows almost any chat command in Discord now so yes its possible to use that but you have to do some editing in esx_rpchat server/main.lua ( i haven’t been lucky with admin commands tho :thinking: )

can you share a little on how you did that?

Yes please could you share!?

i deleted all content in client/main.lua then i edited this in server/main.lua:
( dont delete client/main.lua file just delete the old code )

function getIdentity(source)
	local identifier = GetPlayerIdentifiers(source)[1]
	local result = MySQL.Sync.fetchAll("SELECT * FROM users WHERE identifier = @identifier", {['@identifier'] = identifier})
	if result[1] ~= nil then
		local identity = result[1]

		return {
			identifier = identity['identifier'],
			firstname = identity['firstname'],
			lastname = identity['lastname'],
			dateofbirth = identity['dateofbirth'],
			sex = identity['sex'],
			height = identity['height']
		}
	else
		return nil
	end
end

AddEventHandler('chatMessage', function(source, name, message)
    if string.sub(message,1,string.len("/"))=="/" then
        
    else
    local name = getIdentity(source)
        TriggerClientEvent("sendProximityMessage", -1, source, name.firstname, message)
    end
    CancelEvent()
end)

--------------------OOC
AddEventHandler('chatMessage', function(source, name, msg)
  sm = stringsplit(msg, " ");
  if sm[1] == "/ooc" then
    CancelEvent()
    TriggerClientEvent('chatMessage', -1, "^1 OOC ^0| " .. name .. " |", { 128, 128, 128 }, string.sub(msg,5))
  end
end)


--------------------BRB
AddEventHandler('chatMessage', function(source, name, msg)
  if msg:sub(1, 1) == "/" then
    sm = stringsplit(msg, " ");
     if sm[1] == "/brb" then
      local identity = getIdentity(source)
         CancelEvent()
  TriggerClientEvent('chatMessage', -1, "^8Poissa ^0| " .. name, {255, 255, 255}, string.sub(msg,5))

     end
  end
end)


--------------------BACK
AddEventHandler('chatMessage', function(source, name, msg)
  if msg:sub(1, 1) == "/" then
    sm = stringsplit(msg, " ");
     if sm[1] == "/back" then
      local identity = getIdentity(source)
         CancelEvent()
  TriggerClientEvent('chatMessage', -1, "^2Paikalla ^0| " .. name, {255, 255, 255}, string.sub(msg,6))
     end
  end
end)


--------------------ANO
AddEventHandler('chatMessage', function(source, name, msg)
  if msg:sub(1, 1) == "/" then
    sm = stringsplit(msg, " ");
     if sm[1] == "/ano" then
      local identity = getIdentity(source)
         CancelEvent()
  TriggerClientEvent('chatMessage', -1, "^0[^4Twitter^0]^0(^4@Anonyymi^0)^4", {255, 255, 255}, string.sub(msg,6))
     end
  end
end)


--------------------Me
AddEventHandler('chatMessage', function(source, name, msg)
  if msg:sub(1, 1) == "/" then
    sm = stringsplit(msg, " ");
     if sm[1] == "/medo" then
      local identity = getIdentity(source)
         CancelEvent()
 TriggerClientEvent('chatMessage', -1, "^9 " .. identity.firstname .. " " .. identity.lastname .."", {255, 255, 255}, string.sub(msg,6))
     end
  end
end)


--------------------TWT
AddEventHandler('chatMessage', function(source, name, msg)
  if msg:sub(1, 1) == "/" then
    sm = stringsplit(msg, " ");
     if sm[1] == "/twt" then
      local identity = getIdentity(source)
         CancelEvent()
  TriggerClientEvent('chatMessage', -1, "^0[^4Twitter^0]^0(^4@" .. identity.firstname .. " " .. identity.lastname .."^0)^4 ", {255, 255, 255}, string.sub(msg,6))
     end
  end
end)


--------------------NEWS
AddEventHandler('chatMessage', function(source, name, msg)
  if msg:sub(1, 1) == "/" then
    sm = stringsplit(msg, " ");
     if sm[1] == "/news" then
      local identity = getIdentity(source)
         CancelEvent()
  TriggerClientEvent('chatMessage', -1, "^0[^3UUTISET^0]", {255, 255, 255}, string.sub(msg,6))
     end
  end
end)


--------------------DEEP
AddEventHandler('chatMessage', function(source, name, msg)
  if msg:sub(1, 1) == "/" then
    sm = stringsplit(msg, " ");
     if sm[1] == "/deep" then
      local identity = getIdentity(source)
         CancelEvent()
  TriggerClientEvent('chatMessage', -1, "^9[Deep chat]^0", {255, 255, 255}, string.sub(msg,6))
     end
  end
end)


--------------------DARK
AddEventHandler('chatMessage', function(source, name, msg)
  if msg:sub(1, 1) == "/" then
    sm = stringsplit(msg, " ");
     if sm[1] == "/dark" then
      local identity = getIdentity(source)
         CancelEvent()
  TriggerClientEvent('chatMessage', -1, "^1[Dark chat]^0", {255, 255, 255}, string.sub(msg,6))
     end
  end
end)


--------------------AD
AddEventHandler('chatMessage', function(source, name, msg)
  if msg:sub(1, 1) == "/" then
    sm = stringsplit(msg, " ");
     if sm[1] == "/ad" then
      local identity = getIdentity(source)
         CancelEvent()
  TriggerClientEvent('chatMessage', -1, "[^4Mainos^0]", {255, 255, 255}, string.sub(msg,6))
     end
  end
end)


--------------------LOST MC
AddEventHandler('chatMessage', function(source, name, msg)
  if msg:sub(1, 1) == "/" then
    sm = stringsplit(msg, " ");
     if sm[1] == "/lost" then
      local identity = getIdentity(source)
         CancelEvent()
  TriggerClientEvent('chatMessage', -1, "^0[^4Twitter^0] ^0(^4@The_Lost_MC^0)^4", {255, 255, 255}, string.sub(msg,6))
     end
  end
end)

--------------------LSPD
AddEventHandler('chatMessage', function(source, name, msg)
  if msg:sub(1, 1) == "/" then
    sm = stringsplit(msg, " ");
     if sm[1] == "/LSPD" then
      local identity = getIdentity(source)
         CancelEvent()
  TriggerClientEvent('chatMessage', -1, "^0[^4Twitter^0] ^0(^4@LSPD^0) " .. identity.firstname .. " " .. identity.lastname .."", {255, 255, 255}, string.sub(msg,6))
     end
  end
end)


--------------------LSSD
AddEventHandler('chatMessage', function(source, name, msg)
  if msg:sub(1, 1) == "/" then
    sm = stringsplit(msg, " ");
     if sm[1] == "/LSSD" then
      local identity = getIdentity(source)
         CancelEvent()
  TriggerClientEvent('chatMessage', -1, "^0[^4Twitter^0] ^0(^4@LSSD^0) " .. identity.firstname .. " " .. identity.lastname .."", {255, 255, 255}, string.sub(msg,6))
     end
  end
end)


function stringsplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end

function makeArgs(cmd)
    args = {}
    for i = 2, #cmd, 1 do
        table.insert(args, cmd[i])
    end
    return args
end

after this it works if you have setup DiscordBot correctly :yum:

This is Admin command for esx_rpchat but it needs AddEventHandler and ‘chatMessage’ to work with DiscordBot and i have tried many things to get those work too but still nothing :frowning:

--------------------OWNER
TriggerEvent('es:addGroupCommand', 'god', "superadmin", function(source, args, user)
 	TriggerClientEvent('chat:addMessage', -1, {
 		args = {"^4Owner^0 [" .. GetPlayerName(source) .. "^0]^4 " .. table.concat(args, " ")}
 	})
 end, function(source, args, user)
 	TriggerClientEvent('chat:addMessage', source, { args = {"^1SYSTEM", "Insufficienct permissions!"} })
 end, {help = "Owner viesti [Owners name]", params = {{name = "announcement", help = "The message to announce"}}})

Or to fix RP_Chat use 1.5.1 and do this under each RegisterCommand as using the old way of commands is just dumb:

RegisterCommand('twt', function(source, args, rawCommand)
	if source == 0 then
		print('esx_rpchat: you can\'t use this command from rcon!')
		return
	end

	args = table.concat(args, ' ')
	local name = GetPlayerName(source)
	local steam = GetPlayerName(source)
	if Config.EnableESXIdentity then name = GetCharacterName(source) end

	TriggerClientEvent('chat:addMessage', -1, { args = { _U('twt_prefix', name), args }, color = { 0, 153, 204 } })
	TriggerEvent('DiscordBot:ToDiscord', 'chat', steam,'[Server 1]  ' .. '**TWITTER: **' .. args, 'logoimageurl', true)
	--print(('%s: %s'):format(name, args))
end, false)

The main part you are adding is this:

TriggerEvent('DiscordBot:ToDiscord', 'chat', steam,'[Server 1]  ' .. '**TWITTER: **' .. args, 'logoimageurl', true)

In my case I want to use their steam name in case of needed discipline so I did it sloppy and added another locale:

local steam = GetPlayerName(source)

Rinse and repeat for each command you put in there