Hi! So I was wondering how I could communicate FiveM with my Discord bot and vice versa. I want to do this for Discord Account linking, bans, and other stuff.
If you have any ideas or any resources, please let me know of them!
There are Discord libraries for most programming languages, including Lua, which should be easier to use than dealing with raw HTTP requests and responses, but I’m not sure whether there would be any challenges using them within a FiveM resource.
I use a webhook for sending messages from in-game to Discord, specifically because a webhook has the ability to use a different name per message. That way, I can use the name of the player in-game for the name on the message on Discord. From what I understand, Bots are more like actual users, in that if you change the name of a bot, the change will affect all of the previous messages sent by that bot as well, which wouldn’t work for me.
For sending messages from Discord to the in-game chat, I use the REST API to interact with a bot. For example, I get a list of messages sent to a channel that the bot is in with https://discord.com/developers/docs/resources/channel#get-channel-messages, and then send those messages as chat messages in-game.
Not via a Discord webhook. A Discord webhook can only receive information from outside Discord and post it in a Discord channel. You can with the Discord REST API, though.