Skip to content

Commit

Permalink
Added support for GUILD_JOIN_REQUEST_DELETE event (discord-net#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamWelsh authored Oct 23, 2021
1 parent a20118a commit dd3214d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Newtonsoft.Json;

namespace Discord.API.Gateway
{
internal class GuildJoinRequestDeleteEvent
{
[JsonProperty("user_id")]
public ulong UserId { get; set; }
[JsonProperty("guild_id")]
public ulong GuildId { get; set; }
}
}
7 changes: 7 additions & 0 deletions src/Discord.Net.WebSocket/BaseSocketClient.Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,13 @@ public event Func<SocketGuild, SocketGuild, Task> GuildUpdated
remove { _guildUpdatedEvent.Remove(value); }
}
internal readonly AsyncEvent<Func<SocketGuild, SocketGuild, Task>> _guildUpdatedEvent = new AsyncEvent<Func<SocketGuild, SocketGuild, Task>>();
/// <summary>Fired when a user leaves without agreeing to the member screening </summary>
public event Func<ulong, ulong, Task> GuildJoinRequestDeleted
{
add { _guildJoinRequestDeletedEvent.Add(value); }
remove { _guildJoinRequestDeletedEvent.Remove(value); }
}
internal readonly AsyncEvent<Func<ulong, ulong, Task>> _guildJoinRequestDeletedEvent = new AsyncEvent<Func<ulong, ulong, Task>>();
#endregion

#region Users
Expand Down
1 change: 1 addition & 0 deletions src/Discord.Net.WebSocket/DiscordShardedClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ private void RegisterEvents(DiscordSocketClient client, bool isPrimary)
client.GuildStickerCreated += (sticker) => _guildStickerCreated.InvokeAsync(sticker);
client.GuildStickerDeleted += (sticker) => _guildStickerDeleted.InvokeAsync(sticker);
client.GuildStickerUpdated += (before, after) => _guildStickerUpdated.InvokeAsync(before, after);
client.GuildJoinRequestDeleted += (userId, guildId) => _guildJoinRequestDeletedEvent.InvokeAsync(userId, guildId);
}
#endregion

Expand Down
8 changes: 8 additions & 0 deletions src/Discord.Net.WebSocket/DiscordSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,14 @@ private async Task ProcessMessageAsync(GatewayOpCode opCode, int? seq, string ty
}
}
break;
case "GUILD_JOIN_REQUEST_DELETE":
{
await _gatewayLogger.DebugAsync("Received Dispatch (GUILD_JOIN_REQUEST_DELETE)").ConfigureAwait(false);

var data = (payload as JToken).ToObject<GuildJoinRequestDeleteEvent>(_serializer);
await TimedInvokeAsync(_guildJoinRequestDeletedEvent, nameof(GuildJoinRequestDeleted), data.UserId, data.GuildId).ConfigureAwait(false);
}
break;
#endregion

#region Channels
Expand Down

0 comments on commit dd3214d

Please sign in to comment.