Browse Source

Create stage channels

pull/1923/head
quin lynch 3 years ago
parent
commit
3cd351f2bf
5 changed files with 120 additions and 23 deletions
  1. +50
    -23
      src/Discord.Net.Core/Discord.Net.Core.xml
  2. +11
    -0
      src/Discord.Net.Core/Entities/Guilds/IGuild.cs
  3. +28
    -0
      src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
  4. +15
    -0
      src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
  5. +16
    -0
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs

+ 50
- 23
src/Discord.Net.Core/Discord.Net.Core.xml View File

@@ -4524,6 +4524,9 @@
<member name="P:Discord.ApplicationCommandOptionChoiceProperties.Value">
<summary>
The value of this choice.
<note type="warning">
Discord only accepts int and string as the input.
</note>
</summary>
</member>
<member name="T:Discord.ApplicationCommandOptionType">
@@ -4591,6 +4594,11 @@
Gets or sets the name of this command.
</summary>
</member>
<member name="P:Discord.ApplicationCommandProperties.DefaultPermission">
<summary>
Whether the command is enabled by default when the app is added to a guild. Default is <see langword="true"/>
</summary>
</member>
<member name="T:Discord.ApplicationCommandType">
<summary>
ApplicationCommandType is enum of current valid Application Command Types: Slash, User, Message
@@ -4626,6 +4634,11 @@
The name of this Message command.
</summary>
</member>
<member name="P:Discord.MessageCommandBuilder.DefaultPermission">
<summary>
Whether the command is enabled by default when the app is added to a guild
</summary>
</member>
<member name="M:Discord.MessageCommandBuilder.Build">
<summary>
Build the current builder into a <see cref="T:Discord.MessageCommandProperties"/> class.
@@ -4643,6 +4656,13 @@
The current builder.
</returns>
</member>
<member name="M:Discord.MessageCommandBuilder.WithDefaultPermission(System.Boolean)">
<summary>
Sets the default permission of the current command.
</summary>
<param name="value">The default permission value to set.</param>
<returns>The current builder.</returns>
</member>
<member name="T:Discord.MessageCommandProperties">
<summary>
A class used to create message commands.
@@ -4663,6 +4683,11 @@
The name of this User command.
</summary>
</member>
<member name="P:Discord.UserCommandBuilder.DefaultPermission">
<summary>
Whether the command is enabled by default when the app is added to a guild
</summary>
</member>
<member name="M:Discord.UserCommandBuilder.Build">
<summary>
Build the current builder into a <see cref="T:Discord.UserCommandProperties"/> class.
@@ -4678,6 +4703,13 @@
The current builder.
</returns>
</member>
<member name="M:Discord.UserCommandBuilder.WithDefaultPermission(System.Boolean)">
<summary>
Sets the default permission of the current command.
</summary>
<param name="value">The default permission value to set.</param>
<returns>The current builder.</returns>
</member>
<member name="T:Discord.UserCommandProperties">
<summary>
A class used to create User commands.
@@ -5379,22 +5411,22 @@
</member>
<member name="T:Discord.SelectMenuBuilder">
<summary>
Represents a class used to build <see cref="T:Discord.SelectMenu"/>'s.
Represents a class used to build <see cref="T:Discord.SelectMenuComponent"/>'s.
</summary>
</member>
<member name="F:Discord.SelectMenuBuilder.MaxPlaceholderLength">
<summary>
The max length of a <see cref="P:Discord.SelectMenu.Placeholder"/>.
The max length of a <see cref="P:Discord.SelectMenuComponent.Placeholder"/>.
</summary>
</member>
<member name="F:Discord.SelectMenuBuilder.MaxValuesCount">
<summary>
The maximum number of values for the <see cref="P:Discord.SelectMenu.MinValues"/> and <see cref="P:Discord.SelectMenu.MaxValues"/> properties.
The maximum number of values for the <see cref="P:Discord.SelectMenuComponent.MinValues"/> and <see cref="P:Discord.SelectMenuComponent.MaxValues"/> properties.
</summary>
</member>
<member name="F:Discord.SelectMenuBuilder.MaxOptionCount">
<summary>
The maximum number of options a <see cref="T:Discord.SelectMenu"/> can have.
The maximum number of options a <see cref="T:Discord.SelectMenuComponent"/> can have.
</summary>
</member>
<member name="P:Discord.SelectMenuBuilder.CustomId">
@@ -5438,9 +5470,9 @@
Creates a new instance of a <see cref="T:Discord.SelectMenuBuilder"/>.
</summary>
</member>
<member name="M:Discord.SelectMenuBuilder.#ctor(Discord.SelectMenu)">
<member name="M:Discord.SelectMenuBuilder.#ctor(Discord.SelectMenuComponent)">
<summary>
Creates a new instance of a <see cref="T:Discord.SelectMenuBuilder"/> from instance of <see cref="T:Discord.SelectMenu"/>.
Creates a new instance of a <see cref="T:Discord.SelectMenuBuilder"/> from instance of <see cref="T:Discord.SelectMenuComponent"/>.
</summary>
</member>
<member name="M:Discord.SelectMenuBuilder.#ctor(System.String,System.Collections.Generic.List{Discord.SelectMenuOptionBuilder},System.String,System.Int32,System.Int32,System.Boolean)">
@@ -5539,9 +5571,9 @@
</member>
<member name="M:Discord.SelectMenuBuilder.Build">
<summary>
Builds a <see cref="T:Discord.SelectMenu"/>
Builds a <see cref="T:Discord.SelectMenuComponent"/>
</summary>
<returns>The newly built <see cref="T:Discord.SelectMenu"/></returns>
<returns>The newly built <see cref="T:Discord.SelectMenuComponent"/></returns>
</member>
<member name="T:Discord.SelectMenuOptionBuilder">
<summary>
@@ -5715,45 +5747,45 @@
Returns a empty <see cref="T:Discord.MessageComponent"/>.
</summary>
</member>
<member name="T:Discord.SelectMenu">
<member name="T:Discord.SelectMenuComponent">
<summary>
Represents a select menu component defined at <see href="https://discord.com/developers/docs/interactions/message-components#select-menu-object"/>
</summary>
</member>
<member name="P:Discord.SelectMenu.Type">
<member name="P:Discord.SelectMenuComponent.Type">
<inheritdoc/>
</member>
<member name="P:Discord.SelectMenu.CustomId">
<member name="P:Discord.SelectMenuComponent.CustomId">
<summary>
The custom id of this Select menu that will be sent with a <see cref="T:Discord.IDiscordInteraction"/>.
</summary>
</member>
<member name="P:Discord.SelectMenu.Options">
<member name="P:Discord.SelectMenuComponent.Options">
<summary>
The menus options to select from.
</summary>
</member>
<member name="P:Discord.SelectMenu.Placeholder">
<member name="P:Discord.SelectMenuComponent.Placeholder">
<summary>
A custom placeholder text if nothing is selected, max 100 characters.
</summary>
</member>
<member name="P:Discord.SelectMenu.MinValues">
<member name="P:Discord.SelectMenuComponent.MinValues">
<summary>
The minimum number of items that must be chosen; default 1, min 0, max 25
</summary>
</member>
<member name="P:Discord.SelectMenu.MaxValues">
<member name="P:Discord.SelectMenuComponent.MaxValues">
<summary>
The maximum number of items that can be chosen; default 1, max 25
</summary>
</member>
<member name="P:Discord.SelectMenu.Disabled">
<member name="P:Discord.SelectMenuComponent.Disabled">
<summary>
Whether this menu is disabled or not.
</summary>
</member>
<member name="M:Discord.SelectMenu.ToBuilder">
<member name="M:Discord.SelectMenuComponent.ToBuilder">
<summary>
Turns this select menu into a builder.
</summary>
@@ -5763,7 +5795,7 @@
</member>
<member name="T:Discord.SelectMenuOption">
<summary>
Represents a choice for a <see cref="T:Discord.SelectMenu"/>.
Represents a choice for a <see cref="T:Discord.SelectMenuComponent"/>.
</summary>
</member>
<member name="P:Discord.SelectMenuOption.Label">
@@ -6038,11 +6070,6 @@
Gets or sets the options for this command.
</summary>
</member>
<member name="P:Discord.SlashCommandProperties.DefaultPermission">
<summary>
Whether the command is enabled by default when the app is added to a guild. Default is <see langword="true"/>
</summary>
</member>
<member name="T:Discord.IInvite">
<summary>
Represents a generic invite object.


