Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 26 additions & 23 deletions NetCord/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,42 +45,42 @@ public Application(JsonModels.JsonApplication jsonModel, RestClient client) : ba
}

/// <summary>
/// The ID of the application.
/// The application's ID..
/// </summary>
public override ulong Id => _jsonModel.Id;

/// <summary>
/// The name of the application.
/// The application's name.
/// </summary>
public string Name => _jsonModel.Name;

/// <summary>
/// The icon hash of the application.
/// The application's icon hash.
/// </summary>
public string? IconHash => _jsonModel.IconHash;

/// <summary>
/// The description of the application.
/// The application's description.
/// </summary>
public string Description => _jsonModel.Description;

/// <summary>
/// A list of the application's RPC origin URLs. <see langword="null"/> if RPC is disabled.
/// A list of the application's RPC origin URLs if enabled, otherwise <see langword="null"/>.
/// </summary>
public IReadOnlyList<string> RpcOrigins => _jsonModel.RpcOrigins;

/// <summary>
/// When <see langword="false"/>, only the application owner can add the application to guilds.
/// Whether users other than the owner can add the application to guilds.
/// </summary>
public bool? BotPublic => _jsonModel.BotPublic;

/// <summary>
/// When <see langword="true"/>, the application's bot will only join upon completion of the full OAuth2 code grant flow.
/// Whether the application's bot will only join upon completion of the full OAuth2 code grant flow.
/// </summary>
public bool? BotRequireCodeGrant => _jsonModel.BotRequireCodeGrant;

/// <summary>
/// The partial <see cref="User"/> object of the application's bot.
/// The application's user object, representing its bot.
/// </summary>
public User? Bot { get; }

Expand All @@ -95,42 +95,42 @@ public Application(JsonModels.JsonApplication jsonModel, RestClient client) : ba
public string? PrivacyPolicyUrl => _jsonModel.PrivacyPolicyUrl;

/// <summary>
/// The partial <see cref="User"/> object of the application's owner.
/// The application owner's user object.
/// </summary>
public User? Owner { get; }

/// <summary>
/// The hex-encoded verification key used for HTTP interactions and the GameSDK's GetTicket.
/// A hex-encoded verification key, used for HTTP interactions and the GameSDK's GetTicket endpoint.
/// </summary>
public string VerifyKey => _jsonModel.VerifyKey;

/// <summary>
/// The team the application belongs to. Is <see langword="null"/> if the application does not belong to a team.
/// The team the application belongs to, if any.
/// </summary>
public Team? Team { get; }

/// <summary>
/// The ID of the guild associated with the application. For example, a developer support server.
/// The ID corresponding to the application's guild.
/// </summary>
public ulong? GuildId => _jsonModel.GuildId;

/// <summary>
/// The partial <see cref="RestGuild"/> object of the application's associated guild.
/// The application guild's object.
/// </summary>
public RestGuild? Guild { get; }

/// <summary>
/// The ID of the Game SKU created, if one exists. Is <see langword="null"/> if the application is not a game sold on Discord.
/// The ID of the appliication's Game SKU if it exists, otherwise <see langword="null"/>.
/// </summary>
public ulong? PrimarySkuId => _jsonModel.PrimarySkuId;

/// <summary>
/// The URL slug that links to an application's store page. Is <see langword="null"/> if the application is not a game sold on Discord.
/// The URL slug that links to an application's store pageif it exists, otherwise <see langword="null"/>.
/// </summary>
public string? Slug => _jsonModel.Slug;

/// <summary>
/// The cover image hash of the application's default rich presence invite.
/// The cover image hash for the application's default rich presence invite.
/// </summary>
public string? CoverImageHash => _jsonModel.CoverImageHash;

Expand All @@ -150,7 +150,7 @@ public Application(JsonModels.JsonApplication jsonModel, RestClient client) : ba
public int? ApproximateUserInstallCount => _jsonModel.ApproximateUserInstallCount;

/// <summary>
/// The application's redirect URI list.
/// A list of the application's redirect URIs.
/// </summary>
public IReadOnlyList<string>? RedirectUris => _jsonModel.RedirectUris;

Expand All @@ -170,32 +170,35 @@ public Application(JsonModels.JsonApplication jsonModel, RestClient client) : ba
public string? EventWebhooksUrl => _jsonModel.EventWebhooksUrl;

/// <summary>
/// The application's event webhooks status.
/// The application's configuration for webhook events.
/// </summary>
public ApplicationEventWebhooksStatus EventWebhooksStatus => _jsonModel.EventWebhooksStatus;

