inGyni
September 19, 2022, 7:16pm
1
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
iModyHK
September 19, 2022, 7:21pm
2
download link? realtime update or do I have to restart the server every time I assign role to someone?
inGyni
September 20, 2022, 8:06am
3
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
inGyni
December 4, 2022, 3:56pm
5
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…
inGyni
December 4, 2022, 6:01pm
7
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
inGyni
December 4, 2022, 6:57pm
8
Updated main post with latest release, good luck
1 Like