Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions NetCord/Gateway/EventArgs/GuildJoinRequestDeleteEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace NetCord.Gateway;

public class GuildJoinRequestDeleteEventArgs(JsonModels.EventArgs.JsonGuildJoinRequestDeleteEventArgs jsonModel) : IJsonModel<JsonModels.EventArgs.JsonGuildJoinRequestDeleteEventArgs>
{
JsonModels.EventArgs.JsonGuildJoinRequestDeleteEventArgs IJsonModel<JsonModels.EventArgs.JsonGuildJoinRequestDeleteEventArgs>.JsonModel => jsonModel;

public ulong JoinRequestId => jsonModel.Id;

public ulong UserId => jsonModel.UserId;

public ulong GuildId => jsonModel.GuildId;
}
14 changes: 14 additions & 0 deletions NetCord/Gateway/EventArgs/GuildJoinRequestUpdateEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using NetCord.Rest;

namespace NetCord.Gateway;

public class GuildJoinRequestUpdateEventArgs(JsonModels.EventArgs.JsonGuildJoinRequestUpdateEventArgs jsonModel, RestClient client) : IJsonModel<JsonModels.EventArgs.JsonGuildJoinRequestUpdateEventArgs>
{
JsonModels.EventArgs.JsonGuildJoinRequestUpdateEventArgs IJsonModel<JsonModels.EventArgs.JsonGuildJoinRequestUpdateEventArgs>.JsonModel => jsonModel;

public GuildJoinRequestStatus Status => jsonModel.Status;

public GuildJoinRequest Request { get; } = new(jsonModel.Request, client);

public ulong GuildId => jsonModel.GuildId;
}
12 changes: 12 additions & 0 deletions NetCord/Gateway/GatewayClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public partial class GatewayClient : WebSocketClient, IEntity
public event Func<Entitlement, ValueTask>? EntitlementUpdate;
public event Func<Entitlement, ValueTask>? EntitlementDelete;
public event Func<UnknownEventEventArgs, ValueTask>? UnknownEvent;
public event Func<GuildJoinRequestUpdateEventArgs, ValueTask>? GuildJoinRequestUpdate;
public event Func<GuildJoinRequestDeleteEventArgs, ValueTask>? GuildJoinRequestDelete;
Comment thread
KubaZ2 marked this conversation as resolved.

