You can get a collection of users who are currently interested in the event by calling `GetUsersAsync`. This method works like any other get users method as in it returns an async enumerable. This method also supports pagination by user id.
```cs
// get all users and flatten the result into one collection.
var users = await event.GetUsersAsync().FlattenAsync();
// get users around the 613425648685547541 id.
var aroundUsers = await event.GetUsersAsync(613425648685547541, Direction.Around).FlattenAsync();
// Using the ready event is a simple implementation for the sake of the example. Suitable for testing and development.
// For a production bot, it is recommended to only run the CreateGlobalApplicationCommandAsync() once for each command.
}
catch(ApplicationCommandException exception)
{
@@ -93,4 +95,4 @@ public async Task Client_Ready()
```
> [!NOTE]
> Slash commands only need to be created once. They do _not_ have to be 'created' on every startup or connection. The example simple shows creating them in the ready event as it's simpler than creating normal bot commands to register slash commands.
> Slash commands only need to be created once. They do _not_ have to be 'created' on every startup or connection. The example simple shows creating them in the ready event as it's simpler than creating normal bot commands to register slash commands. The global commands take up to an hour to register every time the CreateGlobalApplicationCommandAsync() is called for a given command.
/// The guild has access to set an animated guild icon.
/// </summary>
AnimatedIcon = 1 << 0,
/// <summary>
/// The guild has access to set a guild banner image.
/// </summary>
Banner = 1 << 1,
/// <summary>
/// The guild has access to use commerce features (i.e. create store channels).
/// </summary>
Commerce = 1 << 2,
/// <summary>
/// The guild can enable welcome screen, Membership Screening, stage channels and discovery, and receives community updates.
/// </summary>
Community = 1 << 3,
/// <summary>
/// The guild is able to be discovered in the directory.
/// </summary>
Discoverable = 1 << 4,
/// <summary>
/// The guild is able to be featured in the directory.
/// </summary>
Featureable = 1 << 5,
/// <summary>
/// The guild has access to set an invite splash background.
/// </summary>
InviteSplash = 1 << 6,
/// <summary>
/// The guild has enabled <seealso href="https://discord.com/developers/docs/resources/guild#membership-screening-object">Membership Screening</seealso>.
/// </summary>
MemberVerificationGateEnabled = 1 << 7,
/// <summary>
/// The guild has enabled monetization.
/// </summary>
MonetizationEnabled = 1 << 8,
/// <summary>
/// The guild has increased custom sticker slots.
/// </summary>
MoreStickers = 1 << 9,
/// <summary>
/// The guild has access to create news channels.
/// </summary>
News = 1 << 10,
/// <summary>
/// The guild is partnered.
/// </summary>
Partnered = 1 << 11,
/// <summary>
/// The guild can be previewed before joining via Membership Screening or the directory.
/// </summary>
PreviewEnabled = 1 << 12,
/// <summary>
/// The guild has access to create private threads.
/// </summary>
PrivateThreads = 1 << 13,
/// <summary>
/// The guild is able to set role icons.
/// </summary>
RoleIcons = 1 << 14,
/// <summary>
/// The guild has access to the seven day archive time for threads.
/// </summary>
SevenDayThreadArchive = 1 << 15,
/// <summary>
/// The guild has access to the three day archive time for threads.
/// </summary>
ThreeDayThreadArchive = 1 << 16,
/// <summary>
/// The guild has enabled ticketed events.
/// </summary>
TicketedEventsEnabled = 1 << 17,
/// <summary>
/// The guild has access to set a vanity URL.
/// </summary>
VanityUrl = 1 << 18,
/// <summary>
/// The guild is verified.
/// </summary>
Verified = 1 << 19,
/// <summary>
/// The guild has access to set 384kbps bitrate in voice (previously VIP voice servers).
var vals = Enum.GetValues(typeof(GuildFeature)).Cast<GuildFeature>();
var missingValues = vals.Where(x => feature.HasFlag(x) && !Value.HasFlag(x));
throw new InvalidOperationException($"Missing required guild feature{(missingValues.Count() > 1 ? "s" : "")} {string.Join(", ", missingValues.Select(x => x.ToString()))} in order to execute this operation.");
/// Represents data of an Interaction Command, see <see href="https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata"/>.
/// </summary>
public interface IApplicationCommandInteractionData
public interface IApplicationCommandInteractionData : IDiscordInteractionData
/// Represents a option group for a command, see <see href="https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption"/>.
/// Represents a option group for a command.
/// </summary>
public interface IApplicationCommandInteractionDataOption
{
@@ -15,7 +15,7 @@ namespace Discord
/// <summary>
/// Gets the value of the pair.
/// <note>
/// This objects type can be any one of the option types in <see cref="ApplicationCommandOptionType"/>
/// This objects type can be any one of the option types in <see cref="ApplicationCommandOptionType"/>.
/// Options for the <see cref="IApplicationCommand"/>, see <see href="https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption">The docs</see>.
/// Options for the <see cref="IApplicationCommand"/>.
/// </summary>
public interface IApplicationCommandOption
{
@@ -13,37 +13,47 @@ namespace Discord
ApplicationCommandOptionType Type { get; }
/// <summary>
/// Gets the name of this command option, 1-32 character name.
/// Gets the name of this command option.
/// </summary>
string Name { get; }
/// <summary>
/// Gets the discription of this command option, 1-100 character description.
/// Gets the description of this command option.
/// </summary>
string Description { get; }
/// <summary>
/// Gets the first required option for the user to complete--only one option can be default.
/// Gets whether or not this is the first required option for the user to complete.
/// </summary>
bool? IsDefault { get; }
/// <summary>
/// Gets if the parameter is required or optional, default is <see langword="false"/>.
/// Gets whether or not the parameter is required or optional.
/// </summary>
bool? IsRequired { get; }
/// <summary>
/// Gets a collection of choices for the user to pick from.
/// Gets the smallest number value the user can input.
/// </summary>
double? MinValue { get; }
/// <summary>
/// Gets the largest number value the user can input.
/// </summary>
double? MaxValue { get; }
/// <summary>
/// Gets the choices for string and int types for the user to pick from.
if (menu.Options.Distinct().Count() != menu.Options.Count())
if (menu.Options.Distinct().Count() != menu.Options.Count)
throw new InvalidOperationException("Please make sure that there is no duplicates values.");
var builtMenu = menu.Build();
@@ -218,7 +218,7 @@ namespace Discord
else
{
ActionRowBuilder actionRow;
if(_actionRows.Count > row)
if(_actionRows.Count > row)
actionRow = _actionRows.ElementAt(row);
else
{
@@ -244,10 +244,9 @@ namespace Discord
/// <returns>A <see cref="MessageComponent"/> that can be sent with <see cref="IMessageChannel.SendMessageAsync"/>.</returns>
public MessageComponent Build()
{
if (_actionRows != null)
return new MessageComponent(_actionRows.Select(x => x.Build()).ToList());
else
return MessageComponent.Empty;
return _actionRows != null
? new MessageComponent(_actionRows.Select(x => x.Build()).ToList())
: MessageComponent.Empty;
}
}
@@ -272,19 +271,18 @@ namespace Discord
set
{
if (value == null)
throw new ArgumentNullException(message: "Action row components cannot be null!", paramName: nameof(Components));
if (value.Count <= 0)
throw new ArgumentException(message: "There must be at least 1 component in a row", paramName: nameof(Components));
if (value.Count > MaxChildCount)
throw new ArgumentException(message: $"Action row can only contain {MaxChildCount} child components!", paramName: nameof(Components));
throw new ArgumentNullException(nameof(value), $"{nameof(Components)} cannot be null.");
_components = value;
_components = value.Count switch
{
0 => throw new ArgumentOutOfRangeException(nameof(value), "There must be at least 1 component in a row."),
> MaxChildCount => throw new ArgumentOutOfRangeException(nameof(value), $"Action row can only contain {MaxChildCount} child components!"),
_ => value
};
}
}
private List<IMessageComponent> _components { get; set; } = new List<IMessageComponent>();
private List<IMessageComponent> _components = new List<IMessageComponent>();
/// <summary>
/// Adds a list of components to the current row.
@@ -359,18 +357,12 @@ namespace Discord
public string Label
{
get => _label;
set
set => _label = value?.Length switch
{
if (value != null)
{
if (value.Length > MaxButtonLabelLength)
throw new ArgumentException($"Button label must be {MaxButtonLabelLength} characters or less!", paramName: nameof(Label));
if (value.Length < 1)
throw new ArgumentException("Button label must be 1 character or more!", paramName: nameof(Label));
}
_label = value;
}
> MaxButtonLabelLength => throw new ArgumentOutOfRangeException(nameof(value), $"Label length must be less or equal to {MaxButtonLabelLength}."),
0 => throw new ArgumentOutOfRangeException(nameof(value), "Label length must be at least 1."),
_ => value
};
}
/// <summary>
@@ -381,17 +373,12 @@ namespace Discord
public string CustomId
{
get => _customId;
set
set => _customId = value?.Length switch
{
if (value != null)
{
if (value.Length > ComponentBuilder.MaxCustomIdLength)
throw new ArgumentException($"Custom Id must be {ComponentBuilder.MaxCustomIdLength} characters or less!", paramName: nameof(CustomId));
if (value.Length < 1)
throw new ArgumentException("Custom Id must be 1 character or more!", paramName: nameof(CustomId));
}
_customId = value;
}
> ComponentBuilder.MaxCustomIdLength => throw new ArgumentOutOfRangeException(nameof(value), $"Custom Id length must be less or equal to {ComponentBuilder.MaxCustomIdLength}."),
0 => throw new ArgumentOutOfRangeException(nameof(value), "Custom Id length must be at least 1."),
_ => value
};
}
/// <summary>
@@ -414,7 +401,6 @@ namespace Discord
/// </summary>
public bool IsDisabled { get; set; }
private string _label;
private string _customId;
@@ -594,8 +580,7 @@ namespace Discord
{
if (string.IsNullOrEmpty(Url))
throw new InvalidOperationException("Link buttons must have a link associated with them");
else
UrlValidation.Validate(Url);
UrlValidation.ValidateButton(Url);
}
else if (string.IsNullOrEmpty(CustomId))
throw new InvalidOperationException("Non-link buttons must have a custom id associated with them");
@@ -632,17 +617,12 @@ namespace Discord
public string CustomId
{
get => _customId;
set
set => _customId = value?.Length switch
{
if (value != null)
{
if (value.Length > ComponentBuilder.MaxCustomIdLength)
throw new ArgumentException($"Custom Id must be {ComponentBuilder.MaxCustomIdLength} characters or less!", paramName: nameof(CustomId));
if (value.Length < 1)
throw new ArgumentException("Custom Id must be 1 character or more!", paramName: nameof(CustomId));
}
_customId = value;
}
> ComponentBuilder.MaxCustomIdLength => throw new ArgumentOutOfRangeException(nameof(value), $"Custom Id length must be less or equal to {ComponentBuilder.MaxCustomIdLength}."),
0 => throw new ArgumentOutOfRangeException(nameof(value), "Custom Id length must be at least 1."),
_ => value
};
}
/// <summary>
@@ -653,18 +633,12 @@ namespace Discord
public string Placeholder
{
get => _placeholder;
set
set => _placeholder = value?.Length switch
{
if (value != null)
{
if (value.Length > MaxPlaceholderLength)
throw new ArgumentException($"The placeholder must be {MaxPlaceholderLength} characters or less!", paramName: nameof(Placeholder));
if (value.Length < 1)
throw new ArgumentException("The placeholder must be 1 character or more!", paramName: nameof(Placeholder));
}
_placeholder = value;
}
> MaxPlaceholderLength => throw new ArgumentOutOfRangeException(nameof(value), $"Placeholder length must be less or equal to {MaxPlaceholderLength}."),
0 => throw new ArgumentOutOfRangeException(nameof(value), "Placeholder length must be at least 1."),
throw new ArgumentException($"Select option value must be {MaxSelectValueLength} characters or less!", paramName: nameof(Label));
if (value.Length < 1)
throw new ArgumentException("Select option value must be 1 character or more!", paramName: nameof(Label));
}
else
throw new ArgumentException("Select option value must not be null or empty!", paramName: nameof(Label));
_value = value;
}
> MaxSelectValueLength => throw new ArgumentOutOfRangeException(nameof(value), $"Value length must be less or equal to {MaxSelectValueLength}."),
0 => throw new ArgumentOutOfRangeException(nameof(value), "Value length must be at least 1."),
_ => value
};
}
/// <summary>
@@ -968,18 +928,12 @@ namespace Discord
public string Description
{
get => _description;
set
set => _description = value?.Length switch
{
if (value != null)
{
if (value.Length > MaxDescriptionLength)
throw new ArgumentException($"The description must be {MaxDescriptionLength} characters or less!", paramName: nameof(Label));
if (value.Length < 1)
throw new ArgumentException("The description must be 1 character or more!", paramName: nameof(Label));
}
_description = value;
}
> MaxDescriptionLength => throw new ArgumentOutOfRangeException(nameof(value), $"Description length must be less or equal to {MaxDescriptionLength}."),
0 => throw new ArgumentOutOfRangeException(nameof(value), "Description length must be at least 1."),
var vals = Enum.GetValues(typeof(GuildPermission)).Cast<GuildPermission>();
var currentValues = RawValue;
var missingValues = vals.Where(x => permissions.HasFlag(x) && !Permissions.GetValue(currentValues, x));
throw new InvalidOperationException($"Missing required guild permission{(missingValues.Count() > 1 ? "s" : "")} {string.Join(", ", missingValues.Select(x => x.ToString()))} in order to execute this operation.");
}
}
public override string ToString() => RawValue.ToString();
if (args.Content.IsSpecified && args.Content.Value?.Length > DiscordConfig.MaxMessageSize)
throw new ArgumentOutOfRangeException($"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", nameof(args.Content));
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
public static async Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client,
public static Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client,
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
public static Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client,
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.