+ 11
- 0
src/Discord.Net.Core/Entities/Guilds/IGuild.cs View File

@@ -667,6 +667,17 @@ namespace Discord
/// </returns>
Task<IVoiceChannel> CreateVoiceChannelAsync(string name, Action<VoiceChannelProperties> func = null, RequestOptions options = null);
/// <summary>
/// Creates a new stage channel in this guild.
/// </summary>
/// <param name="name">The new name for the stage channel.</param>
/// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous creation operation. The task result contains the newly created
/// stage channel.
/// </returns>
Task<IStageChannel> CreateStageChannelAsync(string name, Action<VoiceChannelProperties> func = null, RequestOptions options = null);
/// <summary>
/// Creates a new channel category in this guild.
/// </summary>
/// <param name="name">The new name for the category.</param>


+ 28
- 0
src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs View File

@@ -221,6 +221,34 @@ namespace Discord.Rest
var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false);
return RestVoiceChannel.Create(client, guild, model);
}
public static async Task<RestStageChannel> CreateStageChannelAsync(IGuild guild, BaseDiscordClient client,
string name, RequestOptions options, Action<VoiceChannelProperties> func = null)
{
if (name == null)
throw new ArgumentNullException(paramName: nameof(name));

var props = new VoiceChannelProperties();
func?.Invoke(props);

var args = new CreateGuildChannelParams(name, ChannelType.Stage)
{
CategoryId = props.CategoryId,
Bitrate = props.Bitrate,
UserLimit = props.UserLimit,
Position = props.Position,
Overwrites = props.PermissionOverwrites.IsSpecified
? props.PermissionOverwrites.Value.Select(overwrite => new API.Overwrite
{
TargetId = overwrite.TargetId,
TargetType = overwrite.TargetType,
Allow = overwrite.Permissions.AllowValue.ToString(),
Deny = overwrite.Permissions.DenyValue.ToString()
}).ToArray()
: Optional.Create<API.Overwrite[]>(),
};
var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false);
return RestStageChannel.Create(client, guild, model);
}
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception>
public static async Task<RestCategoryChannel> CreateCategoryChannelAsync(IGuild guild, BaseDiscordClient client,
string name, RequestOptions options, Action<GuildChannelProperties> func = null)