/// <summary>
/// The token of the <see cref="GatewayClient"/>.
Expand Down Expand Up @@ -717,6 +719,16 @@ await InvokeEventAsync(
await InvokeEventAsync(EntitlementDelete, () => new(data.ToObject(Serialization.Default.JsonEntitlement))).ConfigureAwait(false);
}
break;
case "GUILD_JOIN_REQUEST_UPDATE":
{
await InvokeEventAsync(GuildJoinRequestUpdate, () => new(data.ToObject(Serialization.Default.JsonGuildJoinRequestUpdateEventArgs), Rest)).ConfigureAwait(false);
}
break;
case "GUILD_JOIN_REQUEST_DELETE":
{
await InvokeEventAsync(GuildJoinRequestDelete, () => new(data.ToObject(Serialization.Default.JsonGuildJoinRequestDeleteEventArgs))).ConfigureAwait(false);
}
break;
default:
{
await InvokeEventAsync(UnknownEvent, () => new(name, data)).ConfigureAwait(false);
Expand Down
25 changes: 25 additions & 0 deletions NetCord/Gateway/GuildJoinRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using NetCord.Rest;

namespace NetCord.Gateway;
Comment thread
KubaZ2 marked this conversation as resolved.
public class GuildJoinRequest : IJsonModel<JsonModels.JsonGuildJoinRequest>
{
private readonly JsonModels.JsonGuildJoinRequest _jsonModel;
JsonModels.JsonGuildJoinRequest IJsonModel<JsonModels.JsonGuildJoinRequest>.JsonModel => _jsonModel;
Comment thread
KubaZ2 marked this conversation as resolved.
Outdated
public GuildJoinRequestStatus ApplicationStatus => _jsonModel.ApplicationStatus;
public DateTimeOffset? CreatedAt => _jsonModel.CreatedAt;
public ulong GuildId => _jsonModel.GuildId;
public DateTimeOffset LastSeen => _jsonModel.LastSeen;
Comment thread
KubaZ2 marked this conversation as resolved.
Outdated
public string? RejectionReason => _jsonModel.RejectionReason;
public ulong UserId => _jsonModel.UserId;
public User User { get; }
public IReadOnlyList<VerificationField> FormResponses { get; }
public User ActionedByUser { get; }
public ulong ActionedAt => _jsonModel.ActionedAt;
Comment thread
KubaZ2 marked this conversation as resolved.
Outdated
public GuildJoinRequest(JsonModels.JsonGuildJoinRequest jsonModel, RestClient client)
{
_jsonModel = jsonModel;
User = new User(jsonModel.User, client);
ActionedByUser = new User(jsonModel.ActionedByUser, client);
FormResponses = _jsonModel.FormResponses.Select(e => new VerificationField(e)).ToList();
Comment thread
KubaZ2 marked this conversation as resolved.
Outdated
}
Comment thread
KubaZ2 marked this conversation as resolved.
Outdated
}
15 changes: 15 additions & 0 deletions NetCord/Gateway/GuildJoinRequestStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Text.Json.Serialization;

namespace NetCord.Gateway;
Comment thread
KubaZ2 marked this conversation as resolved.
[JsonConverter(typeof(JsonConverters.StringEnumConverterWithErrorHandling<GuildJoinRequestStatus>))]
public enum GuildJoinRequestStatus
{
[JsonPropertyName("STARTED")]
Started,
[JsonPropertyName("PENDING")]
Pending,
[JsonPropertyName("REJECTED")]
Rejected,
[JsonPropertyName("APPROVED")]
Approved
Comment thread
KubaZ2 marked this conversation as resolved.
Outdated
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Text.Json.Serialization;

namespace NetCord.Gateway.JsonModels.EventArgs;

public class JsonGuildJoinRequestDeleteEventArgs
{
[JsonPropertyName("id")]
public ulong Id { get; set; }
[JsonPropertyName("user_id")]
public ulong UserId { get; set; }
[JsonPropertyName("guild_id")]
Comment thread
KubaZ2 marked this conversation as resolved.
Outdated
public ulong GuildId { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Text.Json.Serialization;

namespace NetCord.Gateway.JsonModels.EventArgs;

public class JsonGuildJoinRequestUpdateEventArgs
{
[JsonPropertyName("status")]
public GuildJoinRequestStatus Status { get; set; }
[JsonPropertyName("request")]
public JsonGuildJoinRequest Request { get; set; }
[JsonPropertyName("guild_id")]
public ulong GuildId { get; set; }
}
37 changes: 37 additions & 0 deletions NetCord/Gateway/JsonModels/JsonGuildJoinRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Text.Json.Serialization;

using NetCord.JsonModels;

namespace NetCord.Gateway.JsonModels;
Comment thread
KubaZ2 marked this conversation as resolved.
public class JsonGuildJoinRequest : JsonEntity
{
[JsonPropertyName("application_status")]
public GuildJoinRequestStatus ApplicationStatus { get; set; }

[JsonPropertyName("created_at")]
public DateTimeOffset CreatedAt { get; set; }

[JsonPropertyName("guild_id")]
public ulong GuildId { get; set; }

[JsonPropertyName("last_seen")]
public DateTimeOffset LastSeen { get; set; }
Comment thread
KubaZ2 marked this conversation as resolved.
Outdated

[JsonPropertyName("rejection_reason")]
public string? RejectionReason { get; set; }

[JsonPropertyName("user_id")]
public ulong UserId { get; set; }

[JsonPropertyName("user")]
public JsonUser User { get; set; }

[JsonPropertyName("form_responses")]
public IReadOnlyList<JsonVerificationField> FormResponses { get; set; }

[JsonPropertyName("actioned_by_user")]
public JsonUser ActionedByUser { get; set; }

[JsonPropertyName("actioned_at")]
public ulong ActionedAt { get; set; }
}
20 changes: 20 additions & 0 deletions NetCord/Gateway/JsonModels/JsonVerificationField.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Text.Json.Serialization;

namespace NetCord.Gateway.JsonModels;
Comment thread
KubaZ2 marked this conversation as resolved.
public partial class JsonVerificationField
{
[JsonPropertyName("field_type")]
public VerificationFieldType FieldType { get; set; }

[JsonPropertyName("label")]
public string Label { get; set; }

[JsonPropertyName("required")]
public bool Required { get; set; }

[JsonPropertyName("response")]
public bool Response { get; set; }

[JsonPropertyName("values")]
public IReadOnlyList<string> Values { get; set; }
}
12 changes: 12 additions & 0 deletions NetCord/Gateway/VerificationField.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace NetCord.Gateway;

public class VerificationField(JsonModels.JsonVerificationField jsonModel) : IJsonModel<JsonModels.JsonVerificationField>
{
private readonly JsonModels.JsonVerificationField _jsonModel = jsonModel;
JsonModels.JsonVerificationField IJsonModel<JsonModels.JsonVerificationField>.JsonModel => _jsonModel;
public VerificationFieldType FieldType => _jsonModel.FieldType;
public string Label => _jsonModel.Label;
public bool Required => _jsonModel.Required;
public bool IsResponse => _jsonModel.Response;
public IReadOnlyList<string> Values => _jsonModel.Values;
Comment thread
KubaZ2 marked this conversation as resolved.
Outdated
}
19 changes: 19 additions & 0 deletions NetCord/Gateway/VerificationFieldType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Text.Json.Serialization;

namespace NetCord.Gateway;
Comment thread
KubaZ2 marked this conversation as resolved.
[JsonConverter(typeof(JsonConverters.StringEnumConverterWithErrorHandling<VerificationFieldType>))]
public enum VerificationFieldType
{
[JsonPropertyName("TERMS")]
Terms,
[JsonPropertyName("TEXT_INPUT")]
TextInput,
[JsonPropertyName("PARAGRAPH")]
Paragraph,
[JsonPropertyName("MULTIPLE_CHOICE")]
MultipleChoise,
Comment thread
KubaZ2 marked this conversation as resolved.
Outdated
[JsonPropertyName("VERIFICATION")]
Verification,
[JsonPropertyName("FILE_UPLOAD")]
FileUpload
Comment thread
KubaZ2 marked this conversation as resolved.
Outdated
}
6 changes: 6 additions & 0 deletions NetCord/Serialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ namespace NetCord;
[JsonSerializable(typeof(GuildUsersSearchTimestamp))]
[JsonSerializable(typeof(JsonGuildUserSearchResult))]
[JsonSerializable(typeof(GuildUsersSearchPaginationProperties))]
[JsonSerializable(typeof(IReadOnlyList<string>))]
[JsonSerializable(typeof(JsonVerificationField))]
[JsonSerializable(typeof(IReadOnlyList<JsonVerificationField>))]
[JsonSerializable(typeof(JsonGuildJoinRequest))]
Comment thread
KubaZ2 marked this conversation as resolved.
Outdated
[JsonSerializable(typeof(JsonGuildJoinRequestUpdateEventArgs))]
[JsonSerializable(typeof(JsonGuildJoinRequestDeleteEventArgs))]
internal partial class Serialization : JsonSerializerContext
{
}