/// <summary>
/// The list of event webhook types that the application supports.
/// A list of event webhook types that the application supports.
/// </summary>
public IReadOnlyList<string>? EventWebhooksTypes => _jsonModel.EventWebhooksTypes;

/// <summary>
/// The application's tag list, describing its content and functionality. Max of 5 tags.
/// A list of the application's tags, describing its content and functionality.
/// </summary>
/// <remarks>
/// A maximum of 5 tags is supported.
/// </remarks>
public IReadOnlyList<string>? Tags => _jsonModel.Tags;

/// <summary>
/// The application's default in-app authorization URL. Is <see langword="null"/> if disabled.
/// The application's default in-app authorization URL if enabled, otherwise <see langword="null"/>.
/// </summary>
public ApplicationInstallParams? InstallParams { get; }

/// <summary>
/// The default scopes and permissions for each supported installation context.
/// A list of the app's default scopes and permissions, for each supported installation context.
/// </summary>
public IReadOnlyDictionary<ApplicationIntegrationType, ApplicationIntegrationTypeConfiguration>? IntegrationTypesConfiguration { get; }

/// <summary>
/// The application's default custom install URL. Is <see langword="null"/> if disabled.
/// The application's default custom install URL if enabled, otherwise <see langword="null"/>.
/// </summary>
public string? CustomInstallUrl => _jsonModel.CustomInstallUrl;

Expand Down
3 changes: 3 additions & 0 deletions NetCord/ApplicationEventWebhooksStatus.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace NetCord;

