[Feature] Age restricted (NSFW) application commands support (#2531)
* add `nsfw` to data model & internal methods; add missing property * add `nsfw` prop to command builders * add `NsfwCommandAttribute` to Interaction Framework * working state * docs?
This commit is contained in:
@@ -25,6 +25,11 @@ namespace Discord.Interactions.Builders
|
||||
/// </summary>
|
||||
public bool IsEnabledInDm { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this command is age restricted.
|
||||
/// </summary>
|
||||
public bool IsNsfw { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default permissions needed for executing this command.
|
||||
/// </summary>
|
||||
@@ -95,6 +100,19 @@ namespace Discord.Interactions.Builders
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="IsNsfw"/>.
|
||||
/// </summary>
|
||||
/// <param name="isNsfw">New value of the <see cref="IsNsfw"/>.</param>
|
||||
/// <returns>
|
||||
/// The builder instance.
|
||||
/// </returns>
|
||||
public ContextCommandBuilder SetNsfw(bool isNsfw)
|
||||
{
|
||||
IsNsfw = isNsfw;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="DefaultMemberPermissions"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -25,6 +25,11 @@ namespace Discord.Interactions.Builders
|
||||
/// </summary>
|
||||
public bool IsEnabledInDm { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this command is age restricted.
|
||||
/// </summary>
|
||||
public bool IsNsfw { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default permissions needed for executing this command.
|
||||
/// </summary>
|
||||
@@ -95,6 +100,19 @@ namespace Discord.Interactions.Builders
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="IsNsfw"/>.
|
||||
/// </summary>
|
||||
/// <param name="isNsfw">New value of the <see cref="IsNsfw"/>.</param>
|
||||
/// <returns>
|
||||
/// The builder instance.
|
||||
/// </returns>
|
||||
public SlashCommandBuilder SetNsfw(bool isNsfw)
|
||||
{
|
||||
IsNsfw = isNsfw;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="DefaultMemberPermissions"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -59,6 +59,11 @@ namespace Discord.Interactions.Builders
|
||||
/// </summary>
|
||||
public bool IsEnabledInDm { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this command is age restricted.
|
||||
/// </summary>
|
||||
public bool IsNsfw { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default permissions needed for executing this command.
|
||||
/// </summary>
|
||||
@@ -190,6 +195,19 @@ namespace Discord.Interactions.Builders
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="IsNsfw"/>.
|
||||
/// </summary>
|
||||
/// <param name="isNsfw">New value of the <see cref="IsNsfw"/>.</param>
|
||||
/// <returns>
|
||||
/// The builder instance.
|
||||
/// </returns>
|
||||
public ModuleBuilder SetNsfw(bool isNsfw)
|
||||
{
|
||||
IsNsfw = isNsfw;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="DefaultMemberPermissions"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -101,6 +101,9 @@ namespace Discord.Interactions.Builders
|
||||
case DontAutoRegisterAttribute dontAutoRegister:
|
||||
builder.DontAutoRegister = true;
|
||||
break;
|
||||
case NsfwCommandAttribute nsfwCommand:
|
||||
builder.SetNsfw(nsfwCommand.IsNsfw);
|
||||
break;
|
||||
default:
|
||||
builder.AddAttributes(attribute);
|
||||
break;
|
||||
@@ -192,6 +195,9 @@ namespace Discord.Interactions.Builders
|
||||
case PreconditionAttribute precondition:
|
||||
builder.WithPreconditions(precondition);
|
||||
break;
|
||||
case NsfwCommandAttribute nsfwCommand:
|
||||
builder.SetNsfw(nsfwCommand.IsNsfw);
|
||||
break;
|
||||
default:
|
||||
builder.WithAttributes(attribute);
|
||||
break;
|
||||
@@ -244,6 +250,9 @@ namespace Discord.Interactions.Builders
|
||||
case PreconditionAttribute precondition:
|
||||
builder.WithPreconditions(precondition);
|
||||
break;
|
||||
case NsfwCommandAttribute nsfwCommand:
|
||||
builder.SetNsfw(nsfwCommand.IsNsfw);
|
||||
break;
|
||||
default:
|
||||
builder.WithAttributes(attribute);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user