b1naryth1ef / dscord

Discord Library for D
http://b1naryth1ef.github.io/dscord/
zlib License
51 stars 15 forks source link

Gateway not working #20

Closed WebFreak001 closed 7 years ago

WebFreak001 commented 7 years ago

I tried changing the game with this very simple code:

auto client = new Client("<token>");
GatewayClient gw = client.gw;
gw.run();
gw.send(new StatusUpdate(0, new Game("game")));

But it crashes with

core.exception.AssertError@../../.dub/packages/vibe-d-0.7.30/vibe-d/source/vibe/http/websockets.d(401): null this
----------------
??:? _d_assert_msg [0xb0b585]
../../.dub/packages/vibe-d-0.7.30/vibe-d/source/vibe/http/websockets.d:401 void vibe.http.websockets.WebSocket.send(scope const(char)[]) [0xa330c5]
../../.dub/packages/dscord-0.0.9/dscord/src/dscord/gateway/client.d:128 void dscord.gateway.client.GatewayClient.send(dscord.gateway.packets.Serializable) [0x8c4edd]
../../.dub/packages/dscord-0.0.9/dscord/src/dscord/gateway/client.d:351 void dscord.gateway.client.GatewayClient.run() [0x8c5f3b]
source/app.d:14 _Dmain [0x8bdcc8]
??:? _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv [0xb11e56]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0xb11d9c]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() [0xb11e12]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0xb11d9c]
??:? _d_run_main [0xb11d16]
??:? main [0x8c0879]
??:? __libc_start_main [0x68b61290]
There were still 1 tasks running at exit.
Program exited with code 1

Am I using the gateway wrongly? The documentation says nothing about how to use it and there is no example.

whytro commented 7 years ago

You can update the game via the updateStatus method in client.

For example, in one of my plugins I have:

this.client.updateStatus(0, new Game("Dscord", "", GameType.DEFAULT));

This updates the status of the bot to "Playing Dscord".

WebFreak001 commented 7 years ago

same issue, but I'm not using a plugin because I don't want to make a bot. I want to modify my personal user's game. I got a token for it using the rpc.api scope in the OAuth request.

ZeroSumGame commented 7 years ago

I am not sure I understand what you're trying to say. You want to write third party software to log in on Discord as you and change the name of the game you're playing? I don't think this library is built to be able to log in as a real user (most of the behaviors people might use something like that for would get them banned from Discord). Obviously, it's something you could do, but it's unclear whether it's something you should do.

If all you're trying to do is have silly names in Discord for the games you're playing, you can already do that through the Discord client without using a bot library to do so. Just click the little cog in the lower left corner, click the Games subheading, and highlight to edit the name of the game you're running so it reads as something else.

b1naryth1ef commented 7 years ago

@ZeroSumGame is correct in stating that the library only supports bot accounts, and won't work for user accounts. That said throwing assertion errors with rando traces isn't the best way to make that clear. I'll add it to my backlog of things to clean up.

Additionally the OAuth2 API doesn't actually give you anything you can connect to the gateway with, the tokens there are only valid for OAuth2 HTTP API requests and for the RPC API.

@WebFreak001 for now if you want to use a user account, some other libs (discord.py, discord.js, etc) support this behavior.

WebFreak001 commented 7 years ago

@ZeroSumGame well it's not silly game names I want to have, it's automatically updating game names depending on where inside the game I am in. For example multiplayer matches or maps.

@b1naryth1ef discord.js actually doesn't work with the RPC API, there is discord-rpc but it's so broken, even the example in the README doesn't work (it just doesn't do anything without any output). Plus it has a browser version that for some reason has a different API than the node version.

b1naryth1ef commented 7 years ago

@WebFreak001 generally the way people do this is not through the RPC API, there aren't great libs for it right now (I think Discord.Net has the most complete implementation although), but instead run "selfbots" which are just bots running using the users token. Thats what I was referencing w/ the libs I mentioned above.

I think supporting the RPC API would be awesome, but not something I'm focusing on right away.