@@ -0,0 +1,23 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord | |||
{ | |||
/// <summary> | |||
/// Represents public flags for an application. | |||
/// </summary> | |||
public enum ApplicationFlags | |||
{ | |||
GatewayPresence = 1 << 12, | |||
GatewayPresenceLimited = 1 << 13, | |||
GatewayGuildMembers = 1 << 14, | |||
GatewayGuildMembersLimited = 1 << 15, | |||
VerificationPendingGuildLimit = 1 << 16, | |||
Embedded = 1 << 17, | |||
GatewayMessageContent = 1 << 18, | |||
GatewayMessageContentLimited = 1 << 19 | |||
} | |||
} |
@@ -0,0 +1,31 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.Immutable; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord | |||
{ | |||
/// <summary> | |||
/// Represents install parameters for an application. | |||
/// </summary> | |||
public class ApplicationInstallParams | |||
{ | |||
/// <summary> | |||
/// Gets the scopes to install this application. | |||
/// </summary> | |||
public IReadOnlyCollection<string> Scopes { get; } | |||
/// <summary> | |||
/// Gets the default permissions to install this application | |||
/// </summary> | |||
public GuildPermission? Permission { get; } | |||
internal ApplicationInstallParams(string[] scopes, GuildPermission? permission) | |||
{ | |||
Scopes = scopes.ToImmutableArray(); | |||
Permission = permission; | |||
} | |||
} | |||
} |
@@ -1,3 +1,5 @@ | |||
using System.Collections.Generic; | |||
namespace Discord | |||
{ | |||
/// <summary> | |||
@@ -16,8 +18,16 @@ namespace Discord | |||
/// <summary> | |||
/// Gets the RPC origins of the application. | |||
/// </summary> | |||
string[] RPCOrigins { get; } | |||
ulong Flags { get; } | |||
IReadOnlyCollection<string> RPCOrigins { get; } | |||
ApplicationFlags Flags { get; } | |||
/// <summary> | |||
/// Gets a collection of install parameters for this application. | |||
/// </summary> | |||
ApplicationInstallParams InstallParams { get; } | |||
/// <summary> | |||
/// Gets a collection of tags related to the application. | |||
/// </summary> | |||
IReadOnlyCollection<string> Tags { get; } | |||
/// <summary> | |||
/// Gets the icon URL of the application. | |||
/// </summary> | |||
@@ -7,7 +7,7 @@ namespace Discord.API | |||
[JsonProperty("description")] | |||
public string Description { get; set; } | |||
[JsonProperty("rpc_origins")] | |||
public string[] RPCOrigins { get; set; } | |||
public Optional<string[]> RPCOrigins { get; set; } | |||
[JsonProperty("name")] | |||
public string Name { get; set; } | |||
[JsonProperty("id")] | |||
@@ -18,12 +18,16 @@ namespace Discord.API | |||
public bool IsBotPublic { get; set; } | |||
[JsonProperty("bot_require_code_grant")] | |||
public bool BotRequiresCodeGrant { get; set; } | |||
[JsonProperty("install_params")] | |||
public Optional<InstallParams> InstallParams { get; set; } | |||
[JsonProperty("team")] | |||
public Team Team { get; set; } | |||
[JsonProperty("flags"), Int53] | |||
public Optional<ulong> Flags { get; set; } | |||
public Optional<ApplicationFlags> Flags { get; set; } | |||
[JsonProperty("owner")] | |||
public Optional<User> Owner { get; set; } | |||
public Optional<string[]> Tags { get; set; } | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
using Newtonsoft.Json; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord.API | |||
{ | |||
internal class InstallParams | |||
{ | |||
[JsonProperty("scopes")] | |||
public string[] Scopes { get; set; } | |||
[JsonProperty("permissions")] | |||
public ulong Permission { get; set; } | |||
} | |||
} |
@@ -1,4 +1,6 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.Immutable; | |||
using System.Diagnostics; | |||
using System.Threading.Tasks; | |||
using Model = Discord.API.Application; | |||
@@ -18,9 +20,9 @@ namespace Discord.Rest | |||
/// <inheritdoc /> | |||
public string Description { get; private set; } | |||
/// <inheritdoc /> | |||
public string[] RPCOrigins { get; private set; } | |||
public IReadOnlyCollection<string> RPCOrigins { get; private set; } | |||
/// <inheritdoc /> | |||
public ulong Flags { get; private set; } | |||
public ApplicationFlags Flags { get; private set; } | |||
/// <inheritdoc /> | |||
public bool IsBotPublic { get; private set; } | |||
/// <inheritdoc /> | |||
@@ -36,6 +38,10 @@ namespace Discord.Rest | |||
/// <inheritdoc /> | |||
public string IconUrl => CDN.GetApplicationIconUrl(Id, _iconId); | |||
public ApplicationInstallParams InstallParams { get; private set; } | |||
public IReadOnlyCollection<string> Tags { get; private set; } | |||
internal RestApplication(BaseDiscordClient discord, ulong id) | |||
: base(discord, id) | |||
{ | |||
@@ -49,14 +55,17 @@ namespace Discord.Rest | |||
internal void Update(Model model) | |||
{ | |||
Description = model.Description; | |||
RPCOrigins = model.RPCOrigins; | |||
RPCOrigins = model.RPCOrigins.IsSpecified ? model.RPCOrigins.Value.ToImmutableArray() : ImmutableArray<string>.Empty; | |||
Name = model.Name; | |||
_iconId = model.Icon; | |||
IsBotPublic = model.IsBotPublic; | |||
BotRequiresCodeGrant = model.BotRequiresCodeGrant; | |||
Tags = model.Tags.GetValueOrDefault(null)?.ToImmutableArray() ?? ImmutableArray<string>.Empty; | |||
var installParams = model.InstallParams.GetValueOrDefault(null); | |||
InstallParams = new ApplicationInstallParams(installParams?.Scopes ?? new string[0], (GuildPermission?)installParams?.Permission ?? null); | |||
if (model.Flags.IsSpecified) | |||
Flags = model.Flags.Value; //TODO: Do we still need this? | |||
Flags = model.Flags.Value; | |||
if (model.Owner.IsSpecified) | |||
Owner = RestUser.Create(Discord, model.Owner.Value); | |||
if (model.Team != null) | |||