/// <summary>
/// Specifies an application's configuration for webhook events.
/// </summary>
public enum ApplicationEventWebhooksStatus
{
/// <summary>
Expand Down
47 changes: 40 additions & 7 deletions NetCord/ApplicationFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,59 @@

namespace NetCord;

/// <summary>
/// Specifies the capabilities and status of an app.
/// </summary>
[Flags]
public enum ApplicationFlags : uint
{
/// <summary>
/// Undocumented.
/// Indicates if an embedded app is available to play.
/// </summary>
EmbeddedReleased = 1 << 1,

/// <summary>
/// Undocumented.
/// Indicates if an app has the ability to create twitch-style emoji.
/// </summary>
ManagedEmoji = 1 << 2,

/// <summary>
/// Undocumented.
/// Indicates that an embedded app has the ability to create in-app purchases.
/// </summary>
EmbeddedIAP = 1 << 3,
EmbeddedInAppPurchases = 1 << 3,

/// <summary>
/// Undocumented.
/// Indicates if an app has permission to create group DMs.
/// </summary>
GroupDMCreate = 1 << 4,

/// <summary>
/// Allows the application access the local RPC server.
/// </summary>
RpcPrivateBeta = 1 << 5,

/// <summary>
/// Indicates if an app uses the Auto Moderation API.
/// </summary>
ApplicationAutoModerationRuleCreateBadge = 1 << 6,

/// <summary>
/// Undocumented.
/// Indicates if an app is allowed to create activity assets.
/// </summary>
AllowAssets = 1 << 8,

/// <summary>
/// Indicates if an app is allowed to enable activity spectating.
/// </summary>
AllowActivityActionSpectate = 1 << 9,

/// <summary>
/// Indicates if an app is allowed to enable join requests for activities.
/// </summary>
AllowActivityActionJoinRequest = 1 << 10,

/// <summary>
/// Indiicates whether an app has ever accessed the local RPC server.
/// </summary>
RPCHasConnected = 1 << 11,

Expand Down Expand Up @@ -76,12 +99,22 @@ public enum ApplicationFlags : uint
GatewayMessageContentLimited = 1 << 19,

/// <summary>
/// Undocumented.
/// Indicates a first-party embedded app.
/// </summary>
EmbeddedFirstParty = 1 << 20,

/// <summary>
/// Indicates if an app has registered global application commands.
/// </summary>
ApplicationCommandBadge = 1 << 23,

/// <summary>
/// Indicates if an app is considered active.
/// </summary>
Active = 1 << 24,

/// <summary>
/// Indiciates if an app is allowed to use IFrame modals.
/// </summary>
IFrameModal = 1 << 26,
}
7 changes: 5 additions & 2 deletions NetCord/ApplicationInstallParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

namespace NetCord;

/// <summary>
/// Represents the configuration state for an application install.
/// </summary>
public class ApplicationInstallParams(JsonApplicationInstallParams jsonModel) : IJsonModel<JsonApplicationInstallParams>
{
JsonApplicationInstallParams IJsonModel<JsonApplicationInstallParams>.JsonModel => jsonModel;

/// <summary>
/// Scopes to add the application to the server with.
/// The scopes to use when installing the application to the guild.
/// </summary>
public IReadOnlyList<string> Scopes => jsonModel.Scopes;

/// <summary>
/// Permissions to request for the bot role.
/// The permissions to request for the application's bot role.
/// </summary>
public Permissions Permissions => jsonModel.Permissions;
}
7 changes: 5 additions & 2 deletions NetCord/ApplicationIntegrationType.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
namespace NetCord;

/// <summary>
/// Represents an app integration's install type.
/// </summary>
public enum ApplicationIntegrationType
{
/// <summary>
/// App is installable to servers.
/// App is available for guild installs.
/// </summary>
GuildInstall = 0,

/// <summary>
/// App is installable to users.
/// App is available for user installs.
/// </summary>
UserInstall = 1,
}
5 changes: 4 additions & 1 deletion NetCord/ApplicationIntegrationTypeConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace NetCord;

/// <summary>
/// Represents additional configuration for a specific app installation context.
/// </summary>
public class ApplicationIntegrationTypeConfiguration : IJsonModel<JsonApplicationIntegrationTypeConfiguration>
{
private readonly JsonApplicationIntegrationTypeConfiguration _jsonModel;
Expand All @@ -17,7 +20,7 @@ public ApplicationIntegrationTypeConfiguration(JsonApplicationIntegrationTypeCon
}

/// <summary>
/// Install params for each installation context's default in-app authorization link.
/// Additional installation params to apply to the specific install context.
/// </summary>
public ApplicationInstallParams? OAuth2InstallParams { get; }
}
29 changes: 21 additions & 8 deletions NetCord/Attachment.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using NetCord.Rest;

namespace NetCord;

/// <summary>
/// Represents a message attachment, and its contained data.
/// </summary>
public class Attachment(JsonModels.JsonAttachment jsonModel) : Entity, IJsonModel<JsonModels.JsonAttachment>
{
JsonModels.JsonAttachment IJsonModel<JsonModels.JsonAttachment>.JsonModel => _jsonModel;
Expand All @@ -8,37 +13,37 @@ public class Attachment(JsonModels.JsonAttachment jsonModel) : Entity, IJsonMode
public override ulong Id => _jsonModel.Id;

/// <summary>
/// Name of the attachment.
/// Name of the attachment (max 1024 characters for attachments sent by message, 2-30 characters for attachments used for sticker creation).
/// </summary>
public string FileName => _jsonModel.FileName;

/// <summary>
/// Title of the attachment.
/// The title of the attachment.
/// </summary>
public string? Title => _jsonModel.Title;

/// <summary>
/// Description for the attachment (max 1024 characters).
/// Description for the attachment (max 1024 characters for attachments sent by message, max 200 characters for attachments used for sticker creation).
/// </summary>
public string? Description => _jsonModel.Description;

/// <summary>
/// The attachment's media type.
/// The attachment's media (MIME) type.
/// </summary>
public string? ContentType => _jsonModel.ContentType;

/// <summary>
/// Size of file in bytes.
/// The attachment's size in bytes.
/// </summary>
public long Size => _jsonModel.Size;

/// <summary>
/// Source url of file.
/// The attachment's source URL.
/// </summary>
public string Url => _jsonModel.Url;

/// <summary>
/// A proxied url of file.
/// The attachment's source URL, proxied through Discord's CDN.
/// </summary>
public string ProxyUrl => _jsonModel.ProxyUrl;

Expand All @@ -47,16 +52,24 @@ public class Attachment(JsonModels.JsonAttachment jsonModel) : Entity, IJsonMode
/// </summary>
public bool Ephemeral => _jsonModel.Ephemeral;

/// <summary>
/// Additional information about the attachment's type.
/// </summary>
public AttachmentFlags Flags => _jsonModel.Flags;

/// <summary>
/// Returns expiration and issue info for the attachment's source URL.
/// </summary>
public AttachmentExpirationInfo GetExpirationInfo() => new(Url);

public static Attachment CreateFromJson(JsonModels.JsonAttachment jsonModel)
public static Attachment CreateFromJson(JsonModels.JsonAttachment jsonModel, RestClient client)
{
if (jsonModel.Width.HasValue)
return new ImageAttachment(jsonModel);
else if (jsonModel.DurationSeconds.HasValue)
return new VoiceAttachment(jsonModel);
else if (jsonModel.ClipCreatedAt.HasValue)
return new ClipAttachment(jsonModel, client);
else
return new Attachment(jsonModel);
}
Expand Down
Loading