PsychoTea / Oxide.Ext.Discord

Discord extension and integration
https://umod.org/extensions/discord
12 stars 25 forks source link

Bans are being handled incorrectly #32

Closed Slydelix closed 6 years ago

Slydelix commented 6 years ago

Info: Discord_GuildBanAdd(User user) gets called but user is null

Where the mistake is located: WebSockets > SocketListener > method SocketMessage > switch payload.OpCode > case OpCodes.Dispatch > switch payload.EventName > case GUILD_BAN_ADD & GUILD_BAN_REMOVE

Solution: both ban add and ban remove are getting user with payload.EventData.ToObject<User>(); but the content of payload.EventData is "user": { "username": "username", "id": "someIDhere", "discriminator": "discriminatorHere", "avatar": null }, "guild_id": "guildIdHere"

Solution is simple, add a new DiscordObject and deserialize the payload.EventData into it, the class would have to look like this class BanObject { public User user { get; set; } public string guild_id { get; set; } }

and then finally, user would be supplied like this User bannedUser = payload.EventData.ToObject<BanObject>().user;

PsychoTea commented 6 years ago

Is this fixed now? If so, please close this issue :)

Slydelix commented 6 years ago

It is 👍