[Free] FiveM Guilded API Wrapper

FiveM Guilded API

FiveM Guilded API uses the recently released Guilded API to interact with your Guilded bots from within your FiveM server.

Installation Steps

Installation steps can be found in the README.md of the GitHub repository.

Documentation

Documentation can be found on the wiki: Home · gegelendvay/FiveM-Guilded-API Wiki · GitHub

Usage

Once you installed and set up the script, you can use its functions from other server-side scripts by calling exports.FiveM_Guilded_API:GetMember("abcdefgh") for example.

Contributions

If you have an update containing new and unused API endpoints or you have improvements you want to share, feel free to open a Pull Request and contribute to the project. Every contribution is much appreciated!

The API documentation can be found here: Guilded - Chat for Gaming Communities

Future Plans

I plan to integrate more and more endpoints into this script to have a broader functionality than it currently has. This is currently restricted by the available models, which I hope will get added to in the future by the Guilded team.

Since the API does not have a versioning scheme yet, issues may occur if response data get modified by the maintainers. I will try to keep up with the updates to mitigate these issues that may arise.

The integration of a Guilded connection for FiveM, similar to the one used on Discord, would significantly improve the functionality of the script, but sadly this is out of my scope.

Download

3 Likes

Rather than doing a repeat loop, you can use promises.

local function GuildedRequest(method, endpoint, data)

	local p = promise.new()

	PerformHttpRequest('https://www.guilded.gg/api/v1/'..endpoint, function(errorCode, resultData, resultHeaders)

		p:resolve({code = errorCode, data = resultData, headers = resultHeaders})

    end, method, #data > 0 and data or '', {['Authorization'] = 'Bearer '..Token, ['Accept'] = 'application/json', ['Content-Type'] = 'application/json'})

	return Citizen.Await(p)
	
end

Oh would it be possible to do GuildedAcePerms???

Hey, thanks for the contribution! Are there benefits of using promises over the current solution? If so, what kind? I haven’t used promises in LUA before, so I would appreciate your answer. Thanks

A Guilded role-based permission system is possible, however since FiveM doesn’t have a Guilded connection like Discord has, you would have to create a system for retrieving user ID and connecting it to a license yourself. Sadly, you cannot currently get Guilded IDs with GetPlayerIdentifiers().

I have pushed changes containing new return values and an IsRolePresent function to enable developers to create a basic permission system for their server.
Since currently there is no support for OAuth2 from Guilded, a connection like with Discord is not possible for the foreseeable future. More about it here:

A solution to this issue could be to create a system similar to what Transport Tycoon has: send a randomly generated code you get from in-game to your Guilded bot, which then connects your license to your Guilded ID, and stores it. If someone has the time and knowledge to create such a system, let me know!

Future updates will include examples that cover most of the available HTTP request methods as well as some interesting endpoints.