Browse Source

add `nsfw` prop to command builders

pull/2531/head
Misha133 2 years ago
parent
commit
4f7324d384
3 changed files with 57 additions and 6 deletions
  1. +19
    -2
      src/Discord.Net.Core/Entities/Interactions/ContextMenus/MessageCommandBuilder.cs
  2. +19
    -2
      src/Discord.Net.Core/Entities/Interactions/ContextMenus/UserCommandBuilder.cs
  3. +19
    -2
      src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs

+ 19
- 2
src/Discord.Net.Core/Entities/Interactions/ContextMenus/MessageCommandBuilder.cs View File

@@ -46,6 +46,11 @@ namespace Discord
/// </summary>
public bool IsDMEnabled { get; set; } = true;

/// <summary>
/// Gets or sets whether or not this command is age restricted.
/// </summary>
public bool IsNsfw{ get; set; } = false;

/// <summary>
/// Gets or sets the default permission required to use this slash command.
/// </summary>
@@ -68,7 +73,8 @@ namespace Discord
IsDefaultPermission = IsDefaultPermission,
IsDMEnabled = IsDMEnabled,
DefaultMemberPermissions = DefaultMemberPermissions ?? Optional<GuildPermission>.Unspecified,
NameLocalizations = NameLocalizations
NameLocalizations = NameLocalizations,
IsNsfw = IsNsfw,
};

return props;
@@ -123,7 +129,7 @@ namespace Discord
}

/// <summary>
/// Sets whether or not this command can be used in dms
/// Sets whether or not this command can be used in dms.
/// </summary>
/// <param name="permission"><see langword="true"/> if the command is available in dms, otherwise <see langword="false"/>.</param>
/// <returns>The current builder.</returns>
@@ -133,6 +139,17 @@ namespace Discord
return this;
}

/// <summary>
/// Sets whether or not this command is age restricted.
/// </summary>
/// <param name="permission"><see langword="true"/> if the command is age restricted, otherwise <see langword="false"/>.</param>
/// <returns>The current builder.</returns>
public MessageCommandBuilder WithNsfw(bool permission)
{
IsNsfw = permission;
return this;
}

/// <summary>
/// Adds a new entry to the <see cref="NameLocalizations"/> collection.
/// </summary>


+ 19
- 2
src/Discord.Net.Core/Entities/Interactions/ContextMenus/UserCommandBuilder.cs View File

@@ -46,6 +46,11 @@ namespace Discord
/// </summary>
public bool IsDMEnabled { get; set; } = true;

/// <summary>
/// Gets or sets whether or not this command is age restricted.
/// </summary>
public bool IsNsfw { get; set; } = false;

/// <summary>
/// Gets or sets the default permission required to use this slash command.
/// </summary>
@@ -66,7 +71,8 @@ namespace Discord
IsDefaultPermission = IsDefaultPermission,
IsDMEnabled = IsDMEnabled,
DefaultMemberPermissions = DefaultMemberPermissions ?? Optional<GuildPermission>.Unspecified,
NameLocalizations = NameLocalizations
NameLocalizations = NameLocalizations,
IsNsfw = IsNsfw,
};

return props;
@@ -121,7 +127,7 @@ namespace Discord
}
/// <summary>
/// Sets whether or not this command can be used in dms
/// Sets whether or not this command can be used in dms.
/// </summary>
/// <param name="permission"><see langword="true"/> if the command is available in dms, otherwise <see langword="false"/>.</param>
/// <returns>The current builder.</returns>
@@ -131,6 +137,17 @@ namespace Discord
return this;
}

/// <summary>
/// Sets whether or not this command is age restricted.
/// </summary>
/// <param name="permission"><see langword="true"/> if the command is age restricted, otherwise <see langword="false"/>.</param>
/// <returns>The current builder.</returns>
public UserCommandBuilder WithNsfw(bool permission)
{
IsNsfw = permission;
return this;
}

/// <summary>
/// Adds a new entry to the <see cref="NameLocalizations"/> collection.
/// </summary>


+ 19
- 2
src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs View File

@@ -84,6 +84,11 @@ namespace Discord
/// Gets or sets whether or not this command can be used in DMs.
/// </summary>
public bool IsDMEnabled { get; set; } = true;
/// <summary>
/// Gets or sets whether or not this command is age restricted.
/// </summary>
public bool IsNsfw { get; set; } = false;

/// <summary>
/// Gets or sets the default permission required to use this slash command.
@@ -110,7 +115,8 @@ namespace Discord
NameLocalizations = _nameLocalizations,
DescriptionLocalizations = _descriptionLocalizations,
IsDMEnabled = IsDMEnabled,
DefaultMemberPermissions = DefaultMemberPermissions ?? Optional<GuildPermission>.Unspecified
DefaultMemberPermissions = DefaultMemberPermissions ?? Optional<GuildPermission>.Unspecified,
IsNsfw = IsNsfw,
};

if (Options != null && Options.Any())
@@ -161,7 +167,7 @@ namespace Discord
}

/// <summary>
/// Sets whether or not this command can be used in dms
/// Sets whether or not this command can be used in dms.
/// </summary>
/// <param name="permission"><see langword="true"/> if the command is available in dms, otherwise <see langword="false"/>.</param>
/// <returns>The current builder.</returns>
@@ -171,6 +177,17 @@ namespace Discord
return this;
}

/// <summary>
/// Sets whether or not this command is age restricted.
/// </summary>
/// <param name="permission"><see langword="true"/> if the command is age restricted, otherwise <see langword="false"/>.</param>
/// <returns>The current builder.</returns>
public SlashCommandBuilder WithNsfw(bool permission)
{
IsNsfw = permission;
return this;
}

/// <summary>
/// Sets the default member permissions required to use this application command.
/// </summary>


Loading…
Cancel
Save