/// <para>Field value is <see langword="null" />, empty or entirely whitespace.</para>
/// <para><c>- or -</c></para>
/// <para>Field value length exceeds <see cref="MaxFieldValueLength"/>.</para>
/// </exception>
/// <returns>
/// The value of the field.
/// </returns>
public object Value
{
get => _value;
set
{
var stringValue = value?.ToString();
if (string.IsNullOrEmpty(stringValue)) throw new ArgumentException($"Field value must not be null or empty.", nameof(Value));
if (string.IsNullOrEmpty(stringValue)) throw new ArgumentException("Field value must not be null or empty.", nameof(Value));
if (stringValue.Length > MaxFieldValueLength) throw new ArgumentException($"Field value length must be less than or equal to {MaxFieldValueLength}.", nameof(Value));
_value = stringValue;
}
}
/// <summary>
/// Gets or sets whether the field should be in-line with each other.
/// Determines whether the field should be in-line with each other.
/// </summary>
public bool IsInline { get; set; }
@@ -386,6 +501,9 @@ namespace Discord
/// Sets the field name.
/// </summary>
/// <param name="name">The name to set the field name to.</param>
/// <returns>
/// The current builder.
/// </returns>
public EmbedFieldBuilder WithName(string name)
{
Name = name;
@@ -395,14 +513,20 @@ namespace Discord
/// Sets the field value.
/// </summary>
/// <param name="value">The value to set the field value to.</param>
/// <returns>
/// The current builder.
/// </returns>
public EmbedFieldBuilder WithValue(object value)
{
Value = value;
return this;
}
/// <summary>
/// Sets whether the field should be in-line with each other.
/// Determines whether the field should be in-line with each other.
/// </summary>
/// <returns>
/// The current builder.
/// </returns>
public EmbedFieldBuilder WithIsInline(bool isInline)
{
IsInline = isInline;
@@ -410,19 +534,42 @@ namespace Discord
}
/// <summary>
/// Builds the field builder into a <see cref="EmbedField"/> class.
/// Builds the field builder into a <see cref="EmbedField"/> class.
/// </summary>
/// <returns>
/// The current builder.
/// </returns>
/// <exception cref="ArgumentException">
/// <para><see cref="Name"/> or <see cref="Value"/> is <see langword="null" />, empty or entirely whitespace.</para>
/// <para><c>- or -</c></para>
/// <para><see cref="Name"/> or <see cref="Value"/> length exceeds the maximum allowed by Discord.</para>
/// </exception>
public EmbedField Build()
=> new EmbedField(Name, Value.ToString(), IsInline);
}
/// <summary>
/// Represents a builder class for a author field.
/// </summary>
public class EmbedAuthorBuilder
{
private string _name;
private string _url;
private string _iconUrl;
/// <summary>
/// Gets the maximum author name length allowed by Discord.
/// </summary>
public const int MaxAuthorNameLength = 256;
/// <summary>
/// Gets or sets the author name.
/// </summary>
/// <exception cref="ArgumentException">
/// Author name length is longer than <see cref="MaxAuthorNameLength" />.
/// </exception>
/// <returns>
/// The author name.
/// </returns>
public string Name
{
get => _name;
@@ -432,6 +579,13 @@ namespace Discord
_name = value;
}
}
/// <summary>
/// Gets or sets the URL of the author field.
/// </summary>
/// <exception cref="ArgumentException" accessor="set">Url is not a well-formed <see cref="Uri"/>.</exception>
/// <returns>
/// The URL of the author field.
/// </returns>
public string Url
{
get => _url;
@@ -441,6 +595,13 @@ namespace Discord
_url = value;
}
}
/// <summary>
/// Gets or sets the icon URL of the author field.
/// </summary>
/// <exception cref="ArgumentException" accessor="set">Url is not a well-formed <see cref="Uri"/>.</exception>
/// <returns>
/// The icon URL of the author field.
/// </returns>
public string IconUrl
{
get => _iconUrl;
@@ -451,33 +612,82 @@ namespace Discord
}
}
/// <summary>
/// Sets the name of the author field.
/// </summary>
/// <param name="name">The name of the author field.</param>
/// <returns>
/// The current builder.
/// </returns>
public EmbedAuthorBuilder WithName(string name)
{
Name = name;
return this;
}
/// <summary>
/// Sets the URL of the author field.
/// </summary>
/// <param name="url">The URL of the author field.</param>
/// <returns>
/// The current builder.
/// </returns>
public EmbedAuthorBuilder WithUrl(string url)
{
Url = url;
return this;
}
/// <summary>
/// Sets the icon URL of the author field.
/// </summary>
/// <param name="iconUrl">The icon URL of the author field.</param>
/// <returns>
/// The current builder.
/// </returns>
public EmbedAuthorBuilder WithIconUrl(string iconUrl)
{
IconUrl = iconUrl;
return this;
}
/// <summary>
/// Builds the author field to be used.
/// </summary>
/// <exception cref="ArgumentException">
/// <para>Author name length is longer than <see cref="MaxAuthorNameLength" />.</para>
/// <para><c>- or -</c></para>
/// <para><see cref="Url"/> is not a well-formed <see cref="Uri" />.</para>
/// <para><c>- or -</c></para>
/// <para><see cref="IconUrl"/> is not a well-formed <see cref="Uri" />.</para>
/// </exception>
/// <returns>
/// The built author field.
/// </returns>
public EmbedAuthor Build()
=> new EmbedAuthor(Name, Url, IconUrl, null);
}
/// <summary>
/// Represents a builder class for an embed footer.
/// </summary>
public class EmbedFooterBuilder
{
private string _text;
private string _iconUrl;
/// <summary>
/// Gets the maximum footer length allowed by Discord.
/// </summary>
public const int MaxFooterTextLength = 2048;
/// <summary>
/// Gets or sets the footer text.
/// </summary>
/// <exception cref="ArgumentException">
/// Author name length is longer than <see cref="MaxFooterTextLength" />.
/// </exception>
/// <returns>
/// The footer text.
/// </returns>
public string Text
{
get => _text;
@@ -487,6 +697,13 @@ namespace Discord
_text = value;
}
}
/// <summary>
/// Gets or sets the icon URL of the footer field.
/// </summary>
/// <exception cref="ArgumentException" accessor="set">Url is not a well-formed <see cref="Uri"/>.</exception>
/// <returns>
/// The icon URL of the footer field.
/// </returns>
public string IconUrl
{
get => _iconUrl;
@@ -497,17 +714,43 @@ namespace Discord
}
}
/// <summary>
/// Sets the name of the footer field.
/// </summary>
/// <param name="text">The text of the footer field.</param>
/// <returns>
/// The current builder.
/// </returns>
public EmbedFooterBuilder WithText(string text)
{
Text = text;
return this;
}
/// <summary>
/// Sets the icon URL of the footer field.
/// </summary>
/// <param name="iconUrl">The icon URL of the footer field.</param>
/// <returns>
/// The current builder.
/// </returns>
public EmbedFooterBuilder WithIconUrl(string iconUrl)
{
IconUrl = iconUrl;
return this;
}
/// <summary>
/// Builds the footer field to be used.
/// </summary>
/// <returns></returns>
/// <exception cref="ArgumentException">
/// <para><see cref="Text"/> length is longer than <see cref="MaxFooterTextLength" />.</para>
/// <para><c>- or -</c></para>
/// <para><see cref="IconUrl"/> is not a well-formed <see cref="Uri"/>.</para>
/// Represents a configuration class for <see cref="DiscordSocketClient" />.
/// </summary>
public class DiscordSocketConfig : DiscordRestConfig
{
/// <summary>
/// Gets or sets the encoding gateway should use.
/// </summary>
public const string GatewayEncoding = "json";
/// <summary> Gets or sets the websocket host to connect to. If null, the client will use the /gateway endpoint. </summary>
/// <summary>
/// Gets or sets the WebSocket host to connect to. If <see langword="null"/>, the client will use the
/// /gateway endpoint.
/// </summary>
public string GatewayHost { get; set; } = null;
/// <summary> Gets or sets the time, in milliseconds, to wait for a connection to complete before aborting. </summary>
/// <summary>
/// Gets or sets the time, in milliseconds, to wait for a connection to complete before aborting.
/// </summary>
public int ConnectionTimeout { get; set; } = 30000;
/// <summary> Gets or sets the id for this shard. Must be less than TotalShards. </summary>
/// <summary>
/// Gets or sets the ID for this shard. Must be less than <see cref="TotalShards"/>.
/// </summary>
public int? ShardId { get; set; } = null;
/// <summary> Gets or sets the total number of shards for this application. </summary>
/// <summary>
/// Gets or sets the total number of shards for this application.
/// </summary>
public int? TotalShards { get; set; } = null;
/// <summary> Gets or sets the number of messages per channel that should be kept in cache. Setting this to zero disables the message cache entirely. </summary>
/// <summary>
/// Gets or sets the number of messages per channel that should be kept in cache. Setting this to zero
/// disables the message cache entirely.
/// </summary>
public int MessageCacheSize { get; set; } = 0;
/// <summary>
/// Gets or sets the max number of users a guild may have for offline users to be included in the READY packet. Max is 250.
/// <summary>
/// Gets or sets the max number of users a guild may have for offline users to be included in the READY
/// packet. Max is 250.
/// </summary>
public int LargeThreshold { get; set; } = 250;
/// <summary> Gets or sets the provider used to generate new websocket connections. </summary>
/// <summary>
/// Gets or sets the provider used to generate new WebSocket connections.
/// </summary>
public WebSocketProvider WebSocketProvider { get; set; }
/// <summary> Gets or sets the provider used to generate new udp sockets. </summary>
/// <summary>
/// Gets or sets the provider used to generate new UDP sockets.
/// </summary>
public UdpSocketProvider UdpSocketProvider { get; set; }
/// <summary> Gets or sets whether or not all users should be downloaded as guilds come available. </summary>
/// <summary>
/// Gets or sets whether or not all users should be downloaded as guilds come available.
/// </summary>
public bool AlwaysDownloadUsers { get; set; } = false;
/// <summary> Gets or sets the timeout for event handlers, in milliseconds, after which a warning will be logged. Null disables this check. </summary>
/// <summary>
/// Gets or sets the timeout for event handlers, in milliseconds, after which a warning will be logged. Null
public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
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.