I'm not positive about syncing it to the website, but I know you can do it for Discord using their
API.
You would need some way to identify the player on your Discord, though, as people may use different names. The way I do it on my test server is have a channel where people will post their Steam IDs (rather, a bot finds it for them using the
Steam API), and periodically my script checks this channel's messages and looks for the ID (more information
here). When it's able to find that, it compares that to the player's SteamID in-game, and then uses the
Modify Guild Member call on them (which isn't completely supported at the moment because HTTP PATCH calls are currently unavailable on the main branch of gmod) to then edit their role.
Pseudo-code:
function findPlayer( ply )
-- Use the HTTP() function (http://wiki.garrysmod.com/page/Global/HTTP) to launch a
-- GET request to your server
HTTP( {
failed = function() end, -- do something on failure, maybe let the server know we failed?
success = function( cody, body, headers ) -- This is where we look through the messages
local data = body and util.JSONToTable( body ) -- Discord returns in JSON,
-- so we can access a table easily.
-- Loop through the data, looking for the "content" tag (data[ i ].content)
-- If we find it, copy their ID (data[ i ].author.id)
-- If not, do something?
end,
method = "GET", -- We're using an HTTP GET request, as specified by the
-- Discord documentation
url = "https://discordapp.com/api/channels/YOUR_CHANNEL_ID", -- You can find the channel's ID by right-clicking the channel on the left and Copy ID (you may need to turn on Developer tools in User Settings)
headers = {
Authorization = "Bot YOUR_BOTS_CLIENT_ID" -- Discord mandates an authorization key in many HTTP requests, and if you're bot is authorized on your server, you can use it's ID. Note: You DO need to keep the leading "Bot" in there.
}
} )
end
-- Now we actually set the person's role
function setRole( ply )
-- Now we want to use the HTTP() function, but with a PATCH request.
-- Keep in mind, PATCH is NOT integrated in the main build of gmod, so it will not work for the moment.
HTTP( {
failed = function() end,
success = function() end, -- Since we're not trying to do anything on our side, we can just notify the server if we succeed, or just do nothing.
method = "PATCH", -- Again, not implemented currently.
url = "https://discordapp.com/api/guilds/YOUR_GUILD_ID/members/THE_USERS_ID", -- The Guild ID can be found by right-clicking the server's name in the upper left and click Copy ID, and the user's ID was found earlier. You could return the user's ID in findPlayer() and set this to "https://discordapp.com/api/guilds/YOUR_GUILD_ID/members/" .. findPlayer( ply ) as well.
headers = {
Authorization = "Bot BOT_CLIENT_ID", -- Again, this is required.
roles = util.TableToJSON( {
-- Fill this with the IDs of the roles you want to give. This can be found by doing '\@role name' in Discord. You want to copy the numbers inside the brackets and paste them in here.
}
}
} )
end
So, basically, it is POSSIBLE, just until the next update (
says so) it is not, unless you use some third-party wrapper that allows PATCH requests.