@@ -83,6 +83,11 @@ namespace Discord | |||||
/// </summary> | /// </summary> | ||||
public Optional<bool> IsDMEnabled { get; set; } | public Optional<bool> IsDMEnabled { get; set; } | ||||
/// <summary> | |||||
/// Gets or sets whether or not this command is age restricted. | |||||
/// </summary> | |||||
public Optional<bool> IsNsfw { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// Gets or sets the default permissions required by a user to execute this application command. | /// Gets or sets the default permissions required by a user to execute this application command. | ||||
/// </summary> | /// </summary> | ||||
@@ -42,6 +42,11 @@ namespace Discord | |||||
/// </remarks> | /// </remarks> | ||||
bool IsEnabledInDm { get; } | bool IsEnabledInDm { get; } | ||||
/// <summary> | |||||
/// Indicates whether the command is age restricted. | |||||
/// </summary> | |||||
bool IsNsfw { get; } | |||||
/// <summary> | /// <summary> | ||||
/// Set of default <see cref="GuildPermission"/> required to invoke the command. | /// Set of default <see cref="GuildPermission"/> required to invoke the command. | ||||
/// </summary> | /// </summary> | ||||
@@ -44,5 +44,8 @@ namespace Discord.API | |||||
[JsonProperty("default_member_permissions")] | [JsonProperty("default_member_permissions")] | ||||
public Optional<GuildPermission?> DefaultMemberPermission { get; set; } | public Optional<GuildPermission?> DefaultMemberPermission { get; set; } | ||||
[JsonProperty("nsfw")] | |||||
public Optional<bool?> Nsfw { get; set; } | |||||
} | } | ||||
} | } |
@@ -35,9 +35,12 @@ namespace Discord.API.Rest | |||||
[JsonProperty("default_member_permissions")] | [JsonProperty("default_member_permissions")] | ||||
public Optional<GuildPermission?> DefaultMemberPermission { get; set; } | public Optional<GuildPermission?> DefaultMemberPermission { get; set; } | ||||
[JsonProperty("nsfw")] | |||||
public Optional<bool> Nsfw { get; set; } | |||||
public CreateApplicationCommandParams() { } | public CreateApplicationCommandParams() { } | ||||
public CreateApplicationCommandParams(string name, string description, ApplicationCommandType type, ApplicationCommandOption[] options = null, | public CreateApplicationCommandParams(string name, string description, ApplicationCommandType type, ApplicationCommandOption[] options = null, | ||||
IDictionary<string, string> nameLocalizations = null, IDictionary<string, string> descriptionLocalizations = null) | |||||
IDictionary<string, string> nameLocalizations = null, IDictionary<string, string> descriptionLocalizations = null, bool nsfw = false) | |||||
{ | { | ||||
Name = name; | Name = name; | ||||
Description = description; | Description = description; | ||||
@@ -45,6 +48,7 @@ namespace Discord.API.Rest | |||||
Type = type; | Type = type; | ||||
NameLocalizations = nameLocalizations?.ToDictionary(x => x.Key, x => x.Value) ?? Optional<Dictionary<string, string>>.Unspecified; | NameLocalizations = nameLocalizations?.ToDictionary(x => x.Key, x => x.Value) ?? Optional<Dictionary<string, string>>.Unspecified; | ||||
DescriptionLocalizations = descriptionLocalizations?.ToDictionary(x => x.Key, x => x.Value) ?? Optional<Dictionary<string, string>>.Unspecified; | DescriptionLocalizations = descriptionLocalizations?.ToDictionary(x => x.Key, x => x.Value) ?? Optional<Dictionary<string, string>>.Unspecified; | ||||
Nsfw = nsfw; | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -17,6 +17,12 @@ namespace Discord.API.Rest | |||||
[JsonProperty("default_permission")] | [JsonProperty("default_permission")] | ||||
public Optional<bool> DefaultPermission { get; set; } | public Optional<bool> DefaultPermission { get; set; } | ||||
[JsonProperty("nsfw")] | |||||
public Optional<bool> Nsfw { get; set; } | |||||
[JsonProperty("default_member_permissions")] | |||||
public Optional<GuildPermission?> DefaultMemberPermission { get; set; } | |||||
[JsonProperty("name_localizations")] | [JsonProperty("name_localizations")] | ||||
public Optional<Dictionary<string, string>> NameLocalizations { get; set; } | public Optional<Dictionary<string, string>> NameLocalizations { get; set; } | ||||
@@ -107,7 +107,8 @@ namespace Discord.Rest | |||||
// TODO: better conversion to nullable optionals | // TODO: better conversion to nullable optionals | ||||
DefaultMemberPermission = arg.DefaultMemberPermissions.ToNullable(), | DefaultMemberPermission = arg.DefaultMemberPermissions.ToNullable(), | ||||
DmPermission = arg.IsDMEnabled.ToNullable() | |||||
DmPermission = arg.IsDMEnabled.ToNullable(), | |||||
Nsfw = arg.IsNsfw.GetValueOrDefault(false), | |||||
}; | }; | ||||
if (arg is SlashCommandProperties slashProps) | if (arg is SlashCommandProperties slashProps) | ||||
@@ -147,8 +148,9 @@ namespace Discord.Rest | |||||
// TODO: better conversion to nullable optionals | // TODO: better conversion to nullable optionals | ||||
DefaultMemberPermission = arg.DefaultMemberPermissions.ToNullable(), | DefaultMemberPermission = arg.DefaultMemberPermissions.ToNullable(), | ||||
DmPermission = arg.IsDMEnabled.ToNullable() | |||||
}; | |||||
DmPermission = arg.IsDMEnabled.ToNullable(), | |||||
Nsfw = arg.IsNsfw.GetValueOrDefault(false) | |||||
}; | |||||
if (arg is SlashCommandProperties slashProps) | if (arg is SlashCommandProperties slashProps) | ||||
{ | { | ||||
@@ -190,7 +192,8 @@ namespace Discord.Rest | |||||
// TODO: better conversion to nullable optionals | // TODO: better conversion to nullable optionals | ||||
DefaultMemberPermission = arg.DefaultMemberPermissions.ToNullable(), | DefaultMemberPermission = arg.DefaultMemberPermissions.ToNullable(), | ||||
DmPermission = arg.IsDMEnabled.ToNullable() | |||||
DmPermission = arg.IsDMEnabled.ToNullable(), | |||||
Nsfw = arg.IsNsfw.GetValueOrDefault(false) | |||||
}; | }; | ||||
if (arg is SlashCommandProperties slashProps) | if (arg is SlashCommandProperties slashProps) | ||||
@@ -252,7 +255,9 @@ namespace Discord.Rest | |||||
? args.IsDefaultPermission.Value | ? args.IsDefaultPermission.Value | ||||
: Optional<bool>.Unspecified, | : Optional<bool>.Unspecified, | ||||
NameLocalizations = args.NameLocalizations?.ToDictionary(), | NameLocalizations = args.NameLocalizations?.ToDictionary(), | ||||
DescriptionLocalizations = args.DescriptionLocalizations?.ToDictionary() | |||||
DescriptionLocalizations = args.DescriptionLocalizations?.ToDictionary(), | |||||
Nsfw = args.IsNsfw.GetValueOrDefault(false), | |||||
DefaultMemberPermission = args.DefaultMemberPermissions.ToNullable() | |||||
}; | }; | ||||
if (args is SlashCommandProperties slashProps) | if (args is SlashCommandProperties slashProps) | ||||
@@ -312,7 +317,8 @@ namespace Discord.Rest | |||||
// TODO: better conversion to nullable optionals | // TODO: better conversion to nullable optionals | ||||
DefaultMemberPermission = arg.DefaultMemberPermissions.ToNullable(), | DefaultMemberPermission = arg.DefaultMemberPermissions.ToNullable(), | ||||
DmPermission = arg.IsDMEnabled.ToNullable() | |||||
DmPermission = arg.IsDMEnabled.ToNullable(), | |||||
Nsfw = arg.IsNsfw.GetValueOrDefault(false) | |||||
}; | }; | ||||
if (arg is SlashCommandProperties slashProps) | if (arg is SlashCommandProperties slashProps) | ||||
@@ -347,7 +353,9 @@ namespace Discord.Rest | |||||
? arg.IsDefaultPermission.Value | ? arg.IsDefaultPermission.Value | ||||
: Optional<bool>.Unspecified, | : Optional<bool>.Unspecified, | ||||
NameLocalizations = arg.NameLocalizations?.ToDictionary(), | NameLocalizations = arg.NameLocalizations?.ToDictionary(), | ||||
DescriptionLocalizations = arg.DescriptionLocalizations?.ToDictionary() | |||||
DescriptionLocalizations = arg.DescriptionLocalizations?.ToDictionary(), | |||||
Nsfw = arg.IsNsfw.GetValueOrDefault(false), | |||||
DefaultMemberPermission = arg.DefaultMemberPermissions.ToNullable() | |||||
}; | }; | ||||
if (arg is SlashCommandProperties slashProps) | if (arg is SlashCommandProperties slashProps) | ||||
@@ -30,6 +30,9 @@ namespace Discord.Rest | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public bool IsEnabledInDm { get; private set; } | public bool IsEnabledInDm { get; private set; } | ||||
/// <inheritdoc/> | |||||
public bool IsNsfw { get; private set; } | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public GuildPermissions DefaultMemberPermissions { get; private set; } | public GuildPermissions DefaultMemberPermissions { get; private set; } | ||||
@@ -101,6 +104,7 @@ namespace Discord.Rest | |||||
IsEnabledInDm = model.DmPermission.GetValueOrDefault(true).GetValueOrDefault(true); | IsEnabledInDm = model.DmPermission.GetValueOrDefault(true).GetValueOrDefault(true); | ||||
DefaultMemberPermissions = new GuildPermissions((ulong)model.DefaultMemberPermission.GetValueOrDefault(0).GetValueOrDefault(0)); | DefaultMemberPermissions = new GuildPermissions((ulong)model.DefaultMemberPermission.GetValueOrDefault(0).GetValueOrDefault(0)); | ||||
IsNsfw = model.Nsfw.GetValueOrDefault(false).GetValueOrDefault(false); | |||||
} | } | ||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
@@ -39,6 +39,9 @@ namespace Discord.WebSocket | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public bool IsEnabledInDm { get; private set; } | public bool IsEnabledInDm { get; private set; } | ||||
/// <inheritdoc/> | |||||
public bool IsNsfw { get; private set; } | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public GuildPermissions DefaultMemberPermissions { get; private set; } | public GuildPermissions DefaultMemberPermissions { get; private set; } | ||||
@@ -130,6 +133,7 @@ namespace Discord.WebSocket | |||||
IsEnabledInDm = model.DmPermission.GetValueOrDefault(true).GetValueOrDefault(true); | IsEnabledInDm = model.DmPermission.GetValueOrDefault(true).GetValueOrDefault(true); | ||||
DefaultMemberPermissions = new GuildPermissions((ulong)model.DefaultMemberPermission.GetValueOrDefault(0).GetValueOrDefault(0)); | DefaultMemberPermissions = new GuildPermissions((ulong)model.DefaultMemberPermission.GetValueOrDefault(0).GetValueOrDefault(0)); | ||||
IsNsfw = model.Nsfw.GetValueOrDefault(false).GetValueOrDefault(false); | |||||
} | } | ||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||