[RELEASE] gyni-discordroles | Retrieve User's Discord Roles

Discord Roles

Retrieve a user’s discord roles from a specific guild

How to use:

You have 3 exports:

  • GetUserRoles(source) Retrieves all the user’s roles into a Lua Table.
  • GetDiscordID(source) Retrieves the user’s discord id.
  • UserHasRole(source, role) Returns a boolean

Exports Example:

  • exports["resourcename"]:UserHasRole(source, role)
  • exports["resourcename"]:UserHasRole(source, roleid)
  • exports["resourcename"]:GetDiscordID(source)

NOTE: roleid is the discord role id.
To get it you must enable developer mode in discord advanced settings, then right click the role and copy id.

Configuration:

Config = {}

Config.BotToken = "" -- DISCORD BOT TOKEN
Config.GuildID = {  -- DISCORD SERVER IDs (GUILD IDs) FOR CHECKING
	"",
	""
}

Download latest release:

Release v1.1.0 · inGyni/gyni-discordroles · GitHub

Changelogs

v1.1.0 - 04/12/2022

  • Added support for multiple guilds checking.

This script is inspired from logan-mcgee release of discordroles which is written in JavaScript, and me not liking javascript, I decided to write my own version of it in Lua using the PerformHttpRequest method to send a GET request to the Discord API to Get Guild Member which returns a Guild Member Object.

1 Like

download link? realtime update or do I have to restart the server every time I assign role to someone?

Updated post with GitHub repo, real-time updates, of course.
The script sends a GET request to the discord API, so this should update instantly. (unless the Discord API is down)

Is it possible to put several Guild?

Like:

Config = {}

Config.BotToken = “XXXXXXXXXXXXXXXXXXX” – DISCORD BOT TOKEN
Config.GuildID = “xxxxxxxxxxx, xxxxxxxxxxx” – DISCORD SERVER ID (GUILD ID) FOR CHECKING

The code is made to only work on one guild.
What are you trying to achieve? Maybe there is another way.

Edit: This can be implemented, will update the repo once implemented.

Ok perfect, because I’m looking to put several guilds to use different discord to whitelist jobs

like
POLICE role with POLICE discord, EMS role with EMS discord etc…

I am working on it right now and will be done in a bit. Just a heads up, I am not going to add any error handling. This can be done on your side.

1 Like

Updated main post with latest release, good luck

1 Like

Thaaaanks :ok_hand: :raised_hands:t4:

1 Like