Mudlet / Mudlet

⚔️ A cross-platform, open source, and super fast MUD client with scripting in Lua
https://mudlet.org
GNU General Public License v2.0
736 stars 268 forks source link

Retrieve Discord invite for mudlet server at later point #3914

Closed atari2600tim closed 3 years ago

atari2600tim commented 4 years ago

Brief summary of issue / Description of requested feature:

Shift around how mudlet::updateMudletDiscordInvite() gets called.

Steps to reproduce the issue / Reasons for adding feature:

  1. Launch mudlet
  2. Wait for I don't know how long, leave it open overnight I guess
  3. Try Discord button or menu option, it goes to expired invite.

Error output / Expected result of feature

It would bring you to a current invite.

Extra information, such as Mudlet version, operating system and ideas for how to solve / implement:

Currently, mudlet upon startup will request this widget.json file from the Discord API regarding the mudlet server, and then it looks at the JSON in there for instant_invite and grabs that URL. This is done by mudlet::updateMudletDiscordInvite() in src/mudlet.cpp. That is saved to a variable, and then for the rest of the session, if the Discord button or the menu option are used then they open up a web browser with that URL.

Instant invites can be valid for certain length of time, details at https://support.discord.com/hc/en-us/articles/208866998-Invites-101

I don't know enough about this widget.json file and the instant invite thing, like if it constantly rotates so that each day has a new invite, or whatever. I know it's not generated as the file is requested because it gives me the same invite URL if I load it from another computer hours later. The JSON file doesn't appear to say how long the invite is valid for or when it was first generated. Anyway, seems reasonable that if it refreshes once a day, and you request that data right before it refreshes, then you'd have an expired invite when you click it.

It might make sense to change the invite clicking part from simply loading the URL it found at program launch, and change it to instead do that request and then load the URL as 2 steps together, with the risk of a short delay as it retrieves it. I don't know what kind of other drawbacks there might be in doing it interactively instead of in the background like it is right now.

Xabre666 commented 4 years ago

Bear in mind that discord-rpc-api which is currently used has been labeled as depriciated by upstream developers in favour of new Dicord GameSDK, so it's quite questionable for how long will current implementation in Mudlet work at all. On top of it, Mudlet uses upstream discord-rpc-api code as is, just bundles the upstream lib, no changes whatsoever, therefor it seems to me that this issue is something that ought to be directed to upstream (where no help will come, since code is depreciated). Hope I'm wrong.

SlySven commented 4 years ago

Bear in mind that discord-rpc-api which is currently used has been labeled as depriciated by upstream developers in favour of new Dicord GameSDK, so it's quite questionable for how long will current implementation in Mudlet work at all. On top of it, Mudlet uses upstream discord-rpc-api code as is, just bundles the upstream lib, no changes whatsoever, therefor it seems to me that this issue is something that ought to be directed to upstream (where no help will come, since code is depreciated).

Well, Mudlet's inclusion of the Discord remote-procedure-call library is a separate issue to having an invite to the Mudlet Discord Guild.

I do not know much about the latter but I can speak about the former. it is available under a licence that is GPL compatible and thus can be included in the Mudlet package whereas the replacement (the Discord Games SDK) is proprietary and cannot. With the library being archived ( https://github.com/discord/discord-rpc/issues/290 ) it is now fixed and unchangeable - unless someone forks it and revises (or reverse engineers) it to connect to the Discord application (or applications as there are three current at any one time) via their own API. It is possible to re-compile the RPC library from the source code - but I found it hard to do and it had some dependencies that I found difficult to satisfy IIRC - on the other hand should a Mudlet user want to see the source code for the library it is there on https://github.com/discord/discord-rpc - so we should be able to meet our GPL obligations...

vadi2 commented 4 years ago

Thanks @atari2600tim, good catch. Yes, this has nothing to do with the discord-rpc library - this is related to the web API only.

The drawback would be that clicking the button isn't as instant as it was before, but that's an OK loss.

vadi2 commented 3 years ago

This this now.