• Discord Rich Presence / Discord Authentication
    28 replies, posted
Discord Rich Presence / Discord Authentication This is a library to control a person's rich presence or authenticate a user. A fast and easy way to manager Discord Rich Presence / Discord Authentication. There is a Readme file in the bottom linked GitHub-Repo. Uses: Set User's Discord Rich Presence: https://files.facepunch.com/forum/upload/252266/18d2e8be-64e1-47fd-8870-281fa29800b8/Discord_2018-04-10_23-19-09.png This can be setup differently for each gamemode or state. Like so. local START_TIME = os.time() hook.Add( "Discord.GetActivity", "ADDON.UniqueName", sState ) if sState == "Default" then local tActivity = { details = "My Cool Server", state = GetHostName() .. " (" .. player.GetCount() .. " / " .. game.MaxPlayers() .. ")", timestamps = { start = START_TIME }, assets = { large_image = "your_cool_large_image", large_text = "Cool Large Image Hover Text", small_image = "your_cool_small_image", small_text = "Cool Small Image Hover Text" } } return tActivity end end ) If you like to change the current state you are able to call a hook to update it. hook.Run( "Discord.ChangeState", "YourNewState" ) Authentication for a user: With this hook you will start the authentication process. hook.Run( "Discord.Authorize" ) It will prompt you to discord and show this: https://files.facepunch.com/forum/upload/252266/b9a0c85c-af35-4007-ad1b-65f6f7210fd2/Discord_2018-04-10_23-22-04.png After clicking Authorize the server will handle the rest by itself and authorize over the discord api after that's done and no error occured this hook will be called: hook.Add( "Discord.UserAuthenticated", "ADDON.UniqueName", function( tData, pPlayer )         local discriminator = tData.discriminator         local id            = tData.id         local username      = tData.username         local avatar        = tData.avatar         local mfa_enabled   = tData.mfa_enabled         print( discriminator, id, username, avatar, mfa_enabled )         --> "7070", "280432211818184705", "Flixs", "0a1c8879bbdf7e97a319b4db0465ce8d", true end ) After this hook is called you can do whatever you want with the user. Be sure to read the full Readme to avoid any possible exploits. If you find any bugs or have any suggestions feel free to use the issue tracker on the repo! GitHub-Repo: https://github.com/7Flixs/glua_discord
If I want to display my server as the game users on my server are playing as, do I have to go through the process of authenticating or can I do it purely through the server with no client interaction? Cheers
Soo you just went and took my library and somewhat added hook support as well as a better API?
If you just want to display the server info in discord you don't need the authentications process. No while creating this libary i didn't took your libary to create mine, but yes I've apodted the idea. My goal with this libary is to have a dynamic, simple and fast libary to control the Discord Rich Presence or Authorize a user. While my Libary is created for custom Addons / Gamemodes, i think that your libary is more of a plug and go, where users can just load your libary and it's running. My aim is to have a libary that people can build their features ontop of it, and add their own ideas to it.
So the few similarities that I can notice are... https://github.com/7Flixs/glua_discord/blob/master/discord/sh_discord.lua#L95 and https://github.com/Tenrys/gmod_discordrpc/blob/master/lua/discordrpc/init.lua#L84 https://github.com/7Flixs/glua_discord/blob/master/discord/cl_discord.lua#L109 and https://github.com/Tenrys/gmod_discordrpc/blob/master/lua/discordrpc/init.lua#L38 Now to be fair on that last one the similarities are very minimal, restricted just to the basic logic. So I could potentially see where they used your library for a reference a few times, but with how few this occurs I don't think it happens enough to be a complete "rewrite".
To me, the points you noted are literal requirements to get the system to work. Both are utilising Discord's client endpoints and require the same logic to do so.
I'm launch localmachine server. I edit only discordrpc.debug 1 and discordrpc.clientID(default.lua, example.lua, init.lua).
Okay?
Hook does not want to run (error Discord nil)
These are separate addons.
This Libary is meant for developers to implement into their Addons / Gamemodes and customize it.
okay thx
You need to inlucde all 3 lua files or the reference will be nil.
init.lua and cl_init.lua https://files.facepunch.com/forum/upload/107063/aca40d4c-0209-44cf-a6e5-dcc40848febb/image.png https://files.facepunch.com/forum/upload/107063/6a6d98f6-188a-40bc-a233-c1fa13df5113/image.png
Did you set the CLIENT ID etc to your application from your bot? And also it's not recommended to add the call AddCSLuaFile on the server side file since the bot access token is saved in there, that one shouldn't be shared, only serverside.
https://files.facepunch.com/forum/upload/107063/4c081b5e-7d7c-49df-9b50-e296e60ef20a/image.png
You also have to update them in your libary files
you can upload video for install ? (For example: darkrp)
There is a documentation seen here: https://github.com/7Flixs/glua_discord/blob/master/README.md If you don't know how to code / implement this Libary i would suggest this one: Discord Rich Presence
Yes and launch hook Discord.Authorize (console error)
What is the error?
refresh in game https://files.facepunch.com/forum/upload/107063/2a490d7a-6a6a-4b44-b17c-5cd08faea2fc/image.png
No one is hear to spoon feed you. Please don't clog up the thread with this.
I think you should read read up these pages to get started first: hook.Run include AddCSLuaFile These explain how including files and and running a hook works, and also there is yet again there is a documentation for this, but it requires a understanding of glua. If you do not have that then the libary isn't for, you sorry.
great stuff!
I think you misunderstand the point of my post. I was debunking the whole thing.
Ah, understood - it is difficult to understand you sometimes
Even just this part: https://github.com/7Flixs/glua_discord/blob/master/discord/cl_discord.lua#L57 and this part https://github.com/Tenrys/gmod_discordrpc/blob/master/lua/discordrpc/main.lua#L8 are telling that you copied his code, where's the harm in just giving credit?
I never copied any code from @Tenrys 's libary, but as i don't want this unneeded drama anymore i will add him to the credits. And @Tenrys i hope that we can get along in the future since we have resolved this issue now too, my goal is not to cause any drama and i understand your concerns, but if you still feel like there is still an issue please let me know with a private message, that will be a better way to solve an issue like this in the future.
Sorry, you need to Log In to post a reply to this thread.