+ 15
- 0
src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs View File

@@ -663,6 +663,18 @@ namespace Discord.Rest
public Task<RestVoiceChannel> CreateVoiceChannelAsync(string name, Action<VoiceChannelProperties> func = null, RequestOptions options = null)
=> GuildHelper.CreateVoiceChannelAsync(this, Discord, name, options, func);
/// <summary>
/// Creates a new stage channel in this guild.
/// </summary>
/// <param name="name">The new name for the stage channel.</param>
/// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous creation operation. The task result contains the newly created
/// stage channel.
/// </returns>
public Task<RestStageChannel> CreateStageChannelAsync(string name, Action<VoiceChannelProperties> func = null, RequestOptions options = null)
=> GuildHelper.CreateStageChannelAsync(this, Discord, name, options, func);
/// <summary>
/// Creates a category channel with the provided name.
/// </summary>
/// <param name="name">The name of the new channel.</param>
@@ -1241,6 +1253,9 @@ namespace Discord.Rest
async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, Action<VoiceChannelProperties> func, RequestOptions options)
=> await CreateVoiceChannelAsync(name, func, options).ConfigureAwait(false);
/// <inheritdoc />
async Task<IStageChannel> IGuild.CreateStageChannelAsync(string name, Action<VoiceChannelProperties> func, RequestOptions options)
=> await CreateStageChannelAsync(name, func, options).ConfigureAwait(false);
/// <inheritdoc />
async Task<ICategoryChannel> IGuild.CreateCategoryAsync(string name, Action<GuildChannelProperties> func, RequestOptions options)
=> await CreateCategoryChannelAsync(name, func, options).ConfigureAwait(false);



+ 16
- 0
src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -746,6 +746,19 @@ namespace Discord.WebSocket
/// </returns>
public Task<RestVoiceChannel> CreateVoiceChannelAsync(string name, Action<VoiceChannelProperties> func = null, RequestOptions options = null)
=> GuildHelper.CreateVoiceChannelAsync(this, Discord, name, options, func);

/// <summary>
/// Creates a new stage channel in this guild.
/// </summary>
/// <param name="name">The new name for the stage channel.</param>
/// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous creation operation. The task result contains the newly created
/// stage channel.
/// </returns>
public Task<RestStageChannel> CreateStageChannelAsync(string name, Action<VoiceChannelProperties> func = null, RequestOptions options = null)
=> GuildHelper.CreateStageChannelAsync(this, Discord, name, options, func);
/// <summary>
/// Creates a new channel category in this guild.
/// </summary>
@@ -1650,6 +1663,9 @@ namespace Discord.WebSocket
async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, Action<VoiceChannelProperties> func, RequestOptions options)
=> await CreateVoiceChannelAsync(name, func, options).ConfigureAwait(false);
/// <inheritdoc />
async Task<IStageChannel> IGuild.CreateStageChannelAsync(string name, Action<VoiceChannelProperties> func, RequestOptions options)
=> await CreateStageChannelAsync(name, func, options).ConfigureAwait(false);
/// <inheritdoc />
async Task<ICategoryChannel> IGuild.CreateCategoryAsync(string name, Action<GuildChannelProperties> func, RequestOptions options)
=> await CreateCategoryChannelAsync(name, func, options).ConfigureAwait(false);



Loading…
Cancel
Save