This reverts commit ba78e0c1f0.
This commit is contained in:
@@ -132,7 +132,7 @@ namespace Discord
|
|||||||
/// A task that represents an asynchronous send operation for delivering the message.
|
/// A task that represents an asynchronous send operation for delivering the message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null,
|
Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null,
|
||||||
MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None);
|
MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Responds to this interaction with a file attachment.
|
/// Responds to this interaction with a file attachment.
|
||||||
@@ -154,8 +154,7 @@ namespace Discord
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
async Task RespondWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
async Task RespondWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null,
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
using (var file = new FileAttachment(fileStream, fileName))
|
using (var file = new FileAttachment(fileStream, fileName))
|
||||||
{
|
{
|
||||||
@@ -164,8 +163,7 @@ namespace Discord
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Task RespondWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
Task RespondWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
, MessageFlags flags = MessageFlags.None);
|
|
||||||
#endif
|
#endif
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Responds to this interaction with a file attachment.
|
/// Responds to this interaction with a file attachment.
|
||||||
@@ -187,8 +185,7 @@ namespace Discord
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
async Task RespondWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
async Task RespondWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null,
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
using (var file = new FileAttachment(filePath, fileName))
|
using (var file = new FileAttachment(filePath, fileName))
|
||||||
{
|
{
|
||||||
@@ -197,8 +194,7 @@ namespace Discord
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Task RespondWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
Task RespondWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null,
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
MessageFlags flags = MessageFlags.None);
|
|
||||||
#endif
|
#endif
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Responds to this interaction with a file attachment.
|
/// Responds to this interaction with a file attachment.
|
||||||
@@ -219,13 +215,11 @@ namespace Discord
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
Task RespondWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
Task RespondWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null,
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
=> RespondWithFilesAsync(new FileAttachment[] { attachment }, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
=> RespondWithFilesAsync([attachment], text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
|
||||||
#else
|
#else
|
||||||
Task RespondWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
Task RespondWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null,
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
MessageFlags flags = MessageFlags.None);
|
|
||||||
#endif
|
#endif
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Responds to this interaction with a collection of file attachments.
|
/// Responds to this interaction with a collection of file attachments.
|
||||||
@@ -245,9 +239,7 @@ namespace Discord
|
|||||||
/// contains the sent message.
|
/// contains the sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
Task RespondWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
Task RespondWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null,
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
MessageFlags flags = MessageFlags.None);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a followup message for this interaction.
|
/// Sends a followup message for this interaction.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -265,9 +257,7 @@ namespace Discord
|
|||||||
/// contains the sent message.
|
/// contains the sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
Task<IUserMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
Task<IUserMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null,
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
MessageFlags flags = MessageFlags.None);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a followup message for this interaction.
|
/// Sends a followup message for this interaction.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -288,19 +278,17 @@ namespace Discord
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
async Task<IUserMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
async Task<IUserMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
{
|
{
|
||||||
using (var file = new FileAttachment(fileStream, fileName))
|
using (var file = new FileAttachment(fileStream, fileName))
|
||||||
{
|
{
|
||||||
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Task<IUserMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
Task<IUserMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null,
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
MessageFlags flags = MessageFlags.None);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a followup message for this interaction.
|
/// Sends a followup message for this interaction.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -321,17 +309,16 @@ namespace Discord
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
async Task<IUserMessage> FollowupWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
async Task<IUserMessage> FollowupWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null,
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
using (var file = new FileAttachment(filePath, fileName))
|
using (var file = new FileAttachment(filePath, fileName))
|
||||||
{
|
{
|
||||||
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Task<IUserMessage> FollowupWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
Task<IUserMessage> FollowupWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None);
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
#endif
|
#endif
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a followup message for this interaction.
|
/// Sends a followup message for this interaction.
|
||||||
@@ -352,11 +339,11 @@ namespace Discord
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
Task<IUserMessage> FollowupWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
Task<IUserMessage> FollowupWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> FollowupWithFilesAsync(new FileAttachment[] { attachment }, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
=> FollowupWithFilesAsync(new FileAttachment[] { attachment }, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
#else
|
#else
|
||||||
Task<IUserMessage> FollowupWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
Task<IUserMessage> FollowupWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None);
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
#endif
|
#endif
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a followup message for this interaction.
|
/// Sends a followup message for this interaction.
|
||||||
@@ -376,7 +363,7 @@ namespace Discord
|
|||||||
/// contains the sent message.
|
/// contains the sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
Task<IUserMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
Task<IUserMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None);
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the original response for this interaction.
|
/// Gets the original response for this interaction.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Discord;
|
namespace Discord
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a <see cref="IMessageComponent"/> Row for child components to live in.
|
|
||||||
/// </summary>
|
|
||||||
public class ActionRowComponent : IMessageComponent
|
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
|
||||||
public ComponentType Type => ComponentType.ActionRow;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; internal set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the child components in this row.
|
/// Represents a <see cref="IMessageComponent"/> Row for child components to live in.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IReadOnlyCollection<IMessageComponent> Components { get; internal set; }
|
public class ActionRowComponent : IMessageComponent
|
||||||
|
|
||||||
internal ActionRowComponent() { }
|
|
||||||
|
|
||||||
internal ActionRowComponent(IReadOnlyCollection<IMessageComponent> components)
|
|
||||||
{
|
{
|
||||||
Components = components;
|
/// <inheritdoc/>
|
||||||
|
public ComponentType Type => ComponentType.ActionRow;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the child components in this row.
|
||||||
|
/// </summary>
|
||||||
|
public IReadOnlyCollection<IMessageComponent> Components { get; internal set; }
|
||||||
|
|
||||||
|
internal ActionRowComponent() { }
|
||||||
|
|
||||||
|
internal ActionRowComponent(List<IMessageComponent> components)
|
||||||
|
{
|
||||||
|
Components = components;
|
||||||
|
}
|
||||||
|
|
||||||
|
string IMessageComponent.CustomId => null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,8 @@ namespace Discord;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a class used to build Action rows.
|
/// Represents a class used to build Action rows.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionRowBuilder : IMessageComponentBuilder, IInteractableComponentContainer
|
public class ActionRowBuilder
|
||||||
{
|
{
|
||||||
public ComponentType Type => ComponentType.ActionRow;
|
|
||||||
|
|
||||||
public int? Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The max amount of child components this row can hold.
|
/// The max amount of child components this row can hold.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -24,7 +20,7 @@ public class ActionRowBuilder : IMessageComponentBuilder, IInteractableComponent
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="ArgumentNullException" accessor="set"><see cref="Components"/> cannot be null.</exception>
|
/// <exception cref="ArgumentNullException" accessor="set"><see cref="Components"/> cannot be null.</exception>
|
||||||
/// <exception cref="ArgumentException" accessor="set"><see cref="Components"/> count exceeds <see cref="MaxChildCount"/>.</exception>
|
/// <exception cref="ArgumentException" accessor="set"><see cref="Components"/> count exceeds <see cref="MaxChildCount"/>.</exception>
|
||||||
public List<IMessageComponentBuilder> Components
|
public List<IMessageComponent> Components
|
||||||
{
|
{
|
||||||
get => _components;
|
get => _components;
|
||||||
set
|
set
|
||||||
@@ -41,21 +37,7 @@ public class ActionRowBuilder : IMessageComponentBuilder, IInteractableComponent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<IMessageComponent> _components = new List<IMessageComponent>();
|
||||||
public ActionRowBuilder AddComponents(params IMessageComponentBuilder[] components)
|
|
||||||
{
|
|
||||||
foreach (var component in components)
|
|
||||||
AddComponent(component);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ActionRowBuilder WithComponents(IEnumerable<IMessageComponentBuilder> components)
|
|
||||||
{
|
|
||||||
Components = components.ToList();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<IMessageComponentBuilder> _components = new ();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a list of components to the current row.
|
/// Adds a list of components to the current row.
|
||||||
@@ -63,7 +45,7 @@ public class ActionRowBuilder : IMessageComponentBuilder, IInteractableComponent
|
|||||||
/// <param name="components">The list of components to add.</param>
|
/// <param name="components">The list of components to add.</param>
|
||||||
/// <inheritdoc cref="Components"/>
|
/// <inheritdoc cref="Components"/>
|
||||||
/// <returns>The current builder.</returns>
|
/// <returns>The current builder.</returns>
|
||||||
public ActionRowBuilder WithComponents(List<IMessageComponentBuilder> components)
|
public ActionRowBuilder WithComponents(List<IMessageComponent> components)
|
||||||
{
|
{
|
||||||
Components = components;
|
Components = components;
|
||||||
return this;
|
return this;
|
||||||
@@ -75,7 +57,7 @@ public class ActionRowBuilder : IMessageComponentBuilder, IInteractableComponent
|
|||||||
/// <param name="component">The component to add.</param>
|
/// <param name="component">The component to add.</param>
|
||||||
/// <exception cref="InvalidOperationException">Components count reached <see cref="MaxChildCount"/></exception>
|
/// <exception cref="InvalidOperationException">Components count reached <see cref="MaxChildCount"/></exception>
|
||||||
/// <returns>The current builder.</returns>
|
/// <returns>The current builder.</returns>
|
||||||
public ActionRowBuilder AddComponent(IMessageComponentBuilder component)
|
public ActionRowBuilder AddComponent(IMessageComponent component)
|
||||||
{
|
{
|
||||||
if (Components.Count >= MaxChildCount)
|
if (Components.Count >= MaxChildCount)
|
||||||
throw new InvalidOperationException($"Components count reached {MaxChildCount}");
|
throw new InvalidOperationException($"Components count reached {MaxChildCount}");
|
||||||
@@ -121,11 +103,13 @@ public class ActionRowBuilder : IMessageComponentBuilder, IInteractableComponent
|
|||||||
{
|
{
|
||||||
if (menu.Options is not null && menu.Options.Distinct().Count() != menu.Options.Count)
|
if (menu.Options is not null && menu.Options.Distinct().Count() != menu.Options.Count)
|
||||||
throw new InvalidOperationException("Please make sure that there is no duplicates values.");
|
throw new InvalidOperationException("Please make sure that there is no duplicates values.");
|
||||||
|
|
||||||
|
var builtMenu = menu.Build();
|
||||||
|
|
||||||
if (Components.Count != 0)
|
if (Components.Count != 0)
|
||||||
throw new InvalidOperationException($"A Select Menu cannot exist in a pre-occupied ActionRow.");
|
throw new InvalidOperationException($"A Select Menu cannot exist in a pre-occupied ActionRow.");
|
||||||
|
|
||||||
AddComponent(menu);
|
AddComponent(builtMenu);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -168,13 +152,15 @@ public class ActionRowBuilder : IMessageComponentBuilder, IInteractableComponent
|
|||||||
/// <returns>The current builder.</returns>
|
/// <returns>The current builder.</returns>
|
||||||
public ActionRowBuilder WithButton(ButtonBuilder button)
|
public ActionRowBuilder WithButton(ButtonBuilder button)
|
||||||
{
|
{
|
||||||
|
var builtButton = button.Build();
|
||||||
|
|
||||||
if (Components.Count >= 5)
|
if (Components.Count >= 5)
|
||||||
throw new InvalidOperationException($"Components count reached {MaxChildCount}");
|
throw new InvalidOperationException($"Components count reached {MaxChildCount}");
|
||||||
|
|
||||||
if (Components.Any(x => x.Type.IsSelectType()))
|
if (Components.Any(x => x.Type.IsSelectType()))
|
||||||
throw new InvalidOperationException($"A button cannot be added to a row with a SelectMenu");
|
throw new InvalidOperationException($"A button cannot be added to a row with a SelectMenu");
|
||||||
|
|
||||||
AddComponent(button);
|
AddComponent(builtButton);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -185,11 +171,10 @@ public class ActionRowBuilder : IMessageComponentBuilder, IInteractableComponent
|
|||||||
/// <returns>A <see cref="ActionRowComponent"/> that can be used within a <see cref="ComponentBuilder"/></returns>
|
/// <returns>A <see cref="ActionRowComponent"/> that can be used within a <see cref="ComponentBuilder"/></returns>
|
||||||
public ActionRowComponent Build()
|
public ActionRowComponent Build()
|
||||||
{
|
{
|
||||||
return new ActionRowComponent(_components.Select(x => x.Build()).ToList());
|
return new ActionRowComponent(_components);
|
||||||
}
|
}
|
||||||
IMessageComponent IMessageComponentBuilder.Build() => Build();
|
|
||||||
|
|
||||||
internal bool CanTakeComponent(IMessageComponentBuilder component)
|
internal bool CanTakeComponent(IMessageComponent component)
|
||||||
{
|
{
|
||||||
switch (component.Type)
|
switch (component.Type)
|
||||||
{
|
{
|
||||||
@@ -210,11 +195,4 @@ public class ActionRowBuilder : IMessageComponentBuilder, IInteractableComponent
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IComponentContainer IComponentContainer.AddComponent(IMessageComponentBuilder component) => AddComponent(component);
|
|
||||||
|
|
||||||
IComponentContainer IComponentContainer.AddComponents(params IMessageComponentBuilder[] components) => AddComponents(components);
|
|
||||||
|
|
||||||
IComponentContainer IComponentContainer.WithComponents(IEnumerable<IMessageComponentBuilder> components) => WithComponents(components);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,8 @@ namespace Discord;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a class used to build <see cref="ButtonComponent"/>'s.
|
/// Represents a class used to build <see cref="ButtonComponent"/>'s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ButtonBuilder : IInteractableComponentBuilder
|
public class ButtonBuilder
|
||||||
{
|
{
|
||||||
public ComponentType Type => ComponentType.Button;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The max length of a <see cref="ButtonComponent.Label"/>.
|
/// The max length of a <see cref="ButtonComponent.Label"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -76,8 +74,6 @@ public class ButtonBuilder : IInteractableComponentBuilder
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
public ulong? SkuId { get; set; }
|
public ulong? SkuId { get; set; }
|
||||||
|
|
||||||
public int? Id { get; set; }
|
|
||||||
|
|
||||||
private string _label;
|
private string _label;
|
||||||
private string _customId;
|
private string _customId;
|
||||||
|
|
||||||
@@ -96,7 +92,7 @@ public class ButtonBuilder : IInteractableComponentBuilder
|
|||||||
/// <param name="emote">The emote of this button.</param>
|
/// <param name="emote">The emote of this button.</param>
|
||||||
/// <param name="isDisabled">Disabled this button or not.</param>
|
/// <param name="isDisabled">Disabled this button or not.</param>
|
||||||
/// <param name="skuId">The sku id of this button.</param>
|
/// <param name="skuId">The sku id of this button.</param>
|
||||||
public ButtonBuilder(string label = null, string customId = null, ButtonStyle style = ButtonStyle.Primary, string url = null, IEmote emote = null, bool isDisabled = false, ulong? skuId = null, int? id = null)
|
public ButtonBuilder(string label = null, string customId = null, ButtonStyle style = ButtonStyle.Primary, string url = null, IEmote emote = null, bool isDisabled = false, ulong? skuId = null)
|
||||||
{
|
{
|
||||||
CustomId = customId;
|
CustomId = customId;
|
||||||
Style = style;
|
Style = style;
|
||||||
@@ -105,7 +101,6 @@ public class ButtonBuilder : IInteractableComponentBuilder
|
|||||||
IsDisabled = isDisabled;
|
IsDisabled = isDisabled;
|
||||||
Emote = emote;
|
Emote = emote;
|
||||||
SkuId = skuId;
|
SkuId = skuId;
|
||||||
Id = id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -120,7 +115,6 @@ public class ButtonBuilder : IInteractableComponentBuilder
|
|||||||
IsDisabled = button.IsDisabled;
|
IsDisabled = button.IsDisabled;
|
||||||
Emote = button.Emote;
|
Emote = button.Emote;
|
||||||
SkuId = button.SkuId;
|
SkuId = button.SkuId;
|
||||||
Id = button.Id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -321,8 +315,6 @@ public class ButtonBuilder : IInteractableComponentBuilder
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ButtonComponent(Style, Label, Emote, CustomId, Url, IsDisabled, SkuId, Id);
|
return new ButtonComponent(Style, Label, Emote, CustomId, Url, IsDisabled, SkuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
IMessageComponent IMessageComponentBuilder.Build() => Build();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public class ComponentBuilder
|
|||||||
/// <returns>The current builder.</returns>
|
/// <returns>The current builder.</returns>
|
||||||
public ComponentBuilder RemoveComponent(string customId)
|
public ComponentBuilder RemoveComponent(string customId)
|
||||||
{
|
{
|
||||||
this.ActionRows.ForEach(ar => ar.Components.RemoveAll(c => c is IInteractableComponent i && i.CustomId == customId));
|
this.ActionRows.ForEach(ar => ar.Components.RemoveAll(c => c.CustomId == customId));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,15 +158,20 @@ public class ComponentBuilder
|
|||||||
Preconditions.LessThan(row, MaxActionRowCount, nameof(row));
|
Preconditions.LessThan(row, MaxActionRowCount, nameof(row));
|
||||||
if (menu.Options is not null && menu.Options.Distinct().Count() != menu.Options.Count)
|
if (menu.Options is not null && menu.Options.Distinct().Count() != menu.Options.Count)
|
||||||
throw new InvalidOperationException("Please make sure that there is no duplicates values.");
|
throw new InvalidOperationException("Please make sure that there is no duplicates values.");
|
||||||
|
|
||||||
|
var builtMenu = menu.Build();
|
||||||
|
|
||||||
if (_actionRows == null)
|
if (_actionRows == null)
|
||||||
{
|
{
|
||||||
_actionRows = [new ActionRowBuilder().AddComponent(menu)];
|
_actionRows = new List<ActionRowBuilder>
|
||||||
|
{
|
||||||
|
new ActionRowBuilder().AddComponent(builtMenu)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_actionRows.Count == row)
|
if (_actionRows.Count == row)
|
||||||
_actionRows.Add(new ActionRowBuilder().AddComponent(menu));
|
_actionRows.Add(new ActionRowBuilder().AddComponent(builtMenu));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ActionRowBuilder actionRow;
|
ActionRowBuilder actionRow;
|
||||||
@@ -178,12 +183,12 @@ public class ComponentBuilder
|
|||||||
_actionRows.Add(actionRow);
|
_actionRows.Add(actionRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actionRow.CanTakeComponent(menu))
|
if (actionRow.CanTakeComponent(builtMenu))
|
||||||
actionRow.AddComponent(menu);
|
actionRow.AddComponent(builtMenu);
|
||||||
else if (row < MaxActionRowCount)
|
else if (row < MaxActionRowCount)
|
||||||
WithSelectMenu(menu, row + 1);
|
WithSelectMenu(menu, row + 1);
|
||||||
else
|
else
|
||||||
throw new InvalidOperationException($"There is no more row to add a {nameof(menu)}");
|
throw new InvalidOperationException($"There is no more row to add a {nameof(builtMenu)}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,17 +243,19 @@ public class ComponentBuilder
|
|||||||
{
|
{
|
||||||
Preconditions.LessThan(row, MaxActionRowCount, nameof(row));
|
Preconditions.LessThan(row, MaxActionRowCount, nameof(row));
|
||||||
|
|
||||||
|
var builtButton = button.Build();
|
||||||
|
|
||||||
if (_actionRows == null)
|
if (_actionRows == null)
|
||||||
{
|
{
|
||||||
_actionRows = new List<ActionRowBuilder>
|
_actionRows = new List<ActionRowBuilder>
|
||||||
{
|
{
|
||||||
new ActionRowBuilder().AddComponent(button)
|
new ActionRowBuilder().AddComponent(builtButton)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_actionRows.Count == row)
|
if (_actionRows.Count == row)
|
||||||
_actionRows.Add(new ActionRowBuilder().AddComponent(button));
|
_actionRows.Add(new ActionRowBuilder().AddComponent(builtButton));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ActionRowBuilder actionRow;
|
ActionRowBuilder actionRow;
|
||||||
@@ -260,8 +267,8 @@ public class ComponentBuilder
|
|||||||
_actionRows.Add(actionRow);
|
_actionRows.Add(actionRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actionRow.CanTakeComponent(button))
|
if (actionRow.CanTakeComponent(builtButton))
|
||||||
actionRow.AddComponent(button);
|
actionRow.AddComponent(builtButton);
|
||||||
else if (row < MaxActionRowCount)
|
else if (row < MaxActionRowCount)
|
||||||
WithButton(button, row + 1);
|
WithButton(button, row + 1);
|
||||||
else
|
else
|
||||||
@@ -319,7 +326,7 @@ public class ComponentBuilder
|
|||||||
_actionRows.RemoveAt(i);
|
_actionRows.RemoveAt(i);
|
||||||
|
|
||||||
return _actionRows != null
|
return _actionRows != null
|
||||||
? new MessageComponent(_actionRows.Select(x => x.Build()).OfType<IMessageComponent>().ToList())
|
? new MessageComponent(_actionRows.Select(x => x.Build()).ToList())
|
||||||
: MessageComponent.Empty;
|
: MessageComponent.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
public static class ComponentBuilderExtensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the custom id for the component.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current builder.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithId<BuilderT>(this BuilderT builder, int? id)
|
|
||||||
where BuilderT : IMessageComponentBuilder
|
|
||||||
{
|
|
||||||
builder.Id = id;
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Discord;
|
|
||||||
|
|
||||||
public class ComponentBuilderV2 : IStaticComponentContainer
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the maximum number of components that can be added to this container.
|
|
||||||
/// </summary>
|
|
||||||
public const int MaxComponents = 10;
|
|
||||||
|
|
||||||
private List<IMessageComponentBuilder> _components = new();
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public List<IMessageComponentBuilder> Components
|
|
||||||
{
|
|
||||||
get => _components;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_components = value ?? throw new ArgumentNullException(nameof(value), $"{nameof(Components)} cannot be null.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of <see cref="ComponentBuilderV2"/>.
|
|
||||||
/// </summary>
|
|
||||||
public ComponentBuilderV2() { }
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IComponentContainer.AddComponent"/>
|
|
||||||
public ComponentBuilderV2 AddComponent(IMessageComponentBuilder component)
|
|
||||||
{
|
|
||||||
Components.Add(component);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IComponentContainer.AddComponents"/>
|
|
||||||
public ComponentBuilderV2 AddComponents(params IMessageComponentBuilder[] components)
|
|
||||||
{
|
|
||||||
foreach (var component in components)
|
|
||||||
Components.Add(component);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IComponentContainer.WithComponents"/>
|
|
||||||
public ComponentBuilderV2 WithComponents(IEnumerable<IMessageComponentBuilder> components)
|
|
||||||
{
|
|
||||||
Components = components.ToList();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMessageComponentBuilder.Build" />
|
|
||||||
public MessageComponent Build()
|
|
||||||
{
|
|
||||||
if (_components.Count is 0 or >MaxComponents)
|
|
||||||
throw new InvalidOperationException($"The number of components must be between 1 and {MaxComponents}.");
|
|
||||||
|
|
||||||
if (_components.Any(x =>
|
|
||||||
x is not ActionRowBuilder
|
|
||||||
and not SectionBuilder
|
|
||||||
and not TextDisplayBuilder
|
|
||||||
and not MediaGalleryBuilder
|
|
||||||
and not FileComponentBuilder
|
|
||||||
and not SeparatorBuilder
|
|
||||||
and not ContainerBuilder))
|
|
||||||
throw new InvalidOperationException($"Only the following components can be at the top level: {nameof(ActionRowBuilder)}, {nameof(TextDisplayBuilder)}, {nameof(SectionBuilder)}, {nameof(MediaGalleryBuilder)}, {nameof(SeparatorBuilder)}, or {nameof(FileComponentBuilder)} components.");
|
|
||||||
|
|
||||||
return new MessageComponent(Components.Select(x => x.Build()).ToList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
IComponentContainer IComponentContainer.AddComponent(IMessageComponentBuilder component) => AddComponent(component);
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
IComponentContainer IComponentContainer.AddComponents(params IMessageComponentBuilder[] components) => AddComponents(components);
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
IComponentContainer IComponentContainer.WithComponents(IEnumerable<IMessageComponentBuilder> components) => WithComponents(components);
|
|
||||||
}
|
|
||||||
@@ -1,315 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Discord;
|
|
||||||
|
|
||||||
public static class ComponentContainerExtensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="TextDisplayBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithTextDisplay<BuilderT>(this BuilderT container, TextDisplayBuilder textDisplay)
|
|
||||||
where BuilderT : class, IStaticComponentContainer
|
|
||||||
{
|
|
||||||
container.AddComponent(textDisplay);
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="TextDisplayBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithTextDisplay<BuilderT>(this BuilderT container,
|
|
||||||
string content,
|
|
||||||
int? id = null)
|
|
||||||
where BuilderT : class, IStaticComponentContainer
|
|
||||||
=> container.WithTextDisplay(new TextDisplayBuilder()
|
|
||||||
.WithContent(content)
|
|
||||||
.WithId(id));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="SectionBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithSection<BuilderT>(this BuilderT container, SectionBuilder section)
|
|
||||||
where BuilderT : class, IStaticComponentContainer
|
|
||||||
{
|
|
||||||
container.AddComponent(section);
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="SectionBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithSection<BuilderT>(this BuilderT container,
|
|
||||||
IEnumerable<TextDisplayBuilder> components,
|
|
||||||
IMessageComponentBuilder accessory,
|
|
||||||
bool isSpoiler = false,
|
|
||||||
int? id = null)
|
|
||||||
where BuilderT : class, IStaticComponentContainer
|
|
||||||
=> container.WithSection(new SectionBuilder()
|
|
||||||
.WithComponents(components)
|
|
||||||
.WithAccessory(accessory)
|
|
||||||
.WithId(id));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="MediaGalleryBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithMediaGallery<BuilderT>(this BuilderT container, MediaGalleryBuilder mediaGallery)
|
|
||||||
where BuilderT : class, IStaticComponentContainer
|
|
||||||
{
|
|
||||||
container.AddComponent(mediaGallery);
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="MediaGalleryBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithMediaGallery<BuilderT>(this BuilderT container,
|
|
||||||
IEnumerable<MediaGalleryItemProperties> items,
|
|
||||||
int? id = null) where BuilderT : class, IStaticComponentContainer
|
|
||||||
=> container.WithMediaGallery(new MediaGalleryBuilder()
|
|
||||||
.WithItems(items)
|
|
||||||
.WithId(id));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="MediaGalleryBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithMediaGallery<BuilderT>(this BuilderT container,
|
|
||||||
IEnumerable<string> urls,
|
|
||||||
int? id = null)
|
|
||||||
where BuilderT : class, IStaticComponentContainer
|
|
||||||
=> container.WithMediaGallery(new MediaGalleryBuilder()
|
|
||||||
.WithItems(urls.Select(x => new MediaGalleryItemProperties(new UnfurledMediaItemProperties(x))))
|
|
||||||
.WithId(id));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="SeparatorBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithSeparator<BuilderT>(this BuilderT container, SeparatorBuilder separator)
|
|
||||||
where BuilderT : class, IStaticComponentContainer
|
|
||||||
{
|
|
||||||
container.AddComponent(separator);
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="SeparatorBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithSeparator<BuilderT>(this BuilderT container,
|
|
||||||
SeparatorSpacingSize spacing = SeparatorSpacingSize.Small,
|
|
||||||
bool isDivider = true,
|
|
||||||
int? id = null)
|
|
||||||
where BuilderT : class, IStaticComponentContainer
|
|
||||||
=> container.WithSeparator(new SeparatorBuilder()
|
|
||||||
.WithSpacing(spacing)
|
|
||||||
.WithIsDivider(isDivider)
|
|
||||||
.WithId(id));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="FileComponentBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithFile<BuilderT>(this BuilderT container, FileComponentBuilder file)
|
|
||||||
where BuilderT : class, IStaticComponentContainer
|
|
||||||
{
|
|
||||||
container.AddComponent(file);
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="FileComponentBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithFile<BuilderT>(this BuilderT container,
|
|
||||||
UnfurledMediaItemProperties file,
|
|
||||||
bool isSpoiler = false,
|
|
||||||
int? id = null)
|
|
||||||
where BuilderT : class, IStaticComponentContainer
|
|
||||||
=> container.WithFile(new FileComponentBuilder()
|
|
||||||
.WithFile(file)
|
|
||||||
.WithIsSpoiler(isSpoiler)
|
|
||||||
.WithId(id));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="ContainerBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithContainer<BuilderT>(this BuilderT container, ContainerBuilder containerComponent)
|
|
||||||
where BuilderT : class, IStaticComponentContainer
|
|
||||||
{
|
|
||||||
container.AddComponent(containerComponent);
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="ContainerBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithContainer<BuilderT>(this BuilderT container,
|
|
||||||
IEnumerable<IMessageComponentBuilder> components,
|
|
||||||
Color? accentColor = null,
|
|
||||||
bool isSpoiler = false,
|
|
||||||
int? id = null)
|
|
||||||
where BuilderT : class, IStaticComponentContainer
|
|
||||||
=> container.WithContainer(new ContainerBuilder()
|
|
||||||
.WithComponents(components)
|
|
||||||
.WithAccentColor(accentColor)
|
|
||||||
.WithSpoiler(isSpoiler)
|
|
||||||
.WithId(id));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="ContainerBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithContainer<BuilderT>(this BuilderT container,
|
|
||||||
params IMessageComponentBuilder[] components)
|
|
||||||
where BuilderT : class, IStaticComponentContainer
|
|
||||||
=> container.WithContainer(new ContainerBuilder()
|
|
||||||
.WithComponents(components));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="ButtonBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithButton<BuilderT>(this BuilderT container, ButtonBuilder button)
|
|
||||||
where BuilderT : class, IInteractableComponentContainer
|
|
||||||
{
|
|
||||||
container.AddComponent(button);
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="ButtonBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithButton<BuilderT>(this BuilderT container,
|
|
||||||
string label = null,
|
|
||||||
string customId = null,
|
|
||||||
ButtonStyle style = ButtonStyle.Primary,
|
|
||||||
IEmote emote = null,
|
|
||||||
string url = null,
|
|
||||||
bool disabled = false,
|
|
||||||
ulong? skuId = null,
|
|
||||||
int? id = null)
|
|
||||||
where BuilderT : class, IInteractableComponentContainer
|
|
||||||
=> container.WithButton(new ButtonBuilder()
|
|
||||||
.WithLabel(label)
|
|
||||||
.WithStyle(style)
|
|
||||||
.WithEmote(emote)
|
|
||||||
.WithCustomId(customId)
|
|
||||||
.WithUrl(url)
|
|
||||||
.WithDisabled(disabled)
|
|
||||||
.WithSkuId(skuId)
|
|
||||||
.WithId(id));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="SelectMenuBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithSelectMenu<BuilderT>(this BuilderT container, SelectMenuBuilder selectMenu)
|
|
||||||
where BuilderT : class, IInteractableComponentContainer
|
|
||||||
{
|
|
||||||
container.AddComponent(selectMenu);
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="SelectMenuBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithSelectMenu<BuilderT>(this BuilderT container,
|
|
||||||
string customId,
|
|
||||||
List<SelectMenuOptionBuilder> options = null,
|
|
||||||
string placeholder = null,
|
|
||||||
int minValues = 1,
|
|
||||||
int maxValues = 1,
|
|
||||||
bool disabled = false,
|
|
||||||
int row = 0,
|
|
||||||
ComponentType type = ComponentType.SelectMenu,
|
|
||||||
ChannelType[] channelTypes = null,
|
|
||||||
SelectMenuDefaultValue[] defaultValues = null,
|
|
||||||
int? id = null)
|
|
||||||
where BuilderT : class, IInteractableComponentContainer
|
|
||||||
=> container.WithSelectMenu(new SelectMenuBuilder()
|
|
||||||
.WithCustomId(customId)
|
|
||||||
.WithOptions(options)
|
|
||||||
.WithPlaceholder(placeholder)
|
|
||||||
.WithMaxValues(maxValues)
|
|
||||||
.WithMinValues(minValues)
|
|
||||||
.WithDisabled(disabled)
|
|
||||||
.WithType(type)
|
|
||||||
.WithChannelTypes(channelTypes)
|
|
||||||
.WithDefaultValues(defaultValues)
|
|
||||||
.WithId(id));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="ActionRowBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithActionRow<BuilderT>(this BuilderT container, ActionRowBuilder actionRow)
|
|
||||||
where BuilderT : class, IStaticComponentContainer
|
|
||||||
{
|
|
||||||
container.AddComponent(actionRow);
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="ActionRowBuilder"/> to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
public static BuilderT WithActionRow<BuilderT>(this BuilderT container,
|
|
||||||
IEnumerable<IMessageComponentBuilder> components,
|
|
||||||
int? id = null)
|
|
||||||
where BuilderT : class, IStaticComponentContainer
|
|
||||||
=> container.WithActionRow(new ActionRowBuilder()
|
|
||||||
.WithComponents(components)
|
|
||||||
.WithId(id));
|
|
||||||
}
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.Immutable;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Discord;
|
|
||||||
|
|
||||||
public class ContainerBuilder : IMessageComponentBuilder, IStaticComponentContainer
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The maximum number of components allowed in a container.
|
|
||||||
/// </summary>
|
|
||||||
public const int MaxComponents = 10;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public ComponentType Type => ComponentType.Container;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public int? Id { get; set; }
|
|
||||||
|
|
||||||
private List<IMessageComponentBuilder> _components = new();
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public List<IMessageComponentBuilder> Components
|
|
||||||
{
|
|
||||||
get => _components;
|
|
||||||
set => _components = value ?? throw new ArgumentNullException(nameof(value), $"{nameof(Components)} cannot be null.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the accent color of this container.
|
|
||||||
/// </summary>
|
|
||||||
public uint? AccentColor { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets whether this container is a spoiler.
|
|
||||||
/// </summary>
|
|
||||||
public bool? IsSpoiler { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the accent color of this container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current builder.
|
|
||||||
/// </returns>
|
|
||||||
public ContainerBuilder WithAccentColor(Color? color)
|
|
||||||
{
|
|
||||||
AccentColor = color?.RawValue;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets whether this container is a spoiler.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current builder.
|
|
||||||
/// </returns>
|
|
||||||
public ContainerBuilder WithSpoiler(bool isSpoiler)
|
|
||||||
{
|
|
||||||
IsSpoiler = isSpoiler;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IComponentContainer.AddComponent"/>
|
|
||||||
public ContainerBuilder AddComponent(IMessageComponentBuilder component)
|
|
||||||
{
|
|
||||||
Components.Add(component);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IComponentContainer.AddComponents"/>
|
|
||||||
public ContainerBuilder AddComponents(params IMessageComponentBuilder[] components)
|
|
||||||
{
|
|
||||||
foreach (var component in components)
|
|
||||||
Components.Add(component);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IComponentContainer.WithComponents"/>
|
|
||||||
public ContainerBuilder WithComponents(IEnumerable<IMessageComponentBuilder> components)
|
|
||||||
{
|
|
||||||
Components = components.ToList();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMessageComponentBuilder.Build"/>
|
|
||||||
public ContainerComponent Build()
|
|
||||||
{
|
|
||||||
if (_components.Count is 0 or > MaxComponents)
|
|
||||||
throw new InvalidOperationException($"A container must have between 1 and {MaxComponents} components.");
|
|
||||||
|
|
||||||
if (_components.Any(x => x
|
|
||||||
is not ActionRowBuilder
|
|
||||||
and not TextDisplayBuilder
|
|
||||||
and not SectionBuilder
|
|
||||||
and not MediaGalleryBuilder
|
|
||||||
and not SeparatorBuilder
|
|
||||||
and not FileComponentBuilder))
|
|
||||||
throw new InvalidOperationException($"A container can only contain {nameof(ActionRowBuilder)}, {nameof(TextDisplayBuilder)}, {nameof(SectionBuilder)}, {nameof(MediaGalleryBuilder)}, {nameof(SeparatorBuilder)}, or {nameof(FileComponentBuilder)} components.");
|
|
||||||
|
|
||||||
return new(Components.ConvertAll(x => x.Build()).ToImmutableArray(), AccentColor, IsSpoiler, Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
IMessageComponent IMessageComponentBuilder.Build() => Build();
|
|
||||||
/// <inheritdoc />
|
|
||||||
IComponentContainer IComponentContainer.AddComponent(IMessageComponentBuilder component) => AddComponent(component);
|
|
||||||
/// <inheritdoc />
|
|
||||||
IComponentContainer IComponentContainer.AddComponents(params IMessageComponentBuilder[] components) => AddComponents(components);
|
|
||||||
/// <inheritdoc />
|
|
||||||
IComponentContainer IComponentContainer.WithComponents(IEnumerable<IMessageComponentBuilder> components) => WithComponents(components);
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace Discord;
|
|
||||||
|
|
||||||
public class FileComponentBuilder : IMessageComponentBuilder
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public ComponentType Type => ComponentType.File;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public int? Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the file for the component.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// Only attachment URLs are supported.
|
|
||||||
/// </remarks>
|
|
||||||
public UnfurledMediaItemProperties File { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets whether the file is a spoiler.
|
|
||||||
/// </summary>
|
|
||||||
public bool? IsSpoiler { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="FileComponentBuilder"/>.
|
|
||||||
/// </summary>
|
|
||||||
public FileComponentBuilder() {}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="FileComponentBuilder"/>.
|
|
||||||
/// </summary>
|
|
||||||
public FileComponentBuilder(UnfurledMediaItemProperties media, bool isSpoiler = false, int? id = null)
|
|
||||||
{
|
|
||||||
File = media;
|
|
||||||
Id = id;
|
|
||||||
IsSpoiler = isSpoiler;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the file for the component.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current builder.
|
|
||||||
/// </returns>
|
|
||||||
public FileComponentBuilder WithFile(UnfurledMediaItemProperties file)
|
|
||||||
{
|
|
||||||
File = file;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets whether the file is a spoiler.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current builder.
|
|
||||||
/// </returns>
|
|
||||||
public FileComponentBuilder WithIsSpoiler(bool? isSpoiler)
|
|
||||||
{
|
|
||||||
IsSpoiler = isSpoiler;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMessageComponentBuilder.Build" />
|
|
||||||
public FileComponent Build()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(File.Url))
|
|
||||||
throw new InvalidOperationException("File URL must be set.");
|
|
||||||
|
|
||||||
if (!File.Url.StartsWith("attachment://"))
|
|
||||||
throw new InvalidOperationException("File URL must be an attachment URL.");
|
|
||||||
|
|
||||||
return new(new UnfurledMediaItem(File.Url), IsSpoiler, Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
IMessageComponent IMessageComponentBuilder.Build() => Build();
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a container with child components.
|
|
||||||
/// </summary>
|
|
||||||
public interface IComponentContainer
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the components in the container.
|
|
||||||
/// </summary>
|
|
||||||
List<IMessageComponentBuilder> Components { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a component to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
IComponentContainer AddComponent(IMessageComponentBuilder component);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds components to the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
IComponentContainer AddComponents(params IMessageComponentBuilder[] components);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the components in the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current container.
|
|
||||||
/// </returns>
|
|
||||||
IComponentContainer WithComponents(IEnumerable<IMessageComponentBuilder> components);
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a builder for an interactable component.
|
|
||||||
/// </summary>
|
|
||||||
public interface IInteractableComponentBuilder : IMessageComponentBuilder
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the custom id for the component.
|
|
||||||
/// </summary>
|
|
||||||
string CustomId { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a container for interactable components.
|
|
||||||
/// </summary>
|
|
||||||
public interface IInteractableComponentContainer : IComponentContainer
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
public interface IMessageComponentBuilder
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the type of the component.
|
|
||||||
/// </summary>
|
|
||||||
ComponentType Type { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the id for the component. An autoincremented id will be assigned if not set.
|
|
||||||
/// </summary>
|
|
||||||
int? Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Runs validation checks and builds the component.
|
|
||||||
/// </summary>
|
|
||||||
IMessageComponent Build();
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a container for static components.
|
|
||||||
/// </summary>
|
|
||||||
public interface IStaticComponentContainer : IComponentContainer
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.Immutable;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Discord;
|
|
||||||
|
|
||||||
public class MediaGalleryBuilder : IMessageComponentBuilder
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the maximum number of items that can be added to a media gallery.
|
|
||||||
/// </summary>
|
|
||||||
public const int MaxItems = 10;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public ComponentType Type => ComponentType.MediaGallery;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; set; }
|
|
||||||
|
|
||||||
private List<MediaGalleryItemProperties> _items = new();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="MediaGalleryBuilder"/>.
|
|
||||||
/// </summary>
|
|
||||||
public MediaGalleryBuilder() { }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="MediaGalleryBuilder"/>.
|
|
||||||
/// </summary>
|
|
||||||
public MediaGalleryBuilder(IEnumerable<MediaGalleryItemProperties> items, int? id = null)
|
|
||||||
{
|
|
||||||
Items = items.ToList();
|
|
||||||
Id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the items in this media gallery.
|
|
||||||
/// </summary>
|
|
||||||
public List<MediaGalleryItemProperties> Items
|
|
||||||
{
|
|
||||||
get => _items;
|
|
||||||
set => _items = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a new item to the media gallery.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current builder.
|
|
||||||
/// </returns>
|
|
||||||
public MediaGalleryBuilder AddItem(MediaGalleryItemProperties item)
|
|
||||||
{
|
|
||||||
_items.Add(item);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a new item to the media gallery.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current builder.
|
|
||||||
/// </returns>
|
|
||||||
public MediaGalleryBuilder AddItem(string url, string description = null, bool isSpoiler = false)
|
|
||||||
{
|
|
||||||
_items.Add(new MediaGalleryItemProperties(new UnfurledMediaItemProperties(url), description, isSpoiler));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a list of items to the media gallery.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current builder.
|
|
||||||
/// </returns>
|
|
||||||
public MediaGalleryBuilder AddItems(params IEnumerable<MediaGalleryItemProperties> items)
|
|
||||||
{
|
|
||||||
foreach (var item in items)
|
|
||||||
_items.Add(item);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the items in the media gallery.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current builder.
|
|
||||||
/// </returns>
|
|
||||||
public MediaGalleryBuilder WithItems(IEnumerable<MediaGalleryItemProperties> items)
|
|
||||||
{
|
|
||||||
_items = items.ToList();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMessageComponentBuilder.Build"/>
|
|
||||||
public MediaGalleryComponent Build()
|
|
||||||
{
|
|
||||||
if (_items.Any(x => (x.Description?.Length ?? 0) > MediaGalleryItemProperties.MaxDescriptionLength))
|
|
||||||
throw new ArgumentException($"{nameof(MediaGalleryItemProperties)} description length cannot exceed {MediaGalleryItemProperties.MaxDescriptionLength} characters.");
|
|
||||||
|
|
||||||
if (_items.Any(x => !(x.Media.Url?.StartsWith("http://") ?? false)
|
|
||||||
&& !(x.Media.Url?.StartsWith("https://") ?? false)
|
|
||||||
&& !(x.Media.Url?.StartsWith("attachment://") ?? false)))
|
|
||||||
throw new ArgumentException($"{nameof(MediaGalleryItemProperties)} description must be a valid URL or attachment.");
|
|
||||||
|
|
||||||
if (_items.Count is 0 or > MaxItems)
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(Items), $"Media gallery items count must be in range [1, {MaxItems}]");
|
|
||||||
|
|
||||||
return new(_items.Select(x => new MediaGalleryItem(new UnfurledMediaItem(x.Media.Url), x.Description, x.IsSpoiler)).ToImmutableArray(), Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
IMessageComponent IMessageComponentBuilder.Build() => Build();
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
public struct MediaGalleryItemProperties
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The maximum length of the description.
|
|
||||||
/// </summary>
|
|
||||||
public const int MaxDescriptionLength = 256;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the media item to display.
|
|
||||||
/// </summary>
|
|
||||||
public UnfurledMediaItemProperties Media { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the description of the media item.
|
|
||||||
/// </summary>
|
|
||||||
public string Description { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets whether the media item is a spoiler.
|
|
||||||
/// </summary>
|
|
||||||
public bool IsSpoiler { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="MediaGalleryItemProperties"/>.
|
|
||||||
/// </summary>
|
|
||||||
public MediaGalleryItemProperties() { }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="MediaGalleryItemProperties"/>.
|
|
||||||
/// </summary>
|
|
||||||
public MediaGalleryItemProperties(UnfurledMediaItemProperties media, string description = null, bool isSpoiler = false)
|
|
||||||
{
|
|
||||||
Media = media;
|
|
||||||
Description = description;
|
|
||||||
IsSpoiler = isSpoiler;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.Immutable;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Discord;
|
|
||||||
|
|
||||||
public class SectionBuilder : IMessageComponentBuilder, IStaticComponentContainer
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the maximum number of components allowed in this container.
|
|
||||||
/// </summary>
|
|
||||||
public const int MaxComponents = 3;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public ComponentType Type => ComponentType.Section;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the accessory component.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// Only supports <see cref="ButtonBuilder"/> and <see cref="ThumbnailBuilder"/> currently.
|
|
||||||
/// </remarks>
|
|
||||||
public IMessageComponentBuilder Accessory { get; set; }
|
|
||||||
|
|
||||||
private List<IMessageComponentBuilder> _components = new();
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
/// <remarks>
|
|
||||||
/// Only <see cref="TextDisplayBuilder"/> is supported.
|
|
||||||
/// </remarks>
|
|
||||||
public List<IMessageComponentBuilder> Components
|
|
||||||
{
|
|
||||||
get => _components;
|
|
||||||
set => _components = value ?? throw new ArgumentNullException(nameof(value), $"{nameof(Components)} cannot be null.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IComponentContainer.AddComponent"/>
|
|
||||||
/// <remarks>
|
|
||||||
/// Only <see cref="TextDisplayBuilder"/> is supported.
|
|
||||||
/// </remarks>
|
|
||||||
public SectionBuilder AddComponent(IMessageComponentBuilder component)
|
|
||||||
{
|
|
||||||
Components.Add(component);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IComponentContainer.AddComponents"/>
|
|
||||||
/// <remarks>
|
|
||||||
/// Only <see cref="TextDisplayBuilder"/> is supported.
|
|
||||||
/// </remarks>
|
|
||||||
public SectionBuilder AddComponents(params IMessageComponentBuilder[] components)
|
|
||||||
{
|
|
||||||
foreach (var component in components)
|
|
||||||
AddComponent(component);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IComponentContainer.WithComponents"/>
|
|
||||||
/// <remarks>
|
|
||||||
/// Only <see cref="TextDisplayBuilder"/> is supported.
|
|
||||||
/// </remarks>
|
|
||||||
public SectionBuilder WithComponents(IEnumerable<IMessageComponentBuilder> components)
|
|
||||||
{
|
|
||||||
Components = components.ToList();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the accessory component.
|
|
||||||
/// </summary>
|
|
||||||
public SectionBuilder WithAccessory(IMessageComponentBuilder accessory)
|
|
||||||
{
|
|
||||||
Accessory = accessory;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMessageComponentBuilder.Build"/>
|
|
||||||
public SectionComponent Build()
|
|
||||||
{
|
|
||||||
if (_components.Count is 0 or > MaxComponents)
|
|
||||||
throw new InvalidOperationException($"Section component can only contain {MaxComponents} child components!");
|
|
||||||
|
|
||||||
if (_components.Any(x => x is not TextDisplayBuilder))
|
|
||||||
throw new InvalidOperationException($"Section component can only contain {nameof(TextDisplayBuilder)}!");
|
|
||||||
|
|
||||||
if (Accessory is null)
|
|
||||||
throw new ArgumentNullException(nameof(Accessory), "A section must have an accessory");
|
|
||||||
|
|
||||||
if (Accessory is not ButtonBuilder and not ThumbnailBuilder)
|
|
||||||
throw new InvalidOperationException($"Accessory component can only be {nameof(ButtonBuilder)} or {nameof(ThumbnailBuilder)}!");
|
|
||||||
|
|
||||||
return new(Id, Components.Select(x => x.Build()).ToImmutableArray(), Accessory?.Build());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
IMessageComponent IMessageComponentBuilder.Build() => Build();
|
|
||||||
/// <inheritdoc/>
|
|
||||||
IComponentContainer IComponentContainer.AddComponent(IMessageComponentBuilder component) => AddComponent(component);
|
|
||||||
/// <inheritdoc/>
|
|
||||||
IComponentContainer IComponentContainer.AddComponents(params IMessageComponentBuilder[] components) => AddComponents(components);
|
|
||||||
/// <inheritdoc/>
|
|
||||||
IComponentContainer IComponentContainer.WithComponents(IEnumerable<IMessageComponentBuilder> components) => WithComponents(components.ToList());
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,7 @@ namespace Discord;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a class used to build <see cref="SelectMenuComponent"/>'s.
|
/// Represents a class used to build <see cref="SelectMenuComponent"/>'s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SelectMenuBuilder : IInteractableComponentBuilder
|
public class SelectMenuBuilder
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The max length of a <see cref="SelectMenuComponent.Placeholder"/>.
|
/// The max length of a <see cref="SelectMenuComponent.Placeholder"/>.
|
||||||
@@ -135,16 +135,13 @@ public class SelectMenuBuilder : IInteractableComponentBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
private List<SelectMenuOptionBuilder> _options = new List<SelectMenuOptionBuilder>();
|
||||||
public int? Id { get; set; }
|
|
||||||
|
|
||||||
private List<SelectMenuOptionBuilder> _options = [];
|
|
||||||
private int _minValues = 1;
|
private int _minValues = 1;
|
||||||
private int _maxValues = 1;
|
private int _maxValues = 1;
|
||||||
private string _placeholder;
|
private string _placeholder;
|
||||||
private string _customId;
|
private string _customId;
|
||||||
private ComponentType _type = ComponentType.SelectMenu;
|
private ComponentType _type = ComponentType.SelectMenu;
|
||||||
private List<SelectMenuDefaultValue> _defaultValues = [];
|
private List<SelectMenuDefaultValue> _defaultValues = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of a <see cref="SelectMenuBuilder"/>.
|
/// Creates a new instance of a <see cref="SelectMenuBuilder"/>.
|
||||||
@@ -165,7 +162,6 @@ public class SelectMenuBuilder : IInteractableComponentBuilder
|
|||||||
.Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.IsDefault))
|
.Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.IsDefault))
|
||||||
.ToList();
|
.ToList();
|
||||||
DefaultValues = selectMenu.DefaultValues?.ToList();
|
DefaultValues = selectMenu.DefaultValues?.ToList();
|
||||||
Id = selectMenu.Id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -180,7 +176,7 @@ public class SelectMenuBuilder : IInteractableComponentBuilder
|
|||||||
/// <param name="type">The <see cref="ComponentType"/> of this select menu.</param>
|
/// <param name="type">The <see cref="ComponentType"/> of this select menu.</param>
|
||||||
/// <param name="channelTypes">The types of channels this menu can select (only valid on <see cref="ComponentType.ChannelSelect"/>s)</param>
|
/// <param name="channelTypes">The types of channels this menu can select (only valid on <see cref="ComponentType.ChannelSelect"/>s)</param>
|
||||||
public SelectMenuBuilder(string customId, List<SelectMenuOptionBuilder> options = null, string placeholder = null, int maxValues = 1, int minValues = 1,
|
public SelectMenuBuilder(string customId, List<SelectMenuOptionBuilder> options = null, string placeholder = null, int maxValues = 1, int minValues = 1,
|
||||||
bool isDisabled = false, ComponentType type = ComponentType.SelectMenu, List<ChannelType> channelTypes = null, List<SelectMenuDefaultValue> defaultValues = null, int? id = null)
|
bool isDisabled = false, ComponentType type = ComponentType.SelectMenu, List<ChannelType> channelTypes = null, List<SelectMenuDefaultValue> defaultValues = null)
|
||||||
{
|
{
|
||||||
CustomId = customId;
|
CustomId = customId;
|
||||||
Options = options;
|
Options = options;
|
||||||
@@ -191,7 +187,6 @@ public class SelectMenuBuilder : IInteractableComponentBuilder
|
|||||||
Type = type;
|
Type = type;
|
||||||
ChannelTypes = channelTypes ?? new();
|
ChannelTypes = channelTypes ?? new();
|
||||||
DefaultValues = defaultValues ?? new();
|
DefaultValues = defaultValues ?? new();
|
||||||
Id = id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -405,9 +400,6 @@ public class SelectMenuBuilder : IInteractableComponentBuilder
|
|||||||
{
|
{
|
||||||
var options = Options?.Select(x => x.Build()).ToList();
|
var options = Options?.Select(x => x.Build()).ToList();
|
||||||
|
|
||||||
return new SelectMenuComponent(CustomId, options, Placeholder, MinValues, MaxValues, IsDisabled, Type, Id, ChannelTypes, DefaultValues);
|
return new SelectMenuComponent(CustomId, options, Placeholder, MinValues, MaxValues, IsDisabled, Type, ChannelTypes, DefaultValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
IMessageComponent IMessageComponentBuilder.Build() => Build();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
public class SeparatorBuilder : IMessageComponentBuilder
|
|
||||||
{
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public ComponentType Type => ComponentType.Separator;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets whether the component is a divider.
|
|
||||||
/// </summary>
|
|
||||||
public bool? IsDivider { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the spacing of the separator.
|
|
||||||
/// </summary>
|
|
||||||
public SeparatorSpacingSize? Spacing { get; set; }
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets whether the component is a divider.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current builder.
|
|
||||||
/// </returns>
|
|
||||||
public SeparatorBuilder WithIsDivider(bool? isDivider)
|
|
||||||
{
|
|
||||||
IsDivider = isDivider;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the spacing of the separator.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current builder.
|
|
||||||
/// </returns>
|
|
||||||
public SeparatorBuilder WithSpacing(SeparatorSpacingSize? spacing)
|
|
||||||
{
|
|
||||||
Spacing = spacing;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMessageComponentBuilder.Build"/>
|
|
||||||
public SeparatorComponent Build()
|
|
||||||
{
|
|
||||||
return new(IsDivider, Spacing, Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
IMessageComponent IMessageComponentBuilder.Build() => Build();
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace Discord;
|
|
||||||
|
|
||||||
public class TextDisplayBuilder : IMessageComponentBuilder
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The maximum length of the content.
|
|
||||||
/// </summary>
|
|
||||||
public const int MaxContentLength = 4096;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public ComponentType Type => ComponentType.ActionRow;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the content of the text display.
|
|
||||||
/// </summary>
|
|
||||||
public string Content { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new <see cref="TextDisplayBuilder"/>.
|
|
||||||
/// </summary>
|
|
||||||
public TextDisplayBuilder() { }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new <see cref="TextDisplayBuilder"/> with the specified content.
|
|
||||||
/// </summary>
|
|
||||||
public TextDisplayBuilder(string content, int? id = null)
|
|
||||||
{
|
|
||||||
Content = content;
|
|
||||||
Id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the content of the text display.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current builder.
|
|
||||||
/// </returns>
|
|
||||||
public TextDisplayBuilder WithContent(string content)
|
|
||||||
{
|
|
||||||
Content = content;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMessageComponentBuilder.Build"/>
|
|
||||||
public TextDisplayComponent Build()
|
|
||||||
{
|
|
||||||
if (Content.Length > MaxContentLength)
|
|
||||||
throw new ArgumentException($"Content length must be less than or equal to {MaxContentLength}.", nameof(Content));
|
|
||||||
|
|
||||||
return new(Content, Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
IMessageComponent IMessageComponentBuilder.Build() => Build();
|
|
||||||
}
|
|
||||||
@@ -6,10 +6,8 @@ namespace Discord;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a builder for creating a <see cref="TextInputComponent"/>.
|
/// Represents a builder for creating a <see cref="TextInputComponent"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TextInputBuilder : IInteractableComponentBuilder
|
public class TextInputBuilder
|
||||||
{
|
{
|
||||||
public ComponentType Type => ComponentType.TextInput;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The max length of a <see cref="TextInputComponent.Placeholder"/>.
|
/// The max length of a <see cref="TextInputComponent.Placeholder"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -101,8 +99,6 @@ public class TextInputBuilder : IInteractableComponentBuilder
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool? Required { get; set; }
|
public bool? Required { get; set; }
|
||||||
|
|
||||||
public int? Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the default value of the text input.
|
/// Gets or sets the default value of the text input.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -144,7 +140,7 @@ public class TextInputBuilder : IInteractableComponentBuilder
|
|||||||
/// <param name="maxLength">The text input's maximum length.</param>
|
/// <param name="maxLength">The text input's maximum length.</param>
|
||||||
/// <param name="required">The text input's required value.</param>
|
/// <param name="required">The text input's required value.</param>
|
||||||
public TextInputBuilder(string label, string customId, TextInputStyle style = TextInputStyle.Short, string placeholder = null,
|
public TextInputBuilder(string label, string customId, TextInputStyle style = TextInputStyle.Short, string placeholder = null,
|
||||||
int? minLength = null, int? maxLength = null, bool? required = null, string value = null, int? id = null)
|
int? minLength = null, int? maxLength = null, bool? required = null, string value = null)
|
||||||
{
|
{
|
||||||
Label = label;
|
Label = label;
|
||||||
Style = style;
|
Style = style;
|
||||||
@@ -154,7 +150,6 @@ public class TextInputBuilder : IInteractableComponentBuilder
|
|||||||
MaxLength = maxLength;
|
MaxLength = maxLength;
|
||||||
Required = required;
|
Required = required;
|
||||||
Value = value;
|
Value = value;
|
||||||
Id = id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -262,8 +257,6 @@ public class TextInputBuilder : IInteractableComponentBuilder
|
|||||||
if (Style is TextInputStyle.Short && Value?.Any(x => x == '\n') is true)
|
if (Style is TextInputStyle.Short && Value?.Any(x => x == '\n') is true)
|
||||||
throw new ArgumentException($"Value must not contain new line characters when style is {TextInputStyle.Short}.", nameof(Value));
|
throw new ArgumentException($"Value must not contain new line characters when style is {TextInputStyle.Short}.", nameof(Value));
|
||||||
|
|
||||||
return new TextInputComponent(CustomId, Label, Placeholder, MinLength, MaxLength, Style, Required, Value, Id);
|
return new TextInputComponent(CustomId, Label, Placeholder, MinLength, MaxLength, Style, Required, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
IMessageComponent IMessageComponentBuilder.Build() => Build();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,95 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace Discord;
|
|
||||||
|
|
||||||
public class ThumbnailBuilder : IMessageComponentBuilder
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the maximum length of the description.
|
|
||||||
/// </summary>
|
|
||||||
public const int MaxDescriptionLength = 1024;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public ComponentType Type => ComponentType.Thumbnail;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the media of the thumbnail.
|
|
||||||
/// </summary>
|
|
||||||
public UnfurledMediaItemProperties Media { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the description of the thumbnail.
|
|
||||||
/// </summary>
|
|
||||||
public string Description { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets whether the thumbnail is a spoiler.
|
|
||||||
/// </summary>
|
|
||||||
public bool IsSpoiler { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ThumbnailBuilder"/>.
|
|
||||||
/// </summary>
|
|
||||||
public ThumbnailBuilder() { }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ThumbnailBuilder"/>.
|
|
||||||
/// </summary>
|
|
||||||
public ThumbnailBuilder(UnfurledMediaItemProperties media, string description = null, bool isSpoiler = false)
|
|
||||||
{
|
|
||||||
Media = media;
|
|
||||||
Description = description;
|
|
||||||
IsSpoiler = isSpoiler;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the media of the thumbnail.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current builder.
|
|
||||||
/// </returns>
|
|
||||||
public ThumbnailBuilder WithMedia(UnfurledMediaItemProperties media)
|
|
||||||
{
|
|
||||||
Media = media;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the description of the thumbnail.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current builder.
|
|
||||||
/// </returns>
|
|
||||||
public ThumbnailBuilder WithDescription(string description)
|
|
||||||
{
|
|
||||||
Description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets whether the thumbnail is a spoiler.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The current builder.
|
|
||||||
/// </returns>
|
|
||||||
public ThumbnailBuilder WithSpoiler(bool isSpoiler)
|
|
||||||
{
|
|
||||||
IsSpoiler = isSpoiler;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMessageComponentBuilder.Build"/>
|
|
||||||
public ThumbnailComponent Build()
|
|
||||||
{
|
|
||||||
if (Description is not null && Description.Length > MaxDescriptionLength)
|
|
||||||
throw new ArgumentException($"Description length must be less than or equal to {MaxDescriptionLength}.", nameof(Description));
|
|
||||||
|
|
||||||
return new(Id, new UnfurledMediaItem(Media.Url), Description, IsSpoiler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
IMessageComponent IMessageComponentBuilder.Build() => Build();
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
public struct UnfurledMediaItemProperties
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the URL of the media item.
|
|
||||||
/// </summary>
|
|
||||||
public string Url { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="UnfurledMediaItemProperties"/>.
|
|
||||||
/// </summary>
|
|
||||||
public UnfurledMediaItemProperties() {}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="UnfurledMediaItemProperties"/>.
|
|
||||||
/// </summary>
|
|
||||||
public UnfurledMediaItemProperties(string url)
|
|
||||||
{
|
|
||||||
Url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static implicit operator UnfurledMediaItemProperties(string url) => new(url);
|
|
||||||
}
|
|
||||||
@@ -3,14 +3,11 @@ namespace Discord;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a <see cref="IMessageComponent"/> Button.
|
/// Represents a <see cref="IMessageComponent"/> Button.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ButtonComponent : IInteractableComponent
|
public class ButtonComponent : IMessageComponent
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public ComponentType Type => ComponentType.Button;
|
public ComponentType Type => ComponentType.Button;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="ButtonStyle"/> of this button, example buttons with each style can be found <see href="https://discord.com/assets/7bb017ce52cfd6575e21c058feb3883b.png">Here</see>.
|
/// Gets the <see cref="ButtonStyle"/> of this button, example buttons with each style can be found <see href="https://discord.com/assets/7bb017ce52cfd6575e21c058feb3883b.png">Here</see>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -59,10 +56,9 @@ public class ButtonComponent : IInteractableComponent
|
|||||||
public ButtonBuilder ToBuilder()
|
public ButtonBuilder ToBuilder()
|
||||||
=> new (Label, CustomId, Style, Url, Emote, IsDisabled);
|
=> new (Label, CustomId, Style, Url, Emote, IsDisabled);
|
||||||
|
|
||||||
internal ButtonComponent(ButtonStyle style, string label, IEmote emote, string customId, string url, bool isDisabled, ulong? skuId, int? id)
|
internal ButtonComponent(ButtonStyle style, string label, IEmote emote, string customId, string url, bool isDisabled, ulong? skuId)
|
||||||
{
|
{
|
||||||
Style = style;
|
Style = style;
|
||||||
Id = id;
|
|
||||||
Label = label;
|
Label = label;
|
||||||
Emote = emote;
|
Emote = emote;
|
||||||
CustomId = customId;
|
CustomId = customId;
|
||||||
|
|||||||
@@ -44,19 +44,5 @@ namespace Discord
|
|||||||
/// A select menu for picking from channels.
|
/// A select menu for picking from channels.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ChannelSelect = 8,
|
ChannelSelect = 8,
|
||||||
|
|
||||||
Section = 9,
|
|
||||||
|
|
||||||
TextDisplay = 10,
|
|
||||||
|
|
||||||
Thumbnail = 11,
|
|
||||||
|
|
||||||
MediaGallery = 12,
|
|
||||||
|
|
||||||
File = 13,
|
|
||||||
|
|
||||||
Separator = 14,
|
|
||||||
|
|
||||||
Container = 17,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a container component.
|
|
||||||
/// </summary>
|
|
||||||
public class ContainerComponent : IMessageComponent
|
|
||||||
{
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public ComponentType Type => ComponentType.Container;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the components in this container.
|
|
||||||
/// </summary>
|
|
||||||
public IReadOnlyCollection<IMessageComponent> Components { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the accent color of this container.
|
|
||||||
/// </summary>
|
|
||||||
public uint? AccentColor { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets whether this container is a spoiler.
|
|
||||||
/// </summary>
|
|
||||||
public bool? IsSpoiler { get; }
|
|
||||||
|
|
||||||
internal ContainerComponent(IReadOnlyCollection<IMessageComponent> components, uint? accentColor, bool? isSpoiler, int? id = null)
|
|
||||||
{
|
|
||||||
Components = components;
|
|
||||||
AccentColor = accentColor;
|
|
||||||
IsSpoiler = isSpoiler;
|
|
||||||
Id = id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a file component.
|
|
||||||
/// </summary>
|
|
||||||
public class FileComponent : IMessageComponent
|
|
||||||
{
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public ComponentType Type => ComponentType.File;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the file of this component.
|
|
||||||
/// </summary>
|
|
||||||
public UnfurledMediaItem File { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets whether this file is a spoiler.
|
|
||||||
/// </summary>
|
|
||||||
public bool? IsSpoiler { get; }
|
|
||||||
|
|
||||||
internal FileComponent(UnfurledMediaItem file, bool? isSpoiler, int? id = null)
|
|
||||||
{
|
|
||||||
File = file;
|
|
||||||
IsSpoiler = isSpoiler;
|
|
||||||
Id = id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a message component that can be interacted with.
|
|
||||||
/// </summary>
|
|
||||||
public interface IInteractableComponent : IMessageComponent
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the custom id of the component if possible; otherwise <see langword="null"/>.
|
|
||||||
/// </summary>
|
|
||||||
string CustomId { get; }
|
|
||||||
}
|
|
||||||
@@ -1,14 +1,18 @@
|
|||||||
namespace Discord;
|
namespace Discord
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a message component on a message.
|
|
||||||
/// </summary>
|
|
||||||
public interface IMessageComponent
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="ComponentType"/> of this Message Component.
|
/// Represents a message component on a message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ComponentType Type { get; }
|
public interface IMessageComponent
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the <see cref="ComponentType"/> of this Message Component.
|
||||||
|
/// </summary>
|
||||||
|
ComponentType Type { get; }
|
||||||
|
|
||||||
int? Id { get; }
|
/// <summary>
|
||||||
|
/// Gets the custom id of the component if possible; otherwise <see langword="null"/>.
|
||||||
|
/// </summary>
|
||||||
|
string CustomId { get; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a media gallery component.
|
|
||||||
/// </summary>
|
|
||||||
public class MediaGalleryComponent : IMessageComponent
|
|
||||||
{
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public ComponentType Type => ComponentType.MediaGallery;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the items in this media gallery.
|
|
||||||
/// </summary>
|
|
||||||
public IReadOnlyCollection<MediaGalleryItem> Items { get; }
|
|
||||||
|
|
||||||
internal MediaGalleryComponent(IReadOnlyCollection<MediaGalleryItem> items, int? id)
|
|
||||||
{
|
|
||||||
Items = items;
|
|
||||||
Id = id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a media gallery item.
|
|
||||||
/// </summary>
|
|
||||||
public readonly struct MediaGalleryItem
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the media for this item.
|
|
||||||
/// </summary>
|
|
||||||
public UnfurledMediaItem Media { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the description for this item.
|
|
||||||
/// </summary>
|
|
||||||
public string Description { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets whether this item is a spoiler.
|
|
||||||
/// </summary>
|
|
||||||
public bool IsSpoiler { get; }
|
|
||||||
|
|
||||||
internal MediaGalleryItem(UnfurledMediaItem media, string description, bool? isSpoiler)
|
|
||||||
{
|
|
||||||
Media = media;
|
|
||||||
Description = description;
|
|
||||||
IsSpoiler = isSpoiler ?? false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +1,26 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Discord;
|
namespace Discord
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a component object used to send components with messages.
|
|
||||||
/// </summary>
|
|
||||||
public class MessageComponent
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the components to be used in a message.
|
/// Represents a component object used to send components with messages.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IReadOnlyCollection<IMessageComponent> Components { get; }
|
public class MessageComponent
|
||||||
|
|
||||||
internal MessageComponent(List<IMessageComponent> components)
|
|
||||||
{
|
{
|
||||||
Components = components;
|
/// <summary>
|
||||||
}
|
/// Gets the components to be used in a message.
|
||||||
|
/// </summary>
|
||||||
|
public IReadOnlyCollection<ActionRowComponent> Components { get; }
|
||||||
|
|
||||||
/// <summary>
|
internal MessageComponent(List<ActionRowComponent> components)
|
||||||
/// Returns a empty <see cref="MessageComponent"/>.
|
{
|
||||||
/// </summary>
|
Components = components;
|
||||||
internal static MessageComponent Empty
|
}
|
||||||
=> new([]);
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a empty <see cref="MessageComponent"/>.
|
||||||
|
/// </summary>
|
||||||
|
internal static MessageComponent Empty
|
||||||
|
=> new MessageComponent(new List<ActionRowComponent>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a media item that has been unfurled and resolved.
|
|
||||||
/// </summary>
|
|
||||||
public class ResolvedUnfurledMediaItem : UnfurledMediaItem
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the proxy URL for this media item.
|
|
||||||
/// </summary>
|
|
||||||
public string ProxyUrl { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the height of this media item.
|
|
||||||
/// </summary>
|
|
||||||
public int Height { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the width of this media item.
|
|
||||||
/// </summary>
|
|
||||||
public int Width { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the content type of this media item.
|
|
||||||
/// </summary>
|
|
||||||
public string ContentType { get;}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the loading state of this media item.
|
|
||||||
/// </summary>
|
|
||||||
public UnfurledMediaItemLoadingState LoadingState { get; }
|
|
||||||
|
|
||||||
internal ResolvedUnfurledMediaItem(string url, string proxyUrl, int height, int width, string contentType, UnfurledMediaItemLoadingState loadingState) : base(url)
|
|
||||||
{
|
|
||||||
ProxyUrl = proxyUrl;
|
|
||||||
Height = height;
|
|
||||||
Width = width;
|
|
||||||
ContentType = contentType;
|
|
||||||
LoadingState = loadingState;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a section component.
|
|
||||||
/// </summary>
|
|
||||||
public class SectionComponent : IMessageComponent
|
|
||||||
{
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public ComponentType Type => ComponentType.Section;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the components in this section.
|
|
||||||
/// </summary>
|
|
||||||
public IReadOnlyCollection<IMessageComponent> Components { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the accessory of this section.
|
|
||||||
/// </summary>
|
|
||||||
public IMessageComponent Accessory { get; }
|
|
||||||
|
|
||||||
internal SectionComponent(int? id, IReadOnlyCollection<IMessageComponent> components, IMessageComponent accessory)
|
|
||||||
{
|
|
||||||
Id = id;
|
|
||||||
Components = components;
|
|
||||||
Accessory = accessory;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,14 +7,11 @@ namespace Discord
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a select menu component defined at <see href="https://discord.com/developers/docs/interactions/message-components#select-menu-object"/>
|
/// Represents a select menu component defined at <see href="https://discord.com/developers/docs/interactions/message-components#select-menu-object"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SelectMenuComponent : IInteractableComponent
|
public class SelectMenuComponent : IMessageComponent
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public ComponentType Type { get; }
|
public ComponentType Type { get; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; }
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string CustomId { get; }
|
public string CustomId { get; }
|
||||||
|
|
||||||
@@ -70,7 +67,7 @@ namespace Discord
|
|||||||
DefaultValues.ToList());
|
DefaultValues.ToList());
|
||||||
|
|
||||||
internal SelectMenuComponent(string customId, List<SelectMenuOption> options, string placeholder, int minValues, int maxValues,
|
internal SelectMenuComponent(string customId, List<SelectMenuOption> options, string placeholder, int minValues, int maxValues,
|
||||||
bool disabled, ComponentType type, int? id, IEnumerable<ChannelType> channelTypes = null, IEnumerable<SelectMenuDefaultValue> defaultValues = null)
|
bool disabled, ComponentType type, IEnumerable<ChannelType> channelTypes = null, IEnumerable<SelectMenuDefaultValue> defaultValues = null)
|
||||||
{
|
{
|
||||||
CustomId = customId;
|
CustomId = customId;
|
||||||
Options = options;
|
Options = options;
|
||||||
@@ -79,9 +76,8 @@ namespace Discord
|
|||||||
MaxValues = maxValues;
|
MaxValues = maxValues;
|
||||||
IsDisabled = disabled;
|
IsDisabled = disabled;
|
||||||
Type = type;
|
Type = type;
|
||||||
Id = id;
|
ChannelTypes = channelTypes?.ToArray() ?? Array.Empty<ChannelType>();
|
||||||
ChannelTypes = channelTypes?.ToArray() ?? [];
|
DefaultValues = defaultValues?.ToArray() ?? Array.Empty<SelectMenuDefaultValue>();
|
||||||
DefaultValues = defaultValues?.ToArray() ?? [];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a separator component.
|
|
||||||
/// </summary>
|
|
||||||
public class SeparatorComponent : IMessageComponent
|
|
||||||
{
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public ComponentType Type => ComponentType.Separator;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets whether this component is a divider.
|
|
||||||
/// </summary>
|
|
||||||
public bool? IsDivider { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the spacing of this component.
|
|
||||||
/// </summary>
|
|
||||||
public SeparatorSpacingSize? Spacing { get; }
|
|
||||||
|
|
||||||
internal SeparatorComponent(bool? isDivider, SeparatorSpacingSize? spacing, int? id = null)
|
|
||||||
{
|
|
||||||
IsDivider = isDivider;
|
|
||||||
Spacing = spacing;
|
|
||||||
Id = id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents the spacing of a separator component.
|
|
||||||
/// </summary>
|
|
||||||
public enum SeparatorSpacingSize
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The separator has a small spacing.
|
|
||||||
/// </summary>
|
|
||||||
Small = 1,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The separator has a large spacing.
|
|
||||||
/// </summary>
|
|
||||||
Large = 2
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a text display component.
|
|
||||||
/// </summary>
|
|
||||||
public class TextDisplayComponent : IMessageComponent
|
|
||||||
{
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public ComponentType Type => ComponentType.TextDisplay;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the content of this component.
|
|
||||||
/// </summary>
|
|
||||||
public string Content { get; }
|
|
||||||
|
|
||||||
internal TextDisplayComponent(string content, int? id = null)
|
|
||||||
{
|
|
||||||
Id = id;
|
|
||||||
Content = content;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@ namespace Discord
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a <see cref="IMessageComponent"/> text input.
|
/// Represents a <see cref="IMessageComponent"/> text input.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TextInputComponent : IInteractableComponent
|
public class TextInputComponent : IMessageComponent
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public ComponentType Type => ComponentType.TextInput;
|
public ComponentType Type => ComponentType.TextInput;
|
||||||
@@ -11,9 +11,6 @@ namespace Discord
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string CustomId { get; }
|
public string CustomId { get; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the label of the component; this is the text shown above it.
|
/// Gets the label of the component; this is the text shown above it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -50,7 +47,7 @@ namespace Discord
|
|||||||
public string Value { get; }
|
public string Value { get; }
|
||||||
|
|
||||||
internal TextInputComponent(string customId, string label, string placeholder, int? minLength, int? maxLength,
|
internal TextInputComponent(string customId, string label, string placeholder, int? minLength, int? maxLength,
|
||||||
TextInputStyle style, bool? required, string value, int? id)
|
TextInputStyle style, bool? required, string value)
|
||||||
{
|
{
|
||||||
CustomId = customId;
|
CustomId = customId;
|
||||||
Label = label;
|
Label = label;
|
||||||
@@ -60,7 +57,6 @@ namespace Discord
|
|||||||
Style = style;
|
Style = style;
|
||||||
Required = required;
|
Required = required;
|
||||||
Value = value;
|
Value = value;
|
||||||
Id = id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ namespace Discord
|
|||||||
/// Intended for short, single-line text.
|
/// Intended for short, single-line text.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Short = 1,
|
Short = 1,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Intended for longer or multiline text.
|
/// Intended for longer or multiline text.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a thumbnail component.
|
|
||||||
/// </summary>
|
|
||||||
public class ThumbnailComponent : IMessageComponent
|
|
||||||
{
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public ComponentType Type => ComponentType.Thumbnail;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public int? Id { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the media of the component.
|
|
||||||
/// </summary>
|
|
||||||
public UnfurledMediaItem Media { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the description of the component.
|
|
||||||
/// </summary>
|
|
||||||
public string Description { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets whether the component is a spoiler.
|
|
||||||
/// </summary>
|
|
||||||
public bool IsSpoiler { get; }
|
|
||||||
|
|
||||||
internal ThumbnailComponent(int? id, UnfurledMediaItem media, string description, bool? isSpoiler)
|
|
||||||
{
|
|
||||||
Id = id;
|
|
||||||
Media = media;
|
|
||||||
Description = description;
|
|
||||||
IsSpoiler = isSpoiler ?? false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a media item that has been unfurled.
|
|
||||||
/// </summary>
|
|
||||||
public class UnfurledMediaItem
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the URL of this media item.
|
|
||||||
/// </summary>
|
|
||||||
public string Url { get; }
|
|
||||||
|
|
||||||
internal UnfurledMediaItem(string url)
|
|
||||||
{
|
|
||||||
Url = url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
namespace Discord;
|
|
||||||
|
|
||||||
public enum UnfurledMediaItemLoadingState
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The state of the media item is unknown.
|
|
||||||
/// </summary>
|
|
||||||
Unknown = 0,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The media item is currently loading.
|
|
||||||
/// </summary>
|
|
||||||
Loading = 1,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The media item was successfully loaded.
|
|
||||||
/// </summary>
|
|
||||||
LoadingSuccess = 2,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The media item was not found.
|
|
||||||
/// </summary>
|
|
||||||
LoadingNotFound = 3
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Discord
|
namespace Discord
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a modal interaction.
|
/// Represents a modal interaction.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Modal
|
public class Modal : IMessageComponent
|
||||||
{
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public ComponentType Type => throw new NotSupportedException("Modals do not have a component type.");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the title of the modal.
|
/// Gets the title of the modal.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -111,20 +111,21 @@ namespace Discord
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a <typeparamref name="TMessageComponentBuilder"/> by the specified <paramref name="customId"/>.
|
/// Gets a <typeparamref name="TMessageComponent"/> by the specified <paramref name="customId"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TMessageComponentBuilder">The type of the component to get.</typeparam>
|
/// <typeparam name="TMessageComponent">The type of the component to get.</typeparam>
|
||||||
/// <param name="customId">The <see cref="IInteractableComponentBuilder.CustomId"/> of the component to get.</param>
|
/// <param name="customId">The <see cref="IMessageComponent.CustomId"/> of the component to get.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// The component of type <typeparamref name="TMessageComponentBuilder"/> that was found, <see langword="null"/> otherwise.
|
/// The component of type <typeparamref name="TMessageComponent"/> that was found, <see langword="null"/> otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public TMessageComponentBuilder GetComponent<TMessageComponentBuilder>(string customId)
|
public TMessageComponent GetComponent<TMessageComponent>(string customId)
|
||||||
where TMessageComponentBuilder : class, IInteractableComponentBuilder
|
where TMessageComponent : class, IMessageComponent
|
||||||
{
|
{
|
||||||
Preconditions.NotNull(customId, nameof(customId));
|
Preconditions.NotNull(customId, nameof(customId));
|
||||||
|
|
||||||
return Components.ActionRows?.SelectMany(r => r.Components.OfType<TMessageComponentBuilder>())
|
return Components.ActionRows
|
||||||
.FirstOrDefault(c => c.CustomId == customId);
|
?.SelectMany(r => r.Components.OfType<TMessageComponent>())
|
||||||
|
.FirstOrDefault(c => c?.CustomId == customId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -140,7 +141,7 @@ namespace Discord
|
|||||||
{
|
{
|
||||||
Preconditions.NotNull(customId, nameof(customId));
|
Preconditions.NotNull(customId, nameof(customId));
|
||||||
|
|
||||||
var component = GetComponent<TextInputBuilder>(customId) ?? throw new ArgumentException($"There is no component of type {nameof(TextInputComponent)} with the specified custom ID in this modal builder.", nameof(customId));
|
var component = GetComponent<TextInputComponent>(customId) ?? throw new ArgumentException($"There is no component of type {nameof(TextInputComponent)} with the specified custom ID in this modal builder.", nameof(customId));
|
||||||
var row = Components.ActionRows.First(r => r.Components.Contains(component));
|
var row = Components.ActionRows.First(r => r.Components.Contains(component));
|
||||||
|
|
||||||
var builder = new TextInputBuilder
|
var builder = new TextInputBuilder
|
||||||
@@ -158,7 +159,7 @@ namespace Discord
|
|||||||
updateTextInput(builder);
|
updateTextInput(builder);
|
||||||
|
|
||||||
row.Components.Remove(component);
|
row.Components.Remove(component);
|
||||||
row.AddComponent(builder);
|
row.AddComponent(builder.Build());
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -178,13 +179,13 @@ namespace Discord
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes a component from this builder by the specified <paramref name="customId"/>.
|
/// Removes a component from this builder by the specified <paramref name="customId"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="customId">The <see cref="IInteractableComponent.CustomId"/> of the component to remove.</param>
|
/// <param name="customId">The <see cref="IMessageComponent.CustomId"/> of the component to remove.</param>
|
||||||
/// <returns>The current builder.</returns>
|
/// <returns>The current builder.</returns>
|
||||||
public ModalBuilder RemoveComponent(string customId)
|
public ModalBuilder RemoveComponent(string customId)
|
||||||
{
|
{
|
||||||
Preconditions.NotNull(customId, nameof(customId));
|
Preconditions.NotNull(customId, nameof(customId));
|
||||||
|
|
||||||
Components.ActionRows?.ForEach(r => r.Components.RemoveAll(c => c is IInteractableComponentBuilder ic && ic.CustomId == customId));
|
Components.ActionRows?.ForEach(r => r.Components.RemoveAll(c => c.CustomId == customId));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,7 +226,7 @@ namespace Discord
|
|||||||
public class ModalComponentBuilder
|
public class ModalComponentBuilder
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The max length of a <see cref="IInteractableComponent.CustomId"/>.
|
/// The max length of a <see cref="IMessageComponent.CustomId"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int MaxCustomIdLength = 100;
|
public const int MaxCustomIdLength = 100;
|
||||||
|
|
||||||
@@ -313,17 +314,19 @@ namespace Discord
|
|||||||
{
|
{
|
||||||
Preconditions.LessThan(row, MaxActionRowCount, nameof(row));
|
Preconditions.LessThan(row, MaxActionRowCount, nameof(row));
|
||||||
|
|
||||||
|
var builtButton = text.Build();
|
||||||
|
|
||||||
if (_actionRows == null)
|
if (_actionRows == null)
|
||||||
{
|
{
|
||||||
_actionRows = new List<ActionRowBuilder>
|
_actionRows = new List<ActionRowBuilder>
|
||||||
{
|
{
|
||||||
new ActionRowBuilder().AddComponent(text)
|
new ActionRowBuilder().AddComponent(builtButton)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_actionRows.Count == row)
|
if (_actionRows.Count == row)
|
||||||
_actionRows.Add(new ActionRowBuilder().AddComponent(text));
|
_actionRows.Add(new ActionRowBuilder().AddComponent(builtButton));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ActionRowBuilder actionRow;
|
ActionRowBuilder actionRow;
|
||||||
@@ -335,8 +338,8 @@ namespace Discord
|
|||||||
_actionRows.Add(actionRow);
|
_actionRows.Add(actionRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actionRow.CanTakeComponent(text))
|
if (actionRow.CanTakeComponent(builtButton))
|
||||||
actionRow.AddComponent(text);
|
actionRow.AddComponent(builtButton);
|
||||||
else if (row < MaxActionRowCount)
|
else if (row < MaxActionRowCount)
|
||||||
WithTextInput(text, row + 1);
|
WithTextInput(text, row + 1);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -123,16 +123,5 @@ namespace Discord
|
|||||||
_isDisposed = true;
|
_isDisposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the url formatted with <c>attachment://</c> protocol.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>
|
|
||||||
/// The formatted url.
|
|
||||||
/// </returns>
|
|
||||||
public string GetAttachmentUrl()
|
|
||||||
{
|
|
||||||
return $"attachment://{FileName}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,10 +57,5 @@ namespace Discord
|
|||||||
/// This message is a voice message.
|
/// This message is a voice message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
VoiceMessage = 1 << 13,
|
VoiceMessage = 1 << 13,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This message is using v2 components.
|
|
||||||
/// </summary>
|
|
||||||
ComponentsV2 = 1 << 15,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -401,11 +401,5 @@ namespace Discord
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static void ValidateMessageFlags(MessageFlags flags)
|
|
||||||
{
|
|
||||||
if (flags is not MessageFlags.None and not MessageFlags.SuppressEmbeds and not MessageFlags.SuppressNotification and not MessageFlags.ComponentsV2 and not MessageFlags.Ephemeral)
|
|
||||||
throw new ArgumentException("The only valid MessageFlags are Ephemeral, SuppressEmbeds, SuppressNotification, ComponentsV2 and None.", nameof(flags));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,55 +44,55 @@ namespace Discord.Interactions
|
|||||||
protected virtual Task DeferAsync(bool ephemeral = false, RequestOptions options = null)
|
protected virtual Task DeferAsync(bool ephemeral = false, RequestOptions options = null)
|
||||||
=> Context.Interaction.DeferAsync(ephemeral, options);
|
=> Context.Interaction.DeferAsync(ephemeral, options);
|
||||||
|
|
||||||
/// <inheritdoc cref="IDiscordInteraction.RespondAsync(string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)"/>
|
/// <inheritdoc cref="IDiscordInteraction.RespondAsync(string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)"/>
|
||||||
protected virtual Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
protected virtual Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, Embed embed = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, Embed embed = null, PollProperties poll = null)
|
||||||
=> Context.Interaction.RespondAsync(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
=> Context.Interaction.RespondAsync(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
|
|
||||||
/// <inheritdoc cref="IDiscordInteraction.RespondWithFileAsync(Stream, string, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)"/>
|
/// <inheritdoc cref="IDiscordInteraction.RespondWithFileAsync(Stream, string, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)"/>
|
||||||
protected virtual Task RespondWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
protected virtual Task RespondWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> Context.Interaction.RespondWithFileAsync(fileStream, fileName, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
=> Context.Interaction.RespondWithFileAsync(fileStream, fileName, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
|
|
||||||
/// <inheritdoc cref="IDiscordInteraction.RespondWithFileAsync(string, string, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)"/>
|
/// <inheritdoc cref="IDiscordInteraction.RespondWithFileAsync(string, string, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)"/>
|
||||||
protected virtual Task RespondWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
protected virtual Task RespondWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> Context.Interaction.RespondWithFileAsync(filePath, fileName, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
=> Context.Interaction.RespondWithFileAsync(filePath, fileName, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
|
|
||||||
/// <inheritdoc cref="IDiscordInteraction.RespondWithFileAsync(FileAttachment, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)"/>
|
/// <inheritdoc cref="IDiscordInteraction.RespondWithFileAsync(FileAttachment, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)"/>
|
||||||
protected virtual Task RespondWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
protected virtual Task RespondWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> Context.Interaction.RespondWithFileAsync(attachment, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
=> Context.Interaction.RespondWithFileAsync(attachment, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
|
|
||||||
/// <inheritdoc cref="IDiscordInteraction.RespondWithFilesAsync(IEnumerable{FileAttachment}, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)"/>
|
/// <inheritdoc cref="IDiscordInteraction.RespondWithFilesAsync(IEnumerable{FileAttachment}, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)"/>
|
||||||
protected virtual Task RespondWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
protected virtual Task RespondWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> Context.Interaction.RespondWithFilesAsync(attachments, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
=> Context.Interaction.RespondWithFilesAsync(attachments, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
|
|
||||||
/// <inheritdoc cref="IDiscordInteraction.FollowupAsync(string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)"/>
|
/// <inheritdoc cref="IDiscordInteraction.FollowupAsync(string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)"/>
|
||||||
protected virtual Task<IUserMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
protected virtual Task<IUserMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, Embed embed = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, Embed embed = null, PollProperties poll = null)
|
||||||
=> Context.Interaction.FollowupAsync(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
=> Context.Interaction.FollowupAsync(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
|
|
||||||
/// <inheritdoc cref="IDiscordInteraction.FollowupWithFileAsync(Stream, string, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)"/>
|
/// <inheritdoc cref="IDiscordInteraction.FollowupWithFileAsync(Stream, string, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)"/>
|
||||||
protected virtual Task<IUserMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
protected virtual Task<IUserMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> Context.Interaction.FollowupWithFileAsync(fileStream, fileName, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
=> Context.Interaction.FollowupWithFileAsync(fileStream, fileName, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
|
|
||||||
/// <inheritdoc cref="IDiscordInteraction.FollowupWithFileAsync(string, string, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)"/>
|
/// <inheritdoc cref="IDiscordInteraction.FollowupWithFileAsync(string, string, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)"/>
|
||||||
protected virtual Task<IUserMessage> FollowupWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
protected virtual Task<IUserMessage> FollowupWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> Context.Interaction.FollowupWithFileAsync(filePath, fileName, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
=> Context.Interaction.FollowupWithFileAsync(filePath, fileName, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
|
|
||||||
/// <inheritdoc cref="IDiscordInteraction.FollowupWithFileAsync(FileAttachment, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)"/>
|
/// <inheritdoc cref="IDiscordInteraction.FollowupWithFileAsync(FileAttachment, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)"/>
|
||||||
protected virtual Task<IUserMessage> FollowupWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
protected virtual Task<IUserMessage> FollowupWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> Context.Interaction.FollowupWithFileAsync(attachment, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
=> Context.Interaction.FollowupWithFileAsync(attachment, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
|
|
||||||
/// <inheritdoc cref="IDiscordInteraction.FollowupWithFilesAsync(IEnumerable{FileAttachment}, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)"/>
|
/// <inheritdoc cref="IDiscordInteraction.FollowupWithFilesAsync(IEnumerable{FileAttachment}, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)"/>
|
||||||
protected virtual Task<IUserMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
protected virtual Task<IUserMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> Context.Interaction.FollowupWithFilesAsync(attachments, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
=> Context.Interaction.FollowupWithFilesAsync(attachments, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
|
|
||||||
/// <inheritdoc cref="IMessageChannel.SendMessageAsync(string, bool, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags, PollProperties)"/>
|
/// <inheritdoc cref="IMessageChannel.SendMessageAsync(string, bool, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags, PollProperties)"/>
|
||||||
protected virtual Task<IUserMessage> ReplyAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null,
|
protected virtual Task<IUserMessage> ReplyAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null,
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ namespace Discord.Interactions
|
|||||||
/// A Task representing the operation of creating the interaction response.
|
/// A Task representing the operation of creating the interaction response.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="InvalidOperationException">Thrown if the interaction isn't a type of <see cref="RestInteraction"/>.</exception>
|
/// <exception cref="InvalidOperationException">Thrown if the interaction isn't a type of <see cref="RestInteraction"/>.</exception>
|
||||||
protected override Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, Embed embed = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
protected override Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, Embed embed = null, PollProperties poll = null)
|
||||||
=> HandleInteractionAsync(x => x.Respond(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags));
|
=> HandleInteractionAsync(x => x.Respond(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Responds to the interaction with a modal.
|
/// Responds to the interaction with a modal.
|
||||||
|
|||||||
@@ -8,9 +8,6 @@ namespace Discord.API
|
|||||||
[JsonProperty("type")]
|
[JsonProperty("type")]
|
||||||
public ComponentType Type { get; set; }
|
public ComponentType Type { get; set; }
|
||||||
|
|
||||||
[JsonProperty("id")]
|
|
||||||
public Optional<int> Id { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("components")]
|
[JsonProperty("components")]
|
||||||
public IMessageComponent[] Components { get; set; }
|
public IMessageComponent[] Components { get; set; }
|
||||||
|
|
||||||
@@ -32,10 +29,9 @@ namespace Discord.API
|
|||||||
_ => null
|
_ => null
|
||||||
};
|
};
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
Id = c.Id ?? Optional<int>.Unspecified;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
int? IMessageComponent.Id => Id.ToNullable();
|
string IMessageComponent.CustomId => null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,11 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Discord.API
|
namespace Discord.API
|
||||||
{
|
{
|
||||||
internal class ButtonComponent : IInteractableComponent
|
internal class ButtonComponent : IMessageComponent
|
||||||
{
|
{
|
||||||
[JsonProperty("type")]
|
[JsonProperty("type")]
|
||||||
public ComponentType Type { get; set; }
|
public ComponentType Type { get; set; }
|
||||||
|
|
||||||
[JsonProperty("id")]
|
|
||||||
public Optional<int> Id { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("style")]
|
[JsonProperty("style")]
|
||||||
public ButtonStyle Style { get; set; }
|
public ButtonStyle Style { get; set; }
|
||||||
|
|
||||||
@@ -42,7 +39,6 @@ namespace Discord.API
|
|||||||
Url = c.Url;
|
Url = c.Url;
|
||||||
Disabled = c.IsDisabled;
|
Disabled = c.IsDisabled;
|
||||||
SkuId = c.SkuId ?? Optional<ulong>.Unspecified;
|
SkuId = c.SkuId ?? Optional<ulong>.Unspecified;
|
||||||
Id = c.Id ?? Optional<int>.Unspecified;
|
|
||||||
|
|
||||||
if (c.Emote != null)
|
if (c.Emote != null)
|
||||||
{
|
{
|
||||||
@@ -66,9 +62,6 @@ namespace Discord.API
|
|||||||
}
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
string IInteractableComponent.CustomId => CustomId.GetValueOrDefault();
|
string IMessageComponent.CustomId => CustomId.GetValueOrDefault();
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
int? IMessageComponent.Id => Id.ToNullable();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
using Discord.Rest;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Discord.API;
|
|
||||||
|
|
||||||
internal class ContainerComponent : IMessageComponent
|
|
||||||
{
|
|
||||||
[JsonProperty("type")]
|
|
||||||
public ComponentType Type { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("id")]
|
|
||||||
public Optional<int> Id { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("accent_color")]
|
|
||||||
public Optional<uint?> AccentColor { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("spoiler")]
|
|
||||||
public Optional<bool> IsSpoiler { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("components")]
|
|
||||||
public IMessageComponent[] Components { get; set; }
|
|
||||||
|
|
||||||
public ContainerComponent() { }
|
|
||||||
|
|
||||||
public ContainerComponent(Discord.ContainerComponent component)
|
|
||||||
{
|
|
||||||
Type = component.Type;
|
|
||||||
Id = component.Id ?? Optional<int>.Unspecified;
|
|
||||||
AccentColor = component.AccentColor ?? Optional<uint?>.Unspecified;
|
|
||||||
IsSpoiler = component.IsSpoiler ?? Optional<bool>.Unspecified;
|
|
||||||
Components = component.Components.Select(x => x.ToModel()).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
int? IMessageComponent.Id => Id.ToNullable();
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
using Discord.Rest;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Discord.API;
|
|
||||||
|
|
||||||
internal class FileComponent : IMessageComponent
|
|
||||||
{
|
|
||||||
[JsonProperty("type")]
|
|
||||||
public ComponentType Type { get; set; }
|
|
||||||
[JsonProperty("id")]
|
|
||||||
public Optional<int> Id { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("file")]
|
|
||||||
public UnfurledMediaItem File { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("spoiler")]
|
|
||||||
public Optional<bool> IsSpoiler { get; set; }
|
|
||||||
|
|
||||||
public FileComponent() { }
|
|
||||||
|
|
||||||
public FileComponent(Discord.FileComponent component)
|
|
||||||
{
|
|
||||||
Type = component.Type;
|
|
||||||
Id = component.Id ?? Optional<int>.Unspecified;
|
|
||||||
File = component.File.ToModel();
|
|
||||||
IsSpoiler = component.IsSpoiler ?? Optional<bool>.Unspecified;
|
|
||||||
}
|
|
||||||
|
|
||||||
int? IMessageComponent.Id => Id.ToNullable();
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,7 @@ internal class ForumThreadMessage
|
|||||||
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
||||||
|
|
||||||
[JsonProperty("components")]
|
[JsonProperty("components")]
|
||||||
public Optional<IMessageComponent[]> Components { get; set; }
|
public Optional<API.ActionRowComponent[]> Components { get; set; }
|
||||||
|
|
||||||
[JsonProperty("sticker_ids")]
|
[JsonProperty("sticker_ids")]
|
||||||
public Optional<ulong[]> Stickers { get; set; }
|
public Optional<ulong[]> Stickers { get; set; }
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace Discord.API
|
|||||||
public Optional<MessageFlags> Flags { get; set; }
|
public Optional<MessageFlags> Flags { get; set; }
|
||||||
|
|
||||||
[JsonProperty("components")]
|
[JsonProperty("components")]
|
||||||
public Optional<IMessageComponent[]> Components { get; set; }
|
public Optional<ActionRowComponent[]> Components { get; set; }
|
||||||
|
|
||||||
[JsonProperty("choices")]
|
[JsonProperty("choices")]
|
||||||
public Optional<ApplicationCommandOptionChoice[]> Choices { get; set; }
|
public Optional<ApplicationCommandOptionChoice[]> Choices { get; set; }
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
using Discord.Rest;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Discord.API;
|
|
||||||
|
|
||||||
internal class MediaGalleryComponent : IMessageComponent
|
|
||||||
{
|
|
||||||
[JsonProperty("type")]
|
|
||||||
public ComponentType Type { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("id")]
|
|
||||||
public Optional<int> Id { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("items")]
|
|
||||||
public MediaGalleryItem[] Items { get; set; }
|
|
||||||
|
|
||||||
public MediaGalleryComponent() { }
|
|
||||||
|
|
||||||
public MediaGalleryComponent(Discord.MediaGalleryComponent component)
|
|
||||||
{
|
|
||||||
Type = component.Type;
|
|
||||||
Id = component.Id ?? Optional<int>.Unspecified;
|
|
||||||
Items = component.Items.Select(x => new MediaGalleryItem
|
|
||||||
{
|
|
||||||
Description = x.Description,
|
|
||||||
IsSpoiler = x.IsSpoiler,
|
|
||||||
Media = x.Media.ToModel()
|
|
||||||
}).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
int? IMessageComponent.Id => Id.ToNullable();
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Discord.API;
|
|
||||||
|
|
||||||
internal class MediaGalleryItem
|
|
||||||
{
|
|
||||||
[JsonProperty("media")]
|
|
||||||
public UnfurledMediaItem Media { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("description")]
|
|
||||||
public Optional<string> Description { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("spoiler")]
|
|
||||||
public Optional<bool> IsSpoiler { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
using Discord.Rest;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Discord.API;
|
|
||||||
|
|
||||||
internal class SectionComponent : IMessageComponent
|
|
||||||
{
|
|
||||||
[JsonProperty("type")]
|
|
||||||
public ComponentType Type { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("id")]
|
|
||||||
public Optional<int> Id { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("components")]
|
|
||||||
public IMessageComponent[] Components { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("accessory")]
|
|
||||||
public IMessageComponent Accessory { get; set; }
|
|
||||||
|
|
||||||
public SectionComponent() { }
|
|
||||||
|
|
||||||
public SectionComponent(Discord.SectionComponent component)
|
|
||||||
{
|
|
||||||
Type = component.Type;
|
|
||||||
Id = component.Id ?? Optional<int>.Unspecified;
|
|
||||||
Components = component.Components.Select(x => x.ToModel()).ToArray();
|
|
||||||
Accessory = component.Accessory.ToModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
int? IMessageComponent.Id => Id.ToNullable();
|
|
||||||
}
|
|
||||||
@@ -3,14 +3,11 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace Discord.API
|
namespace Discord.API
|
||||||
{
|
{
|
||||||
internal class SelectMenuComponent : IInteractableComponent
|
internal class SelectMenuComponent : IMessageComponent
|
||||||
{
|
{
|
||||||
[JsonProperty("type")]
|
[JsonProperty("type")]
|
||||||
public ComponentType Type { get; set; }
|
public ComponentType Type { get; set; }
|
||||||
|
|
||||||
[JsonProperty("id")]
|
|
||||||
public Optional<int> Id { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("custom_id")]
|
[JsonProperty("custom_id")]
|
||||||
public string CustomId { get; set; }
|
public string CustomId { get; set; }
|
||||||
|
|
||||||
@@ -55,8 +52,5 @@ namespace Discord.API
|
|||||||
ChannelTypes = component.ChannelTypes.ToArray();
|
ChannelTypes = component.ChannelTypes.ToArray();
|
||||||
DefaultValues = component.DefaultValues.Select(x => new SelectMenuDefaultValue {Id = x.Id, Type = x.Type}).ToArray();
|
DefaultValues = component.DefaultValues.Select(x => new SelectMenuDefaultValue {Id = x.Id, Type = x.Type}).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
int? IMessageComponent.Id => Id.ToNullable();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Discord.API;
|
|
||||||
|
|
||||||
internal class SeparatorComponent : IMessageComponent
|
|
||||||
{
|
|
||||||
[JsonProperty("type")]
|
|
||||||
public ComponentType Type { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("id")]
|
|
||||||
public Optional<int> Id { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("divider")]
|
|
||||||
public Optional<bool> IsDivider { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("spacing")]
|
|
||||||
public Optional<SeparatorSpacingSize> Spacing { get; set; }
|
|
||||||
|
|
||||||
public SeparatorComponent() { }
|
|
||||||
|
|
||||||
public SeparatorComponent(Discord.SeparatorComponent component)
|
|
||||||
{
|
|
||||||
Type = component.Type;
|
|
||||||
Id = component.Id ?? Optional<int>.Unspecified;
|
|
||||||
IsDivider = component.IsDivider ?? Optional<bool>.Unspecified;
|
|
||||||
Spacing = component.Spacing ?? Optional<SeparatorSpacingSize>.Unspecified;
|
|
||||||
}
|
|
||||||
|
|
||||||
int? IMessageComponent.Id => Id.ToNullable();
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Discord.API;
|
|
||||||
|
|
||||||
internal class TextDisplayComponent : IMessageComponent
|
|
||||||
{
|
|
||||||
[JsonProperty("type")]
|
|
||||||
public ComponentType Type { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("id")]
|
|
||||||
public Optional<int> Id { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("content")]
|
|
||||||
public string Content { get; set; }
|
|
||||||
|
|
||||||
public TextDisplayComponent() { }
|
|
||||||
|
|
||||||
public TextDisplayComponent(Discord.TextDisplayComponent component)
|
|
||||||
{
|
|
||||||
Type = component.Type;
|
|
||||||
Id = component.Id ?? Optional<int>.Unspecified;
|
|
||||||
Content = component.Content;
|
|
||||||
}
|
|
||||||
|
|
||||||
int? IMessageComponent.Id => Id.ToNullable();
|
|
||||||
}
|
|
||||||
@@ -2,14 +2,11 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Discord.API
|
namespace Discord.API
|
||||||
{
|
{
|
||||||
internal class TextInputComponent : IInteractableComponent
|
internal class TextInputComponent : IMessageComponent
|
||||||
{
|
{
|
||||||
[JsonProperty("type")]
|
[JsonProperty("type")]
|
||||||
public ComponentType Type { get; set; }
|
public ComponentType Type { get; set; }
|
||||||
|
|
||||||
[JsonProperty("id")]
|
|
||||||
public Optional<int> Id { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("style")]
|
[JsonProperty("style")]
|
||||||
public TextInputStyle Style { get; set; }
|
public TextInputStyle Style { get; set; }
|
||||||
|
|
||||||
@@ -47,10 +44,6 @@ namespace Discord.API
|
|||||||
MaxLength = component.MaxLength ?? Optional<int>.Unspecified;
|
MaxLength = component.MaxLength ?? Optional<int>.Unspecified;
|
||||||
Required = component.Required ?? Optional<bool>.Unspecified;
|
Required = component.Required ?? Optional<bool>.Unspecified;
|
||||||
Value = component.Value ?? Optional<string>.Unspecified;
|
Value = component.Value ?? Optional<string>.Unspecified;
|
||||||
Id = component.Id ?? Optional<int>.Unspecified;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
int? IMessageComponent.Id => Id.ToNullable();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
using Discord.Rest;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Discord.API;
|
|
||||||
|
|
||||||
internal class ThumbnailComponent : IMessageComponent
|
|
||||||
{
|
|
||||||
[JsonProperty("type")]
|
|
||||||
public ComponentType Type { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("id")]
|
|
||||||
public Optional<int> Id { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("media")]
|
|
||||||
public UnfurledMediaItem Media { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("description")]
|
|
||||||
public Optional<string> Description { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("spoiler")]
|
|
||||||
public Optional<bool> IsSpoiler { get; set; }
|
|
||||||
|
|
||||||
public ThumbnailComponent() { }
|
|
||||||
|
|
||||||
public ThumbnailComponent(Discord.ThumbnailComponent component)
|
|
||||||
{
|
|
||||||
Type = component.Type;
|
|
||||||
Id = component.Id ?? Optional<int>.Unspecified;
|
|
||||||
Media = component.Media.ToModel();
|
|
||||||
Description = component.Description;
|
|
||||||
IsSpoiler = component.IsSpoiler;
|
|
||||||
}
|
|
||||||
|
|
||||||
int? IMessageComponent.Id => Id.ToNullable();
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Discord.API;
|
|
||||||
|
|
||||||
internal class UnfurledMediaItem
|
|
||||||
{
|
|
||||||
[JsonProperty("url")]
|
|
||||||
public string Url { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("proxy_url")]
|
|
||||||
public Optional<string> ProxyUrl { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("height")]
|
|
||||||
public Optional<int?> Height { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("width")]
|
|
||||||
public Optional<int?> Width { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("content_type")]
|
|
||||||
public Optional<string> ContentType { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("loading_state")]
|
|
||||||
public Optional<UnfurledMediaItemLoadingState> LoadingState { get; set; }
|
|
||||||
}
|
|
||||||
@@ -24,7 +24,7 @@ namespace Discord.API.Rest
|
|||||||
public Optional<MessageReference> MessageReference { get; set; }
|
public Optional<MessageReference> MessageReference { get; set; }
|
||||||
|
|
||||||
[JsonProperty("components")]
|
[JsonProperty("components")]
|
||||||
public Optional<IMessageComponent[]> Components { get; set; }
|
public Optional<API.ActionRowComponent[]> Components { get; set; }
|
||||||
|
|
||||||
[JsonProperty("sticker_ids")]
|
[JsonProperty("sticker_ids")]
|
||||||
public Optional<ulong[]> Stickers { get; set; }
|
public Optional<ulong[]> Stickers { get; set; }
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace Discord.API.Rest
|
|||||||
public Optional<string> Content { get; set; }
|
public Optional<string> Content { get; set; }
|
||||||
public Optional<Embed[]> Embeds { get; set; }
|
public Optional<Embed[]> Embeds { get; set; }
|
||||||
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
||||||
public Optional<IMessageComponent[]> MessageComponent { get; set; }
|
public Optional<ActionRowComponent[]> MessageComponent { get; set; }
|
||||||
public Optional<MessageFlags?> Flags { get; set; }
|
public Optional<MessageFlags?> Flags { get; set; }
|
||||||
public Optional<ulong[]> Stickers { get; set; }
|
public Optional<ulong[]> Stickers { get; set; }
|
||||||
public Optional<ulong[]> TagIds { get; set; }
|
public Optional<ulong[]> TagIds { get; set; }
|
||||||
|
|||||||
@@ -1,22 +1,28 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Discord.API.Rest;
|
namespace Discord.API.Rest
|
||||||
|
|
||||||
internal class CreatePostParams
|
|
||||||
{
|
{
|
||||||
// thread
|
internal class CreatePostParams
|
||||||
[JsonProperty("name")]
|
{
|
||||||
public string Title { get; set; }
|
// thread
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Title { get; set; }
|
||||||
|
|
||||||
[JsonProperty("auto_archive_duration")]
|
[JsonProperty("auto_archive_duration")]
|
||||||
public ThreadArchiveDuration ArchiveDuration { get; set; }
|
public ThreadArchiveDuration ArchiveDuration { get; set; }
|
||||||
|
|
||||||
[JsonProperty("rate_limit_per_user")]
|
[JsonProperty("rate_limit_per_user")]
|
||||||
public Optional<int?> Slowmode { get; set; }
|
public Optional<int?> Slowmode { get; set; }
|
||||||
|
|
||||||
[JsonProperty("message")]
|
[JsonProperty("message")]
|
||||||
public ForumThreadMessage Message { get; set; }
|
public ForumThreadMessage Message { get; set; }
|
||||||
|
|
||||||
[JsonProperty("applied_tags")]
|
[JsonProperty("applied_tags")]
|
||||||
public Optional<ulong[]> Tags { get; set; }
|
public Optional<ulong[]> Tags { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using Discord.Net.Rest;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Discord.API.Rest
|
namespace Discord.API.Rest
|
||||||
@@ -38,7 +37,7 @@ namespace Discord.API.Rest
|
|||||||
public Optional<MessageFlags> Flags { get; set; }
|
public Optional<MessageFlags> Flags { get; set; }
|
||||||
|
|
||||||
[JsonProperty("components")]
|
[JsonProperty("components")]
|
||||||
public Optional<IMessageComponent[]> Components { get; set; }
|
public Optional<API.ActionRowComponent[]> Components { get; set; }
|
||||||
|
|
||||||
[JsonProperty("file")]
|
[JsonProperty("file")]
|
||||||
public Optional<MultipartFile> File { get; set; }
|
public Optional<MultipartFile> File { get; set; }
|
||||||
@@ -56,7 +55,6 @@ namespace Discord.API.Rest
|
|||||||
{
|
{
|
||||||
var d = new Dictionary<string, object>();
|
var d = new Dictionary<string, object>();
|
||||||
|
|
||||||
var extraFlags = MessageFlags.None;
|
|
||||||
if (File.IsSpecified)
|
if (File.IsSpecified)
|
||||||
{
|
{
|
||||||
d["file"] = File.Value;
|
d["file"] = File.Value;
|
||||||
@@ -79,21 +77,14 @@ namespace Discord.API.Rest
|
|||||||
payload["embeds"] = Embeds.Value;
|
payload["embeds"] = Embeds.Value;
|
||||||
if (AllowedMentions.IsSpecified)
|
if (AllowedMentions.IsSpecified)
|
||||||
payload["allowed_mentions"] = AllowedMentions.Value;
|
payload["allowed_mentions"] = AllowedMentions.Value;
|
||||||
|
|
||||||
|
|
||||||
if (Components.IsSpecified)
|
if (Components.IsSpecified)
|
||||||
{
|
|
||||||
payload["components"] = Components.Value;
|
payload["components"] = Components.Value;
|
||||||
if (Components.Value.Any(x => x.Type is not ComponentType.ActionRow))
|
|
||||||
extraFlags |= MessageFlags.ComponentsV2;
|
|
||||||
}
|
|
||||||
|
|
||||||
payload["flags"] = Flags.GetValueOrDefault(MessageFlags.None) | extraFlags;
|
|
||||||
|
|
||||||
if (ThreadName.IsSpecified)
|
if (ThreadName.IsSpecified)
|
||||||
payload["thread_name"] = ThreadName.Value;
|
payload["thread_name"] = ThreadName.Value;
|
||||||
if (AppliedTags.IsSpecified)
|
if (AppliedTags.IsSpecified)
|
||||||
payload["applied_tags"] = AppliedTags.Value;
|
payload["applied_tags"] = AppliedTags.Value;
|
||||||
|
if (Flags.IsSpecified)
|
||||||
|
payload["flags"] = Flags.Value;
|
||||||
if (Poll.IsSpecified)
|
if (Poll.IsSpecified)
|
||||||
payload["poll"] = Poll.Value;
|
payload["poll"] = Poll.Value;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace Discord.API.Rest
|
|||||||
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
||||||
|
|
||||||
[JsonProperty("components")]
|
[JsonProperty("components")]
|
||||||
public Optional<IMessageComponent[]> Components { get; set; }
|
public Optional<ActionRowComponent[]> Components { get; set; }
|
||||||
|
|
||||||
[JsonProperty("flags")]
|
[JsonProperty("flags")]
|
||||||
public Optional<MessageFlags?> Flags { get; set; }
|
public Optional<MessageFlags?> Flags { get; set; }
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Discord.API.Rest;
|
namespace Discord.API.Rest
|
||||||
|
|
||||||
internal class ModifyMessageParams
|
|
||||||
{
|
{
|
||||||
[JsonProperty("content")]
|
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
|
||||||
public Optional<string> Content { get; set; }
|
internal class ModifyMessageParams
|
||||||
|
{
|
||||||
[JsonProperty("embeds")]
|
[JsonProperty("content")]
|
||||||
public Optional<Embed[]> Embeds { get; set; }
|
public Optional<string> Content { get; set; }
|
||||||
|
[JsonProperty("embeds")]
|
||||||
[JsonProperty("components")]
|
public Optional<API.Embed[]> Embeds { get; set; }
|
||||||
public Optional<IMessageComponent[]> Components { get; set; }
|
[JsonProperty("components")]
|
||||||
|
public Optional<API.ActionRowComponent[]> Components { get; set; }
|
||||||
[JsonProperty("flags")]
|
[JsonProperty("flags")]
|
||||||
public Optional<MessageFlags?> Flags { get; set; }
|
public Optional<MessageFlags?> Flags { get; set; }
|
||||||
|
[JsonProperty("allowed_mentions")]
|
||||||
[JsonProperty("allowed_mentions")]
|
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
||||||
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Discord.API.Rest;
|
namespace Discord.API.Rest
|
||||||
|
|
||||||
internal class ModifyWebhookMessageParams
|
|
||||||
{
|
{
|
||||||
[JsonProperty("content")]
|
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
|
||||||
public Optional<string> Content { get; set; }
|
internal class ModifyWebhookMessageParams
|
||||||
|
{
|
||||||
[JsonProperty("embeds")]
|
[JsonProperty("content")]
|
||||||
public Optional<Embed[]> Embeds { get; set; }
|
public Optional<string> Content { get; set; }
|
||||||
|
[JsonProperty("embeds")]
|
||||||
[JsonProperty("allowed_mentions")]
|
public Optional<Embed[]> Embeds { get; set; }
|
||||||
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
[JsonProperty("allowed_mentions")]
|
||||||
|
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
||||||
[JsonProperty("components")]
|
[JsonProperty("components")]
|
||||||
public Optional<IMessageComponent[]> Components { get; set; }
|
public Optional<API.ActionRowComponent[]> Components { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace Discord.API.Rest
|
|||||||
public Optional<Embed[]> Embeds { get; set; }
|
public Optional<Embed[]> Embeds { get; set; }
|
||||||
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
||||||
public Optional<MessageReference> MessageReference { get; set; }
|
public Optional<MessageReference> MessageReference { get; set; }
|
||||||
public Optional<IMessageComponent[]> MessageComponent { get; set; }
|
public Optional<ActionRowComponent[]> MessageComponent { get; set; }
|
||||||
public Optional<MessageFlags?> Flags { get; set; }
|
public Optional<MessageFlags?> Flags { get; set; }
|
||||||
public Optional<ulong[]> Stickers { get; set; }
|
public Optional<ulong[]> Stickers { get; set; }
|
||||||
public Optional<CreatePollParams> Poll { get; set; }
|
public Optional<CreatePollParams> Poll { get; set; }
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace Discord.API.Rest
|
|||||||
public Optional<bool> IsTTS { get; set; }
|
public Optional<bool> IsTTS { get; set; }
|
||||||
public Optional<Embed[]> Embeds { get; set; }
|
public Optional<Embed[]> Embeds { get; set; }
|
||||||
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
||||||
public Optional<IMessageComponent[]> MessageComponents { get; set; }
|
public Optional<ActionRowComponent[]> MessageComponents { get; set; }
|
||||||
public Optional<MessageFlags> Flags { get; set; }
|
public Optional<MessageFlags> Flags { get; set; }
|
||||||
public Optional<CreatePollParams> Poll { get; set; }
|
public Optional<CreatePollParams> Poll { get; set; }
|
||||||
|
|
||||||
@@ -44,10 +44,8 @@ namespace Discord.API.Rest
|
|||||||
{
|
{
|
||||||
var d = new Dictionary<string, object>();
|
var d = new Dictionary<string, object>();
|
||||||
|
|
||||||
var extraFlags = MessageFlags.None;
|
|
||||||
|
|
||||||
if (Files.Any(x => x.Waveform is not null && x.DurationSeconds is not null))
|
if (Files.Any(x => x.Waveform is not null && x.DurationSeconds is not null))
|
||||||
extraFlags |= MessageFlags.VoiceMessage;
|
Flags = Flags.GetValueOrDefault(MessageFlags.None) | MessageFlags.VoiceMessage;
|
||||||
|
|
||||||
var payload = new Dictionary<string, object>();
|
var payload = new Dictionary<string, object>();
|
||||||
payload["type"] = Type;
|
payload["type"] = Type;
|
||||||
@@ -57,26 +55,20 @@ namespace Discord.API.Rest
|
|||||||
data["content"] = Content.Value;
|
data["content"] = Content.Value;
|
||||||
if (IsTTS.IsSpecified)
|
if (IsTTS.IsSpecified)
|
||||||
data["tts"] = IsTTS.Value;
|
data["tts"] = IsTTS.Value;
|
||||||
|
if (MessageComponents.IsSpecified)
|
||||||
|
data["components"] = MessageComponents.Value;
|
||||||
if (Embeds.IsSpecified)
|
if (Embeds.IsSpecified)
|
||||||
data["embeds"] = Embeds.Value;
|
data["embeds"] = Embeds.Value;
|
||||||
if (AllowedMentions.IsSpecified)
|
if (AllowedMentions.IsSpecified)
|
||||||
data["allowed_mentions"] = AllowedMentions.Value;
|
data["allowed_mentions"] = AllowedMentions.Value;
|
||||||
|
if (Flags.IsSpecified)
|
||||||
if (MessageComponents.IsSpecified)
|
data["flags"] = Flags.Value;
|
||||||
{
|
|
||||||
data["components"] = MessageComponents.Value;
|
|
||||||
if (MessageComponents.Value.Any(x => x.Type is not ComponentType.ActionRow))
|
|
||||||
extraFlags |= MessageFlags.ComponentsV2;
|
|
||||||
}
|
|
||||||
|
|
||||||
data["flags"] = Flags.GetValueOrDefault(MessageFlags.None) | extraFlags;
|
|
||||||
|
|
||||||
if (Poll.IsSpecified)
|
if (Poll.IsSpecified)
|
||||||
data["poll"] = Poll.Value;
|
data["poll"] = Poll.Value;
|
||||||
|
|
||||||
List<object> attachments = [];
|
List<object> attachments = new();
|
||||||
|
|
||||||
for (var n = 0; n != Files.Length; n++)
|
for (int n = 0; n != Files.Length; n++)
|
||||||
{
|
{
|
||||||
var attachment = Files[n];
|
var attachment = Files[n];
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Discord.API.Rest
|
|||||||
public Optional<string> AvatarUrl { get; set; }
|
public Optional<string> AvatarUrl { get; set; }
|
||||||
public Optional<Embed[]> Embeds { get; set; }
|
public Optional<Embed[]> Embeds { get; set; }
|
||||||
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
public Optional<AllowedMentions> AllowedMentions { get; set; }
|
||||||
public Optional<IMessageComponent[]> MessageComponents { get; set; }
|
public Optional<ActionRowComponent[]> MessageComponents { get; set; }
|
||||||
public Optional<MessageFlags> Flags { get; set; }
|
public Optional<MessageFlags> Flags { get; set; }
|
||||||
public Optional<string> ThreadName { get; set; }
|
public Optional<string> ThreadName { get; set; }
|
||||||
public Optional<ulong[]> AppliedTags { get; set; }
|
public Optional<ulong[]> AppliedTags { get; set; }
|
||||||
@@ -37,10 +37,8 @@ namespace Discord.API.Rest
|
|||||||
{
|
{
|
||||||
var d = new Dictionary<string, object>();
|
var d = new Dictionary<string, object>();
|
||||||
|
|
||||||
var extraFlags = MessageFlags.None;
|
|
||||||
|
|
||||||
if (Files.Any(x => x.Waveform is not null && x.DurationSeconds is not null))
|
if (Files.Any(x => x.Waveform is not null && x.DurationSeconds is not null))
|
||||||
extraFlags |= MessageFlags.VoiceMessage;
|
Flags = Flags.GetValueOrDefault(MessageFlags.None) | MessageFlags.VoiceMessage;
|
||||||
|
|
||||||
var payload = new Dictionary<string, object>();
|
var payload = new Dictionary<string, object>();
|
||||||
if (Content.IsSpecified)
|
if (Content.IsSpecified)
|
||||||
@@ -53,20 +51,14 @@ namespace Discord.API.Rest
|
|||||||
payload["username"] = Username.Value;
|
payload["username"] = Username.Value;
|
||||||
if (AvatarUrl.IsSpecified)
|
if (AvatarUrl.IsSpecified)
|
||||||
payload["avatar_url"] = AvatarUrl.Value;
|
payload["avatar_url"] = AvatarUrl.Value;
|
||||||
|
if (MessageComponents.IsSpecified)
|
||||||
|
payload["components"] = MessageComponents.Value;
|
||||||
if (Embeds.IsSpecified)
|
if (Embeds.IsSpecified)
|
||||||
payload["embeds"] = Embeds.Value;
|
payload["embeds"] = Embeds.Value;
|
||||||
if (AllowedMentions.IsSpecified)
|
if (AllowedMentions.IsSpecified)
|
||||||
payload["allowed_mentions"] = AllowedMentions.Value;
|
payload["allowed_mentions"] = AllowedMentions.Value;
|
||||||
|
if (Flags.IsSpecified)
|
||||||
if (MessageComponents.IsSpecified)
|
payload["flags"] = Flags.Value;
|
||||||
{
|
|
||||||
payload["components"] = MessageComponents.Value;
|
|
||||||
if (MessageComponents.Value.Any(x => x.Type is not ComponentType.ActionRow))
|
|
||||||
extraFlags |= MessageFlags.ComponentsV2;
|
|
||||||
}
|
|
||||||
|
|
||||||
payload["flags"] = Flags.GetValueOrDefault(MessageFlags.None) | extraFlags;
|
|
||||||
|
|
||||||
if (ThreadName.IsSpecified)
|
if (ThreadName.IsSpecified)
|
||||||
payload["thread_name"] = ThreadName.Value;
|
payload["thread_name"] = ThreadName.Value;
|
||||||
if (AppliedTags.IsSpecified)
|
if (AppliedTags.IsSpecified)
|
||||||
|
|||||||
@@ -2779,8 +2779,6 @@ namespace Discord.API
|
|||||||
if (threadId.HasValue)
|
if (threadId.HasValue)
|
||||||
querys.Add($"thread_id={threadId}");
|
querys.Add($"thread_id={threadId}");
|
||||||
|
|
||||||
querys.Add("with_components=true");
|
|
||||||
|
|
||||||
return $"{string.Join("&", querys)}";
|
return $"{string.Join("&", querys)}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -308,10 +308,10 @@ namespace Discord.Rest
|
|||||||
Preconditions.AtMost(stickers.Length, 3, nameof(stickers), "A max of 3 stickers are allowed.");
|
Preconditions.AtMost(stickers.Length, 3, nameof(stickers), "A max of 3 stickers are allowed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false)
|
if (flags is not MessageFlags.None and not MessageFlags.SuppressEmbeds and not MessageFlags.SuppressNotification)
|
||||||
flags |= MessageFlags.ComponentsV2;
|
throw new ArgumentException("The only valid MessageFlags are SuppressEmbeds, SuppressNotification and none.", nameof(flags));
|
||||||
|
|
||||||
Preconditions.ValidateMessageFlags(flags);
|
|
||||||
|
|
||||||
var args = new CreateMessageParams
|
var args = new CreateMessageParams
|
||||||
{
|
{
|
||||||
@@ -320,7 +320,7 @@ namespace Discord.Rest
|
|||||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||||
AllowedMentions = allowedMentions?.ToModel(),
|
AllowedMentions = allowedMentions?.ToModel(),
|
||||||
MessageReference = messageReference?.ToModel(),
|
MessageReference = messageReference?.ToModel(),
|
||||||
Components = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
Components = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional<ulong[]>.Unspecified,
|
Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional<ulong[]>.Unspecified,
|
||||||
Flags = flags,
|
Flags = flags,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
@@ -429,10 +429,8 @@ namespace Discord.Rest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false)
|
if (flags is not MessageFlags.None and not MessageFlags.SuppressEmbeds and not MessageFlags.SuppressNotification)
|
||||||
flags |= MessageFlags.ComponentsV2;
|
throw new ArgumentException("The only valid MessageFlags are SuppressEmbeds, SuppressNotification and none.", nameof(flags));
|
||||||
|
|
||||||
Preconditions.ValidateMessageFlags(flags);
|
|
||||||
|
|
||||||
if (stickers != null)
|
if (stickers != null)
|
||||||
{
|
{
|
||||||
@@ -446,7 +444,7 @@ namespace Discord.Rest
|
|||||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
MessageReference = messageReference?.ToModel() ?? Optional<API.MessageReference>.Unspecified,
|
MessageReference = messageReference?.ToModel() ?? Optional<API.MessageReference>.Unspecified,
|
||||||
MessageComponent = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
MessageComponent = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional<ulong[]>.Unspecified,
|
Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional<ulong[]>.Unspecified,
|
||||||
Flags = flags,
|
Flags = flags,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ namespace Discord.Rest
|
|||||||
Content = text,
|
Content = text,
|
||||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||||
Flags = flags,
|
Flags = flags,
|
||||||
Components = components?.Components?.Any() ?? false ? components.Components.Select(x => x.ToModel()).ToArray() : Optional<IMessageComponent[]>.Unspecified,
|
Components = components?.Components?.Any() ?? false ? components.Components.Select(x => new API.ActionRowComponent(x)).ToArray() : Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional<ulong[]>.Unspecified,
|
Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional<ulong[]>.Unspecified,
|
||||||
},
|
},
|
||||||
Tags = tagIds
|
Tags = tagIds
|
||||||
@@ -224,7 +224,7 @@ namespace Discord.Rest
|
|||||||
Content = text,
|
Content = text,
|
||||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||||
Flags = flags,
|
Flags = flags,
|
||||||
MessageComponent = components?.Components?.Any() ?? false ? components.Components.Select(x => x.ToModel()).ToArray() : Optional<IMessageComponent[]>.Unspecified,
|
MessageComponent = components?.Components?.Any() ?? false ? components.Components.Select(x => new API.ActionRowComponent(x)).ToArray() : Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Slowmode = slowmode,
|
Slowmode = slowmode,
|
||||||
Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional<ulong[]>.Unspecified,
|
Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional<ulong[]>.Unspecified,
|
||||||
Title = title,
|
Title = title,
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
using Discord.API.Rest;
|
using Discord.API.Rest;
|
||||||
|
using Discord.Net.Rest;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using DataModel = Discord.API.ApplicationCommandInteractionData;
|
||||||
using Model = Discord.API.Interaction;
|
using Model = Discord.API.Interaction;
|
||||||
|
|
||||||
namespace Discord.Rest
|
namespace Discord.Rest
|
||||||
@@ -80,8 +81,7 @@ namespace Discord.Rest
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
@@ -89,7 +89,7 @@ namespace Discord.Rest
|
|||||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -123,12 +123,8 @@ namespace Discord.Rest
|
|||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
||||||
TTS = isTTS,
|
TTS = isTTS,
|
||||||
Components = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
Components = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = ephemeral
|
Flags = ephemeral ? MessageFlags.Ephemeral : Optional<MessageFlags>.Unspecified,
|
||||||
? flags | MessageFlags.Ephemeral
|
|
||||||
: flags == MessageFlags.None
|
|
||||||
? Optional<MessageFlags>.Unspecified
|
|
||||||
: flags,
|
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -156,13 +152,12 @@ namespace Discord.Rest
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -177,15 +172,13 @@ namespace Discord.Rest
|
|||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
||||||
Components = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
Components = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified,
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
Flags = ephemeral
|
|
||||||
? flags | MessageFlags.Ephemeral
|
|
||||||
: flags == MessageFlags.None
|
|
||||||
? Optional<MessageFlags>.Unspecified
|
|
||||||
: flags,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ephemeral)
|
||||||
|
args.Flags = MessageFlags.Ephemeral;
|
||||||
|
|
||||||
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,8 +194,7 @@ namespace Discord.Rest
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
@@ -211,7 +203,7 @@ namespace Discord.Rest
|
|||||||
Preconditions.NotNullOrEmpty(fileName, nameof(fileName), "File Name must not be empty or null");
|
Preconditions.NotNullOrEmpty(fileName, nameof(fileName), "File Name must not be empty or null");
|
||||||
|
|
||||||
using (var file = new FileAttachment(fileStream, fileName))
|
using (var file = new FileAttachment(fileStream, fileName))
|
||||||
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -226,8 +218,7 @@ namespace Discord.Rest
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
Preconditions.NotNullOrEmpty(filePath, nameof(filePath), "Path must exist");
|
Preconditions.NotNullOrEmpty(filePath, nameof(filePath), "Path must exist");
|
||||||
|
|
||||||
@@ -235,7 +226,7 @@ namespace Discord.Rest
|
|||||||
Preconditions.NotNullOrEmpty(fileName, nameof(fileName), "File Name must not be empty or null");
|
Preconditions.NotNullOrEmpty(fileName, nameof(fileName), "File Name must not be empty or null");
|
||||||
|
|
||||||
using (var file = new FileAttachment(File.OpenRead(filePath), fileName))
|
using (var file = new FileAttachment(File.OpenRead(filePath), fileName))
|
||||||
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -249,10 +240,9 @@ namespace Discord.Rest
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
return FollowupWithFilesAsync([attachment], text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
return FollowupWithFilesAsync(new FileAttachment[] { attachment }, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -266,13 +256,12 @@ namespace Discord.Rest
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -300,22 +289,23 @@ namespace Discord.Rest
|
|||||||
{
|
{
|
||||||
throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(allowedMentions));
|
throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(allowedMentions));
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
var flags = MessageFlags.None;
|
||||||
|
|
||||||
|
if (ephemeral)
|
||||||
|
flags |= MessageFlags.Ephemeral;
|
||||||
|
|
||||||
var args = new API.Rest.UploadWebhookFileParams(attachments.ToArray())
|
var args = new API.Rest.UploadWebhookFileParams(attachments.ToArray())
|
||||||
{
|
{
|
||||||
Flags = ephemeral
|
Flags = flags,
|
||||||
? flags | MessageFlags.Ephemeral
|
Content = text,
|
||||||
: flags == MessageFlags.None
|
IsTTS = isTTS,
|
||||||
? Optional<MessageFlags>.Unspecified
|
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||||
: flags,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
Content = text,
|
MessageComponents = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
IsTTS = isTTS,
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
};
|
||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
|
||||||
MessageComponents = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
|
||||||
};
|
|
||||||
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -430,8 +430,8 @@ namespace Discord.Rest
|
|||||||
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
||||||
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
||||||
Components = args.Components.IsSpecified
|
Components = args.Components.IsSpecified
|
||||||
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? []
|
? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Array.Empty<API.ActionRowComponent>()
|
||||||
: Optional<IMessageComponent[]>.Unspecified,
|
: Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
};
|
};
|
||||||
|
|
||||||
return client.ApiClient.ModifyInteractionFollowupMessageAsync(apiArgs, message.Id, message.Token, options);
|
return client.ApiClient.ModifyInteractionFollowupMessageAsync(apiArgs, message.Id, message.Token, options);
|
||||||
@@ -478,7 +478,8 @@ namespace Discord.Rest
|
|||||||
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
||||||
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
||||||
Components = args.Components.IsSpecified
|
Components = args.Components.IsSpecified
|
||||||
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? [] : Optional<IMessageComponent[]>.Unspecified,
|
? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Array.Empty<API.ActionRowComponent>()
|
||||||
|
: Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = args.Flags
|
Flags = args.Flags
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -494,7 +495,8 @@ namespace Discord.Rest
|
|||||||
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
||||||
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
||||||
MessageComponents = args.Components.IsSpecified
|
MessageComponents = args.Components.IsSpecified
|
||||||
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? [] : Optional<IMessageComponent[]>.Unspecified
|
? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Array.Empty<API.ActionRowComponent>()
|
||||||
|
: Optional<API.ActionRowComponent[]>.Unspecified
|
||||||
};
|
};
|
||||||
|
|
||||||
return client.ApiClient.ModifyInteractionResponseAsync(apiArgs, token, options);
|
return client.ApiClient.ModifyInteractionResponseAsync(apiArgs, token, options);
|
||||||
|
|||||||
@@ -77,8 +77,7 @@ namespace Discord.Rest
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
@@ -86,7 +85,7 @@ namespace Discord.Rest
|
|||||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -120,16 +119,14 @@ namespace Discord.Rest
|
|||||||
AllowedMentions = allowedMentions?.ToModel(),
|
AllowedMentions = allowedMentions?.ToModel(),
|
||||||
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
||||||
TTS = isTTS,
|
TTS = isTTS,
|
||||||
Components = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
Components = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified,
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
Flags = ephemeral
|
|
||||||
? flags | MessageFlags.Ephemeral
|
|
||||||
: flags == MessageFlags.None
|
|
||||||
? Optional<MessageFlags>.Unspecified
|
|
||||||
: flags,
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ephemeral)
|
||||||
|
response.Data.Value.Flags = MessageFlags.Ephemeral;
|
||||||
|
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
if (HasResponded)
|
if (HasResponded)
|
||||||
@@ -211,8 +208,8 @@ namespace Discord.Rest
|
|||||||
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
||||||
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
||||||
Components = args.Components.IsSpecified
|
Components = args.Components.IsSpecified
|
||||||
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? []
|
? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Array.Empty<API.ActionRowComponent>()
|
||||||
: Optional<IMessageComponent[]>.Unspecified,
|
: Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
|
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -230,8 +227,8 @@ namespace Discord.Rest
|
|||||||
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
||||||
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
||||||
MessageComponents = args.Components.IsSpecified
|
MessageComponents = args.Components.IsSpecified
|
||||||
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? []
|
? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Array.Empty<API.ActionRowComponent>()
|
||||||
: Optional<IMessageComponent[]>.Unspecified,
|
: Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
|
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -259,13 +256,12 @@ namespace Discord.Rest
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -280,15 +276,14 @@ namespace Discord.Rest
|
|||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
||||||
Components = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
Components = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = ephemeral
|
Flags = ephemeral ? MessageFlags.Ephemeral : MessageFlags.None,
|
||||||
? flags | MessageFlags.Ephemeral
|
|
||||||
: flags == MessageFlags.None
|
|
||||||
? Optional<MessageFlags>.Unspecified
|
|
||||||
: flags,
|
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ephemeral)
|
||||||
|
args.Flags = MessageFlags.Ephemeral;
|
||||||
|
|
||||||
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,8 +299,7 @@ namespace Discord.Rest
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
@@ -314,7 +308,7 @@ namespace Discord.Rest
|
|||||||
Preconditions.NotNullOrEmpty(fileName, nameof(fileName), "File Name must not be empty or null");
|
Preconditions.NotNullOrEmpty(fileName, nameof(fileName), "File Name must not be empty or null");
|
||||||
|
|
||||||
using (var file = new FileAttachment(fileStream, fileName))
|
using (var file = new FileAttachment(fileStream, fileName))
|
||||||
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -329,8 +323,7 @@ namespace Discord.Rest
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
Preconditions.NotNullOrEmpty(filePath, nameof(filePath), "Path must exist");
|
Preconditions.NotNullOrEmpty(filePath, nameof(filePath), "Path must exist");
|
||||||
|
|
||||||
@@ -338,7 +331,7 @@ namespace Discord.Rest
|
|||||||
Preconditions.NotNullOrEmpty(fileName, nameof(fileName), "File Name must not be empty or null");
|
Preconditions.NotNullOrEmpty(fileName, nameof(fileName), "File Name must not be empty or null");
|
||||||
|
|
||||||
using (var file = new FileAttachment(File.OpenRead(filePath), fileName))
|
using (var file = new FileAttachment(File.OpenRead(filePath), fileName))
|
||||||
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -352,10 +345,9 @@ namespace Discord.Rest
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
return FollowupWithFilesAsync([attachment], text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
return FollowupWithFilesAsync(new FileAttachment[] { attachment }, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -369,13 +361,12 @@ namespace Discord.Rest
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -405,18 +396,19 @@ namespace Discord.Rest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var flags = MessageFlags.None;
|
||||||
|
|
||||||
|
if (ephemeral)
|
||||||
|
flags |= MessageFlags.Ephemeral;
|
||||||
|
|
||||||
var args = new API.Rest.UploadWebhookFileParams(attachments.ToArray())
|
var args = new API.Rest.UploadWebhookFileParams(attachments.ToArray())
|
||||||
{
|
{
|
||||||
Flags = ephemeral
|
Flags = flags,
|
||||||
? flags | MessageFlags.Ephemeral
|
|
||||||
: flags == MessageFlags.None
|
|
||||||
? Optional<MessageFlags>.Unspecified
|
|
||||||
: flags,
|
|
||||||
Content = text,
|
Content = text,
|
||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
MessageComponents = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
MessageComponents = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
};
|
};
|
||||||
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ namespace Discord.Rest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal RestMessageComponentData(IInteractableComponent component, BaseDiscordClient discord, IGuild guild)
|
internal RestMessageComponentData(IMessageComponent component, BaseDiscordClient discord, IGuild guild)
|
||||||
{
|
{
|
||||||
CustomId = component.CustomId;
|
CustomId = component.CustomId;
|
||||||
Type = component.Type;
|
Type = component.Type;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using Discord.Rest;
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@@ -138,13 +137,12 @@ namespace Discord.Rest
|
|||||||
MessageComponent component = null,
|
MessageComponent component = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -159,15 +157,13 @@ namespace Discord.Rest
|
|||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
||||||
Components = component?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
Components = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ??Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<API.Rest.CreatePollParams>.Unspecified,
|
Poll = poll?.ToModel() ?? Optional<API.Rest.CreatePollParams>.Unspecified
|
||||||
Flags = ephemeral
|
|
||||||
? flags | MessageFlags.Ephemeral
|
|
||||||
: flags == MessageFlags.None
|
|
||||||
? Optional<MessageFlags>.Unspecified
|
|
||||||
: flags,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ephemeral)
|
||||||
|
args.Flags = MessageFlags.Ephemeral;
|
||||||
|
|
||||||
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,13 +194,12 @@ namespace Discord.Rest
|
|||||||
MessageComponent component = null,
|
MessageComponent component = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -221,16 +216,14 @@ namespace Discord.Rest
|
|||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
||||||
Components = component?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
Components = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
File = fileStream is not null ? new MultipartFile(fileStream, fileName) : Optional<MultipartFile>.Unspecified,
|
File = fileStream is not null ? new MultipartFile(fileStream, fileName) : Optional<MultipartFile>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<API.Rest.CreatePollParams>.Unspecified,
|
Poll = poll?.ToModel() ?? Optional<API.Rest.CreatePollParams>.Unspecified,
|
||||||
Flags = ephemeral
|
|
||||||
? flags | MessageFlags.Ephemeral
|
|
||||||
: flags == MessageFlags.None
|
|
||||||
? Optional<MessageFlags>.Unspecified
|
|
||||||
: flags,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ephemeral)
|
||||||
|
args.Flags = MessageFlags.Ephemeral;
|
||||||
|
|
||||||
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,13 +254,12 @@ namespace Discord.Rest
|
|||||||
MessageComponent component = null,
|
MessageComponent component = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -287,16 +279,14 @@ namespace Discord.Rest
|
|||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
||||||
Components = component?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
Components = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
File = fileStream != null ? new MultipartFile(fileStream, fileName) : Optional<MultipartFile>.Unspecified,
|
File = fileStream != null ? new MultipartFile(fileStream, fileName) : Optional<MultipartFile>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<API.Rest.CreatePollParams>.Unspecified,
|
Poll = poll?.ToModel() ?? Optional<API.Rest.CreatePollParams>.Unspecified
|
||||||
Flags = ephemeral
|
|
||||||
? flags | MessageFlags.Ephemeral
|
|
||||||
: flags == MessageFlags.None
|
|
||||||
? Optional<MessageFlags>.Unspecified
|
|
||||||
: flags,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ephemeral)
|
||||||
|
args.Flags = MessageFlags.Ephemeral;
|
||||||
|
|
||||||
return await InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
return await InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,8 +315,7 @@ namespace Discord.Rest
|
|||||||
MessageComponent component = null,
|
MessageComponent component = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
@@ -334,7 +323,7 @@ namespace Discord.Rest
|
|||||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -368,12 +357,8 @@ namespace Discord.Rest
|
|||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
||||||
TTS = isTTS,
|
TTS = isTTS,
|
||||||
Components = component?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
Components = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = ephemeral
|
Flags = ephemeral ? MessageFlags.Ephemeral : Optional<MessageFlags>.Unspecified,
|
||||||
? flags | MessageFlags.Ephemeral
|
|
||||||
: flags == MessageFlags.None
|
|
||||||
? Optional<MessageFlags>.Unspecified
|
|
||||||
: flags,
|
|
||||||
Poll = poll?.ToModel() ?? Optional<API.Rest.CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<API.Rest.CreatePollParams>.Unspecified
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -405,13 +390,12 @@ namespace Discord.Rest
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -441,18 +425,19 @@ namespace Discord.Rest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var flags = MessageFlags.None;
|
||||||
|
|
||||||
|
if (ephemeral)
|
||||||
|
flags |= MessageFlags.Ephemeral;
|
||||||
|
|
||||||
var args = new API.Rest.UploadWebhookFileParams(attachments.ToArray())
|
var args = new API.Rest.UploadWebhookFileParams(attachments.ToArray())
|
||||||
{
|
{
|
||||||
Flags = ephemeral
|
Flags = flags,
|
||||||
? flags | MessageFlags.Ephemeral
|
|
||||||
: flags == MessageFlags.None
|
|
||||||
? Optional<MessageFlags>.Unspecified
|
|
||||||
: flags,
|
|
||||||
Content = text,
|
Content = text,
|
||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
MessageComponents = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
MessageComponents = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<API.Rest.CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<API.Rest.CreatePollParams>.Unspecified
|
||||||
};
|
};
|
||||||
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
||||||
@@ -469,10 +454,9 @@ namespace Discord.Rest
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
return FollowupWithFilesAsync([attachment], text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
return FollowupWithFilesAsync(new FileAttachment[] { attachment }, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -557,8 +541,8 @@ namespace Discord.Rest
|
|||||||
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
||||||
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
||||||
Components = args.Components.IsSpecified
|
Components = args.Components.IsSpecified
|
||||||
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? []
|
? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Array.Empty<API.ActionRowComponent>()
|
||||||
: Optional<IMessageComponent[]>.Unspecified,
|
: Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
|
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -567,7 +551,7 @@ namespace Discord.Rest
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var attachments = args.Attachments.Value?.ToArray() ?? [];
|
var attachments = args.Attachments.Value?.ToArray() ?? Array.Empty<FileAttachment>();
|
||||||
|
|
||||||
var response = new API.Rest.UploadInteractionFileParams(attachments)
|
var response = new API.Rest.UploadInteractionFileParams(attachments)
|
||||||
{
|
{
|
||||||
@@ -576,8 +560,8 @@ namespace Discord.Rest
|
|||||||
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
||||||
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
||||||
MessageComponents = args.Components.IsSpecified
|
MessageComponents = args.Components.IsSpecified
|
||||||
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? []
|
? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Array.Empty<API.ActionRowComponent>()
|
||||||
: Optional<IMessageComponent[]>.Unspecified,
|
: Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
|
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using DataModel = Discord.API.MessageComponentInteractionData;
|
||||||
|
using InterationModel = Discord.API.Interaction;
|
||||||
using Model = Discord.API.ModalInteractionData;
|
using Model = Discord.API.ModalInteractionData;
|
||||||
|
|
||||||
namespace Discord.Rest
|
namespace Discord.Rest
|
||||||
@@ -23,7 +26,7 @@ namespace Discord.Rest
|
|||||||
{
|
{
|
||||||
CustomId = model.CustomId;
|
CustomId = model.CustomId;
|
||||||
Components = model.Components
|
Components = model.Components
|
||||||
.SelectMany(x => x.Components.OfType<IInteractableComponent>())
|
.SelectMany(x => x.Components)
|
||||||
.Select(x => new RestMessageComponentData(x, discord, guild))
|
.Select(x => new RestMessageComponentData(x, discord, guild))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ namespace Discord.Rest
|
|||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public abstract string Respond(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
public abstract string Respond(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None);
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a followup message for this interaction.
|
/// Sends a followup message for this interaction.
|
||||||
@@ -361,7 +361,7 @@ namespace Discord.Rest
|
|||||||
/// contains the sent message.
|
/// contains the sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public abstract Task<RestFollowupMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
public abstract Task<RestFollowupMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None);
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a followup message for this interaction.
|
/// Sends a followup message for this interaction.
|
||||||
@@ -382,7 +382,7 @@ namespace Discord.Rest
|
|||||||
/// contains the sent message.
|
/// contains the sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public abstract Task<RestFollowupMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
public abstract Task<RestFollowupMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None);
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a followup message for this interaction.
|
/// Sends a followup message for this interaction.
|
||||||
@@ -403,7 +403,7 @@ namespace Discord.Rest
|
|||||||
/// contains the sent message.
|
/// contains the sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public abstract Task<RestFollowupMessage> FollowupWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
public abstract Task<RestFollowupMessage> FollowupWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None);
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a followup message for this interaction.
|
/// Sends a followup message for this interaction.
|
||||||
@@ -423,7 +423,7 @@ namespace Discord.Rest
|
|||||||
/// contains the sent message.
|
/// contains the sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public abstract Task<RestFollowupMessage> FollowupWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
public abstract Task<RestFollowupMessage> FollowupWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None);
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a followup message for this interaction.
|
/// Sends a followup message for this interaction.
|
||||||
@@ -443,7 +443,7 @@ namespace Discord.Rest
|
|||||||
/// contains the sent message.
|
/// contains the sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public abstract Task<RestFollowupMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
public abstract Task<RestFollowupMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None);
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public Task DeleteOriginalResponseAsync(RequestOptions options = null)
|
public Task DeleteOriginalResponseAsync(RequestOptions options = null)
|
||||||
@@ -462,7 +462,7 @@ namespace Discord.Rest
|
|||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
Task IDiscordInteraction.RespondAsync(string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions,
|
Task IDiscordInteraction.RespondAsync(string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions,
|
||||||
MessageComponent components, Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags)
|
MessageComponent components, Embed embed, RequestOptions options, PollProperties poll)
|
||||||
=> Task.FromResult(Respond(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll));
|
=> Task.FromResult(Respond(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll));
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
Task IDiscordInteraction.DeferAsync(bool ephemeral, RequestOptions options)
|
Task IDiscordInteraction.DeferAsync(bool ephemeral, RequestOptions options)
|
||||||
@@ -470,48 +470,45 @@ namespace Discord.Rest
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
Task IDiscordInteraction.RespondWithModalAsync(Modal modal, RequestOptions options)
|
Task IDiscordInteraction.RespondWithModalAsync(Modal modal, RequestOptions options)
|
||||||
=> Task.FromResult(RespondWithModal(modal, options));
|
=> Task.FromResult(RespondWithModal(modal, options));
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
async Task<IUserMessage> IDiscordInteraction.FollowupAsync(string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions,
|
async Task<IUserMessage> IDiscordInteraction.FollowupAsync(string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions,
|
||||||
MessageComponent components, Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags)
|
MessageComponent components, Embed embed, RequestOptions options, PollProperties poll)
|
||||||
=> await FollowupAsync(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
=> await FollowupAsync(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
async Task<IUserMessage> IDiscordInteraction.GetOriginalResponseAsync(RequestOptions options)
|
async Task<IUserMessage> IDiscordInteraction.GetOriginalResponseAsync(RequestOptions options)
|
||||||
=> await GetOriginalResponseAsync(options).ConfigureAwait(false);
|
=> await GetOriginalResponseAsync(options).ConfigureAwait(false);
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
async Task<IUserMessage> IDiscordInteraction.ModifyOriginalResponseAsync(Action<MessageProperties> func, RequestOptions options)
|
async Task<IUserMessage> IDiscordInteraction.ModifyOriginalResponseAsync(Action<MessageProperties> func, RequestOptions options)
|
||||||
=> await ModifyOriginalResponseAsync(func, options).ConfigureAwait(false);
|
=> await ModifyOriginalResponseAsync(func, options).ConfigureAwait(false);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
async Task<IUserMessage> IDiscordInteraction.FollowupWithFileAsync(Stream fileStream, string fileName, string text, Embed[] embeds, bool isTTS, bool ephemeral,
|
async Task<IUserMessage> IDiscordInteraction.FollowupWithFileAsync(Stream fileStream, string fileName, string text, Embed[] embeds, bool isTTS, bool ephemeral,
|
||||||
AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags)
|
AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll)
|
||||||
=> await FollowupWithFileAsync(fileStream, fileName, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
=> await FollowupWithFileAsync(fileStream, fileName, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
async Task<IUserMessage> IDiscordInteraction.FollowupWithFileAsync(string filePath, string fileName, string text, Embed[] embeds, bool isTTS, bool ephemeral,
|
async Task<IUserMessage> IDiscordInteraction.FollowupWithFileAsync(string filePath, string fileName, string text, Embed[] embeds, bool isTTS, bool ephemeral,
|
||||||
AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags)
|
AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll)
|
||||||
=> await FollowupWithFileAsync(filePath, text, fileName, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
=> await FollowupWithFileAsync(filePath, text, fileName, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
async Task<IUserMessage> IDiscordInteraction.FollowupWithFileAsync(FileAttachment attachment, string text, Embed[] embeds, bool isTTS,
|
async Task<IUserMessage> IDiscordInteraction.FollowupWithFileAsync(FileAttachment attachment, string text, Embed[] embeds, bool isTTS,
|
||||||
bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags)
|
bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll)
|
||||||
=> await FollowupWithFileAsync(attachment, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
=> await FollowupWithFileAsync(attachment, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
async Task<IUserMessage> IDiscordInteraction.FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text, Embed[] embeds, bool isTTS,
|
async Task<IUserMessage> IDiscordInteraction.FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text, Embed[] embeds, bool isTTS,
|
||||||
bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags)
|
bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll)
|
||||||
=> await FollowupWithFilesAsync(attachments, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
=> await FollowupWithFilesAsync(attachments, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
Task IDiscordInteraction.RespondWithFilesAsync(IEnumerable<FileAttachment> attachments, string text, Embed[] embeds, bool isTTS, bool ephemeral,
|
Task IDiscordInteraction.RespondWithFilesAsync(IEnumerable<FileAttachment> attachments, string text, Embed[] embeds, bool isTTS, bool ephemeral,
|
||||||
AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags) => throw new NotSupportedException("REST-Based interactions don't support files.");
|
AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll) => throw new NotSupportedException("REST-Based interactions don't support files.");
|
||||||
#if NETCOREAPP3_0_OR_GREATER != true
|
#if NETCOREAPP3_0_OR_GREATER != true
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
Task IDiscordInteraction.RespondWithFileAsync(Stream fileStream, string fileName, string text, Embed[] embeds, bool isTTS, bool ephemeral,
|
Task IDiscordInteraction.RespondWithFileAsync(Stream fileStream, string fileName, string text, Embed[] embeds, bool isTTS, bool ephemeral,
|
||||||
AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags) => throw new NotSupportedException("REST-Based interactions don't support files.");
|
AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll) => throw new NotSupportedException("REST-Based interactions don't support files.");
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
Task IDiscordInteraction.RespondWithFileAsync(string filePath, string fileName, string text, Embed[] embeds, bool isTTS,
|
Task IDiscordInteraction.RespondWithFileAsync(string filePath, string fileName, string text, Embed[] embeds, bool isTTS,
|
||||||
bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags) => throw new NotSupportedException("REST-Based interactions don't support files.");
|
bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll) => throw new NotSupportedException("REST-Based interactions don't support files.");
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
Task IDiscordInteraction.RespondWithFileAsync(FileAttachment attachment, string text, Embed[] embeds, bool isTTS, bool ephemeral,
|
Task IDiscordInteraction.RespondWithFileAsync(FileAttachment attachment, string text, Embed[] embeds, bool isTTS, bool ephemeral,
|
||||||
AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags) => throw new NotSupportedException("REST-Based interactions don't support files.");
|
AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll) => throw new NotSupportedException("REST-Based interactions don't support files.");
|
||||||
#endif
|
#endif
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ namespace Discord.Rest
|
|||||||
|
|
||||||
public override string Defer(bool ephemeral = false, RequestOptions options = null) => throw new NotSupportedException();
|
public override string Defer(bool ephemeral = false, RequestOptions options = null) => throw new NotSupportedException();
|
||||||
public override string RespondWithModal(Modal modal, RequestOptions options = null) => throw new NotSupportedException();
|
public override string RespondWithModal(Modal modal, RequestOptions options = null) => throw new NotSupportedException();
|
||||||
public override string Respond(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None) => throw new NotSupportedException();
|
public override string Respond(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null) => throw new NotSupportedException();
|
||||||
public override Task<RestFollowupMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None) => throw new NotSupportedException();
|
public override Task<RestFollowupMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null) => throw new NotSupportedException();
|
||||||
public override Task<RestFollowupMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None) => throw new NotSupportedException();
|
public override Task<RestFollowupMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null) => throw new NotSupportedException();
|
||||||
public override Task<RestFollowupMessage> FollowupWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None) => throw new NotSupportedException();
|
public override Task<RestFollowupMessage> FollowupWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null) => throw new NotSupportedException();
|
||||||
public override Task<RestFollowupMessage> FollowupWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None) => throw new NotSupportedException();
|
public override Task<RestFollowupMessage> FollowupWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null) => throw new NotSupportedException();
|
||||||
public override Task<RestFollowupMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None) => throw new NotSupportedException();
|
public override Task<RestFollowupMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null) => throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,17 +100,17 @@ namespace Discord.Rest
|
|||||||
=> Respond(result, options);
|
=> Respond(result, options);
|
||||||
public override string Defer(bool ephemeral = false, RequestOptions options = null)
|
public override string Defer(bool ephemeral = false, RequestOptions options = null)
|
||||||
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
||||||
public override string Respond(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
public override string Respond(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
||||||
public override Task<RestFollowupMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
public override Task<RestFollowupMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
||||||
public override Task<RestFollowupMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
public override Task<RestFollowupMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
||||||
public override Task<RestFollowupMessage> FollowupWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
public override Task<RestFollowupMessage> FollowupWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
||||||
public override Task<RestFollowupMessage> FollowupWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
public override Task<RestFollowupMessage> FollowupWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
||||||
public override Task<RestFollowupMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
public override Task<RestFollowupMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
||||||
public override string RespondWithModal(Modal modal, RequestOptions options = null)
|
public override string RespondWithModal(Modal modal, RequestOptions options = null)
|
||||||
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
||||||
|
|||||||
@@ -55,16 +55,16 @@ namespace Discord.Rest
|
|||||||
Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed.");
|
Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed.");
|
||||||
|
|
||||||
// check that user flag and user Id list are exclusive, same with role flag and role Id list
|
// check that user flag and user Id list are exclusive, same with role flag and role Id list
|
||||||
if (allowedMentions is { AllowedTypes: not null })
|
if (allowedMentions != null && allowedMentions.AllowedTypes.HasValue)
|
||||||
{
|
{
|
||||||
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Users) &&
|
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Users) &&
|
||||||
allowedMentions.UserIds is { Count: > 0 })
|
allowedMentions.UserIds != null && allowedMentions.UserIds.Count > 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("The Users flag is mutually exclusive with the list of User Ids.", nameof(allowedMentions));
|
throw new ArgumentException("The Users flag is mutually exclusive with the list of User Ids.", nameof(allowedMentions));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Roles) &&
|
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Roles) &&
|
||||||
allowedMentions.RoleIds is { Count: > 0 })
|
allowedMentions.RoleIds != null && allowedMentions.RoleIds.Count > 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(allowedMentions));
|
throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(allowedMentions));
|
||||||
}
|
}
|
||||||
@@ -93,13 +93,13 @@ namespace Discord.Rest
|
|||||||
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
||||||
Flags = args.Flags.IsSpecified ? args.Flags.Value : Optional.Create<MessageFlags?>(),
|
Flags = args.Flags.IsSpecified ? args.Flags.Value : Optional.Create<MessageFlags?>(),
|
||||||
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value.ToModel() : Optional.Create<API.AllowedMentions>(),
|
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value.ToModel() : Optional.Create<API.AllowedMentions>(),
|
||||||
Components = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? [] : Optional<IMessageComponent[]>.Unspecified,
|
Components = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Array.Empty<API.ActionRowComponent>() : Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
};
|
};
|
||||||
return client.ApiClient.ModifyMessageAsync(channelId, msgId, apiArgs, options);
|
return client.ApiClient.ModifyMessageAsync(channelId, msgId, apiArgs, options);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var attachments = args.Attachments.Value?.ToArray() ?? [];
|
var attachments = args.Attachments.Value?.ToArray() ?? Array.Empty<FileAttachment>();
|
||||||
|
|
||||||
var apiArgs = new UploadFileParams(attachments)
|
var apiArgs = new UploadFileParams(attachments)
|
||||||
{
|
{
|
||||||
@@ -107,7 +107,7 @@ namespace Discord.Rest
|
|||||||
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
||||||
Flags = args.Flags.IsSpecified ? args.Flags.Value : Optional.Create<MessageFlags?>(),
|
Flags = args.Flags.IsSpecified ? args.Flags.Value : Optional.Create<MessageFlags?>(),
|
||||||
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value.ToModel() : Optional.Create<API.AllowedMentions>(),
|
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value.ToModel() : Optional.Create<API.AllowedMentions>(),
|
||||||
MessageComponent = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? [] : Optional<IMessageComponent[]>.Unspecified
|
MessageComponent = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Array.Empty<API.ActionRowComponent>() : Optional<API.ActionRowComponent[]>.Unspecified
|
||||||
};
|
};
|
||||||
|
|
||||||
return client.ApiClient.ModifyMessageAsync(channelId, msgId, apiArgs, options);
|
return client.ApiClient.ModifyMessageAsync(channelId, msgId, apiArgs, options);
|
||||||
|
|||||||
@@ -95,12 +95,12 @@ namespace Discord.Rest
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public PurchaseNotification PurchaseNotification { get; private set; }
|
public PurchaseNotification PurchaseNotification { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public MessageCallData? CallData { get; private set; }
|
public MessageCallData? CallData { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc cref="IMessage.Components"/>
|
/// <inheritdoc cref="IMessage.Components"/>
|
||||||
public IReadOnlyCollection<IMessageComponent> Components { get; private set; }
|
public IReadOnlyCollection<ActionRowComponent> Components { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a collection of the mentioned users in the message.
|
/// Gets a collection of the mentioned users in the message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -150,7 +150,7 @@ namespace Discord.Rest
|
|||||||
if (model.Activity.IsSpecified)
|
if (model.Activity.IsSpecified)
|
||||||
{
|
{
|
||||||
// create a new Activity from the API model
|
// create a new Activity from the API model
|
||||||
Activity = new MessageActivity
|
Activity = new MessageActivity()
|
||||||
{
|
{
|
||||||
Type = model.Activity.Value.Type.Value,
|
Type = model.Activity.Value.Type.Value,
|
||||||
PartyId = model.Activity.Value.PartyId.GetValueOrDefault()
|
PartyId = model.Activity.Value.PartyId.GetValueOrDefault()
|
||||||
@@ -170,9 +170,62 @@ namespace Discord.Rest
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Components = model.Components.IsSpecified
|
if (model.Components.IsSpecified)
|
||||||
? model.Components.Value.Select(x => x.ToEntity()).ToImmutableArray()
|
{
|
||||||
: [];
|
Components = model.Components.Value.Where(x => x.Type is ComponentType.ActionRow)
|
||||||
|
.Select(x => new ActionRowComponent(((API.ActionRowComponent)x).Components.Select<IMessageComponent, IMessageComponent>(y =>
|
||||||
|
{
|
||||||
|
switch (y.Type)
|
||||||
|
{
|
||||||
|
case ComponentType.Button:
|
||||||
|
{
|
||||||
|
var parsed = (API.ButtonComponent)y;
|
||||||
|
return new Discord.ButtonComponent(
|
||||||
|
parsed.Style,
|
||||||
|
parsed.Label.GetValueOrDefault(),
|
||||||
|
parsed.Emote.IsSpecified
|
||||||
|
? parsed.Emote.Value.Id.HasValue
|
||||||
|
? new Emote(parsed.Emote.Value.Id.Value, parsed.Emote.Value.Name, parsed.Emote.Value.Animated.GetValueOrDefault())
|
||||||
|
: new Emoji(parsed.Emote.Value.Name)
|
||||||
|
: null,
|
||||||
|
parsed.CustomId.GetValueOrDefault(),
|
||||||
|
parsed.Url.GetValueOrDefault(),
|
||||||
|
parsed.Disabled.GetValueOrDefault(),
|
||||||
|
parsed.SkuId.ToNullable());
|
||||||
|
}
|
||||||
|
case ComponentType.SelectMenu or ComponentType.ChannelSelect or ComponentType.RoleSelect or ComponentType.MentionableSelect or ComponentType.UserSelect:
|
||||||
|
{
|
||||||
|
var parsed = (API.SelectMenuComponent)y;
|
||||||
|
return new SelectMenuComponent(
|
||||||
|
parsed.CustomId,
|
||||||
|
parsed.Options?.Select(z => new SelectMenuOption(
|
||||||
|
z.Label,
|
||||||
|
z.Value,
|
||||||
|
z.Description.GetValueOrDefault(),
|
||||||
|
z.Emoji.IsSpecified
|
||||||
|
? z.Emoji.Value.Id.HasValue
|
||||||
|
? new Emote(z.Emoji.Value.Id.Value, z.Emoji.Value.Name, z.Emoji.Value.Animated.GetValueOrDefault())
|
||||||
|
: new Emoji(z.Emoji.Value.Name)
|
||||||
|
: null,
|
||||||
|
z.Default.ToNullable())).ToList(),
|
||||||
|
parsed.Placeholder.GetValueOrDefault(),
|
||||||
|
parsed.MinValues,
|
||||||
|
parsed.MaxValues,
|
||||||
|
parsed.Disabled,
|
||||||
|
parsed.Type,
|
||||||
|
parsed.ChannelTypes.GetValueOrDefault(),
|
||||||
|
parsed.DefaultValues.IsSpecified
|
||||||
|
? parsed.DefaultValues.Value.Select(x => new SelectMenuDefaultValue(x.Id, x.Type))
|
||||||
|
: Array.Empty<SelectMenuDefaultValue>()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}).ToList())).ToImmutableArray();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Components = new List<ActionRowComponent>();
|
||||||
|
|
||||||
if (model.Flags.IsSpecified)
|
if (model.Flags.IsSpecified)
|
||||||
Flags = model.Flags.Value;
|
Flags = model.Flags.Value;
|
||||||
@@ -183,16 +236,15 @@ namespace Discord.Rest
|
|||||||
if (value.Length > 0)
|
if (value.Length > 0)
|
||||||
{
|
{
|
||||||
var reactions = ImmutableArray.CreateBuilder<RestReaction>(value.Length);
|
var reactions = ImmutableArray.CreateBuilder<RestReaction>(value.Length);
|
||||||
foreach (var t in value)
|
for (int i = 0; i < value.Length; i++)
|
||||||
reactions.Add(RestReaction.Create(t));
|
reactions.Add(RestReaction.Create(value[i]));
|
||||||
|
|
||||||
_reactions = reactions.ToImmutable();
|
_reactions = reactions.ToImmutable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_reactions = [];
|
_reactions = ImmutableArray.Create<RestReaction>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_reactions = [];
|
_reactions = ImmutableArray.Create<RestReaction>();
|
||||||
|
|
||||||
if (model.Interaction.IsSpecified)
|
if (model.Interaction.IsSpecified)
|
||||||
{
|
{
|
||||||
@@ -237,11 +289,11 @@ namespace Discord.Rest
|
|||||||
? new GuildProductPurchase(model.PurchaseNotification.Value.ProductPurchase.Value.ListingId, model.PurchaseNotification.Value.ProductPurchase.Value.ProductName)
|
? new GuildProductPurchase(model.PurchaseNotification.Value.ProductPurchase.Value.ListingId, model.PurchaseNotification.Value.ProductPurchase.Value.ProductName)
|
||||||
: null);
|
: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.Call.IsSpecified)
|
if (model.Call.IsSpecified)
|
||||||
CallData = new MessageCallData(model.Call.Value.Participants, model.Call.Value.EndedTimestamp.ToNullable());
|
CallData = new MessageCallData(model.Call.Value.Participants, model.Call.Value.EndedTimestamp.ToNullable());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task UpdateAsync(RequestOptions options = null)
|
public async Task UpdateAsync(RequestOptions options = null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ namespace Discord.Rest
|
|||||||
if (model.MentionEveryone.IsSpecified)
|
if (model.MentionEveryone.IsSpecified)
|
||||||
_isMentioningEveryone = model.MentionEveryone.Value;
|
_isMentioningEveryone = model.MentionEveryone.Value;
|
||||||
if (model.RoleMentions.IsSpecified)
|
if (model.RoleMentions.IsSpecified)
|
||||||
_roleMentionIds = [..model.RoleMentions.Value];
|
_roleMentionIds = model.RoleMentions.Value.ToImmutableArray();
|
||||||
|
|
||||||
if (model.Attachments.IsSpecified)
|
if (model.Attachments.IsSpecified)
|
||||||
{
|
{
|
||||||
@@ -92,13 +92,12 @@ namespace Discord.Rest
|
|||||||
if (value.Length > 0)
|
if (value.Length > 0)
|
||||||
{
|
{
|
||||||
var attachments = ImmutableArray.CreateBuilder<Attachment>(value.Length);
|
var attachments = ImmutableArray.CreateBuilder<Attachment>(value.Length);
|
||||||
foreach (var t in value)
|
for (int i = 0; i < value.Length; i++)
|
||||||
attachments.Add(Attachment.Create(t, Discord));
|
attachments.Add(Attachment.Create(value[i], Discord));
|
||||||
|
|
||||||
_attachments = attachments.ToImmutable();
|
_attachments = attachments.ToImmutable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_attachments = [];
|
_attachments = ImmutableArray.Create<Attachment>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.Embeds.IsSpecified)
|
if (model.Embeds.IsSpecified)
|
||||||
@@ -107,13 +106,12 @@ namespace Discord.Rest
|
|||||||
if (value.Length > 0)
|
if (value.Length > 0)
|
||||||
{
|
{
|
||||||
var embeds = ImmutableArray.CreateBuilder<Embed>(value.Length);
|
var embeds = ImmutableArray.CreateBuilder<Embed>(value.Length);
|
||||||
foreach (var t in value)
|
for (int i = 0; i < value.Length; i++)
|
||||||
embeds.Add(t.ToEntity());
|
embeds.Add(value[i].ToEntity());
|
||||||
|
|
||||||
_embeds = embeds.ToImmutable();
|
_embeds = embeds.ToImmutable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_embeds = [];
|
_embeds = ImmutableArray.Create<Embed>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var guildId = (Channel as IGuildChannel)?.GuildId;
|
var guildId = (Channel as IGuildChannel)?.GuildId;
|
||||||
@@ -125,7 +123,7 @@ namespace Discord.Rest
|
|||||||
model.Content = text;
|
model.Content = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.ReferencedMessage is { IsSpecified: true, Value: not null })
|
if (model.ReferencedMessage.IsSpecified && model.ReferencedMessage.Value != null)
|
||||||
{
|
{
|
||||||
var refMsg = model.ReferencedMessage.Value;
|
var refMsg = model.ReferencedMessage.Value;
|
||||||
IUser refMsgAuthor = MessageHelper.GetAuthor(Discord, guild, refMsg.Author.Value, refMsg.WebhookId.ToNullable());
|
IUser refMsgAuthor = MessageHelper.GetAuthor(Discord, guild, refMsg.Author.Value, refMsg.WebhookId.ToNullable());
|
||||||
@@ -143,7 +141,7 @@ namespace Discord.Rest
|
|||||||
_stickers = stickers.ToImmutable();
|
_stickers = stickers.ToImmutable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_stickers = [];
|
_stickers = ImmutableArray.Create<StickerItem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.Resolved.IsSpecified)
|
if (model.Resolved.IsSpecified)
|
||||||
|
|||||||
@@ -1,198 +0,0 @@
|
|||||||
using System.Collections.Immutable;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Discord.Rest;
|
|
||||||
|
|
||||||
internal static class MessageComponentExtension
|
|
||||||
{
|
|
||||||
internal static IMessageComponent ToModel(this IMessageComponent component)
|
|
||||||
{
|
|
||||||
switch (component)
|
|
||||||
{
|
|
||||||
case ActionRowComponent actionRow:
|
|
||||||
return new API.ActionRowComponent(actionRow);
|
|
||||||
|
|
||||||
case ButtonComponent btn:
|
|
||||||
return new API.ButtonComponent(btn);
|
|
||||||
|
|
||||||
case SelectMenuComponent select:
|
|
||||||
return new API.SelectMenuComponent(select);
|
|
||||||
|
|
||||||
case TextInputComponent textInput:
|
|
||||||
return new API.TextInputComponent(textInput);
|
|
||||||
|
|
||||||
case TextDisplayComponent textDisplay:
|
|
||||||
return new API.TextDisplayComponent(textDisplay);
|
|
||||||
|
|
||||||
case SectionComponent section:
|
|
||||||
return new API.SectionComponent(section);
|
|
||||||
|
|
||||||
case ThumbnailComponent thumbnail:
|
|
||||||
return new API.ThumbnailComponent(thumbnail);
|
|
||||||
|
|
||||||
case MediaGalleryComponent mediaGallery:
|
|
||||||
return new API.MediaGalleryComponent(mediaGallery);
|
|
||||||
|
|
||||||
case SeparatorComponent separator:
|
|
||||||
return new API.SeparatorComponent(separator);
|
|
||||||
|
|
||||||
case FileComponent file:
|
|
||||||
return new API.FileComponent(file);
|
|
||||||
|
|
||||||
case ContainerComponent container:
|
|
||||||
return new API.ContainerComponent(container);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static IMessageComponent ToEntity(this IMessageComponent component)
|
|
||||||
{
|
|
||||||
switch (component.Type)
|
|
||||||
{
|
|
||||||
case ComponentType.ActionRow:
|
|
||||||
{
|
|
||||||
var parsed = (API.ActionRowComponent)component;
|
|
||||||
return new ActionRowComponent
|
|
||||||
{
|
|
||||||
Id = component.Id,
|
|
||||||
Components = parsed.Components.Select(x => x.ToEntity()).ToImmutableArray()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
case ComponentType.Button:
|
|
||||||
{
|
|
||||||
var parsed = (API.ButtonComponent)component;
|
|
||||||
return new ButtonComponent(
|
|
||||||
parsed.Style,
|
|
||||||
parsed.Label.GetValueOrDefault(),
|
|
||||||
parsed.Emote.IsSpecified
|
|
||||||
? parsed.Emote.Value.Id.HasValue
|
|
||||||
? new Emote(parsed.Emote.Value.Id.Value, parsed.Emote.Value.Name, parsed.Emote.Value.Animated.GetValueOrDefault())
|
|
||||||
: new Emoji(parsed.Emote.Value.Name)
|
|
||||||
: null,
|
|
||||||
parsed.CustomId.GetValueOrDefault(),
|
|
||||||
parsed.Url.GetValueOrDefault(),
|
|
||||||
parsed.Disabled.GetValueOrDefault(),
|
|
||||||
parsed.SkuId.ToNullable(),
|
|
||||||
parsed.Id.ToNullable());
|
|
||||||
}
|
|
||||||
|
|
||||||
case ComponentType.SelectMenu or ComponentType.ChannelSelect or ComponentType.RoleSelect or ComponentType.MentionableSelect or ComponentType.UserSelect:
|
|
||||||
{
|
|
||||||
var parsed = (API.SelectMenuComponent)component;
|
|
||||||
return new SelectMenuComponent(
|
|
||||||
parsed.CustomId,
|
|
||||||
parsed.Options?.Select(z => new SelectMenuOption(
|
|
||||||
z.Label,
|
|
||||||
z.Value,
|
|
||||||
z.Description.GetValueOrDefault(),
|
|
||||||
z.Emoji.IsSpecified
|
|
||||||
? z.Emoji.Value.Id.HasValue
|
|
||||||
? new Emote(z.Emoji.Value.Id.Value, z.Emoji.Value.Name, z.Emoji.Value.Animated.GetValueOrDefault())
|
|
||||||
: new Emoji(z.Emoji.Value.Name)
|
|
||||||
: null,
|
|
||||||
z.Default.ToNullable())).ToList(),
|
|
||||||
parsed.Placeholder.GetValueOrDefault(),
|
|
||||||
parsed.MinValues,
|
|
||||||
parsed.MaxValues,
|
|
||||||
parsed.Disabled,
|
|
||||||
parsed.Type,
|
|
||||||
parsed.Id.ToNullable(),
|
|
||||||
parsed.ChannelTypes.GetValueOrDefault(),
|
|
||||||
parsed.DefaultValues.IsSpecified
|
|
||||||
? parsed.DefaultValues.Value.Select(x => new SelectMenuDefaultValue(x.Id, x.Type))
|
|
||||||
: []
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
case ComponentType.TextInput:
|
|
||||||
{
|
|
||||||
var parsed = (API.TextInputComponent)component;
|
|
||||||
return new TextInputComponent(parsed.CustomId,
|
|
||||||
parsed.Label,
|
|
||||||
parsed.Placeholder.GetValueOrDefault(null),
|
|
||||||
parsed.MinLength.ToNullable(),
|
|
||||||
parsed.MaxLength.ToNullable(),
|
|
||||||
parsed.Style,
|
|
||||||
parsed.Required.ToNullable(),
|
|
||||||
parsed.Value.GetValueOrDefault(null),
|
|
||||||
parsed.Id.ToNullable());
|
|
||||||
}
|
|
||||||
|
|
||||||
case ComponentType.TextDisplay:
|
|
||||||
{
|
|
||||||
var parsed = (API.TextDisplayComponent)component;
|
|
||||||
return new TextDisplayComponent(parsed.Content, parsed.Id.ToNullable());
|
|
||||||
}
|
|
||||||
|
|
||||||
case ComponentType.Section:
|
|
||||||
{
|
|
||||||
var parsed = (API.SectionComponent)component;
|
|
||||||
return new SectionComponent(parsed.Id.ToNullable(),
|
|
||||||
parsed.Components.Select(x => x.ToEntity()).ToImmutableArray(),
|
|
||||||
parsed.Accessory.ToEntity());
|
|
||||||
}
|
|
||||||
|
|
||||||
case ComponentType.Thumbnail:
|
|
||||||
{
|
|
||||||
var parsed = (API.ThumbnailComponent)component;
|
|
||||||
return new ThumbnailComponent(parsed.Id.ToNullable(),
|
|
||||||
parsed.Media.ToEntity(),
|
|
||||||
parsed.Description.GetValueOrDefault(null),
|
|
||||||
parsed.IsSpoiler.ToNullable());
|
|
||||||
}
|
|
||||||
|
|
||||||
case ComponentType.MediaGallery:
|
|
||||||
{
|
|
||||||
var parsed = (API.MediaGalleryComponent)component;
|
|
||||||
|
|
||||||
return new MediaGalleryComponent(
|
|
||||||
parsed.Items.Select(x => new MediaGalleryItem(x.Media.ToEntity(), x.Description.GetValueOrDefault(null), x.IsSpoiler.GetValueOrDefault(false))).ToList(),
|
|
||||||
parsed.Id.ToNullable());
|
|
||||||
}
|
|
||||||
|
|
||||||
case ComponentType.Separator:
|
|
||||||
{
|
|
||||||
var parsed = (API.SeparatorComponent)component;
|
|
||||||
return new SeparatorComponent(parsed.IsDivider.ToNullable(), parsed.Spacing.ToNullable(), parsed.Id.ToNullable());
|
|
||||||
}
|
|
||||||
|
|
||||||
case ComponentType.File:
|
|
||||||
{
|
|
||||||
var parsed = (API.FileComponent)component;
|
|
||||||
return new FileComponent(parsed.File.ToEntity(), parsed.IsSpoiler.ToNullable(), parsed.Id.ToNullable());
|
|
||||||
}
|
|
||||||
|
|
||||||
case ComponentType.Container:
|
|
||||||
{
|
|
||||||
var parsed = (API.ContainerComponent)component;
|
|
||||||
return new ContainerComponent(parsed.Components.Select(x => x.ToEntity()).ToImmutableArray(),
|
|
||||||
parsed.AccentColor.GetValueOrDefault(null),
|
|
||||||
parsed.IsSpoiler.ToNullable(),
|
|
||||||
parsed.Id.ToNullable());
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static UnfurledMediaItem ToEntity(this API.UnfurledMediaItem mediaItem)
|
|
||||||
{
|
|
||||||
return new ResolvedUnfurledMediaItem(mediaItem.Url,
|
|
||||||
mediaItem.ProxyUrl.GetValueOrDefault(null),
|
|
||||||
mediaItem.Height.GetValueOrDefault(0).GetValueOrDefault(0),
|
|
||||||
mediaItem.Width.GetValueOrDefault(0).GetValueOrDefault(0),
|
|
||||||
mediaItem.ContentType.GetValueOrDefault(null),
|
|
||||||
mediaItem.LoadingState.GetValueOrDefault(UnfurledMediaItemLoadingState.Unknown));
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static API.UnfurledMediaItem ToModel(this UnfurledMediaItem mediaItem)
|
|
||||||
{
|
|
||||||
return new API.UnfurledMediaItem
|
|
||||||
{
|
|
||||||
Url = mediaItem.Url
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace Discord.Net.Converters
|
namespace Discord.Net.Converters
|
||||||
{
|
{
|
||||||
internal class MessageComponentConverter : JsonConverter
|
internal class MessageComponentConverter : JsonConverter
|
||||||
{
|
{
|
||||||
public static MessageComponentConverter Instance => new ();
|
public static MessageComponentConverter Instance => new MessageComponentConverter();
|
||||||
|
|
||||||
public override bool CanRead => true;
|
public override bool CanRead => true;
|
||||||
public override bool CanWrite => false;
|
public override bool CanWrite => false;
|
||||||
@@ -40,27 +39,6 @@ namespace Discord.Net.Converters
|
|||||||
case ComponentType.TextInput:
|
case ComponentType.TextInput:
|
||||||
messageComponent = new API.TextInputComponent();
|
messageComponent = new API.TextInputComponent();
|
||||||
break;
|
break;
|
||||||
case ComponentType.TextDisplay:
|
|
||||||
messageComponent = new API.TextDisplayComponent();
|
|
||||||
break;
|
|
||||||
case ComponentType.Thumbnail:
|
|
||||||
messageComponent = new API.ThumbnailComponent();
|
|
||||||
break;
|
|
||||||
case ComponentType.Section:
|
|
||||||
messageComponent = new API.SectionComponent();
|
|
||||||
break;
|
|
||||||
case ComponentType.MediaGallery:
|
|
||||||
messageComponent = new API.MediaGalleryComponent();
|
|
||||||
break;
|
|
||||||
case ComponentType.Separator:
|
|
||||||
messageComponent = new API.SeparatorComponent();
|
|
||||||
break;
|
|
||||||
case ComponentType.File:
|
|
||||||
messageComponent = new API.FileComponent();
|
|
||||||
break;
|
|
||||||
case ComponentType.Container:
|
|
||||||
messageComponent = new API.ContainerComponent();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
serializer.Populate(jsonObject.CreateReader(), messageComponent);
|
serializer.Populate(jsonObject.CreateReader(), messageComponent);
|
||||||
return messageComponent;
|
return messageComponent;
|
||||||
|
|||||||
@@ -82,8 +82,7 @@ namespace Discord.WebSocket
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
@@ -91,7 +90,7 @@ namespace Discord.WebSocket
|
|||||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -116,13 +115,6 @@ namespace Discord.WebSocket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false)
|
|
||||||
flags |= MessageFlags.ComponentsV2;
|
|
||||||
if (ephemeral)
|
|
||||||
flags |= MessageFlags.Ephemeral;
|
|
||||||
|
|
||||||
Preconditions.ValidateMessageFlags(flags);
|
|
||||||
|
|
||||||
var response = new API.Rest.UploadInteractionFileParams(attachments?.ToArray())
|
var response = new API.Rest.UploadInteractionFileParams(attachments?.ToArray())
|
||||||
{
|
{
|
||||||
Type = InteractionResponseType.ChannelMessageWithSource,
|
Type = InteractionResponseType.ChannelMessageWithSource,
|
||||||
@@ -130,8 +122,8 @@ namespace Discord.WebSocket
|
|||||||
AllowedMentions = allowedMentions != null ? allowedMentions?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions != null ? allowedMentions?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
||||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
MessageComponents = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
MessageComponents = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = flags,
|
Flags = ephemeral ? MessageFlags.Ephemeral : Optional<MessageFlags>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -157,8 +149,7 @@ namespace Discord.WebSocket
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
@@ -166,7 +157,7 @@ namespace Discord.WebSocket
|
|||||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -176,28 +167,21 @@ namespace Discord.WebSocket
|
|||||||
Preconditions.ValidatePoll(poll);
|
Preconditions.ValidatePoll(poll);
|
||||||
|
|
||||||
// check that user flag and user Id list are exclusive, same with role flag and role Id list
|
// check that user flag and user Id list are exclusive, same with role flag and role Id list
|
||||||
if (allowedMentions is { AllowedTypes: not null })
|
if (allowedMentions != null && allowedMentions.AllowedTypes.HasValue)
|
||||||
{
|
{
|
||||||
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Users) &&
|
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Users) &&
|
||||||
allowedMentions.UserIds is { Count: > 0 })
|
allowedMentions.UserIds != null && allowedMentions.UserIds.Count > 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("The Users flag is mutually exclusive with the list of User Ids.", nameof(allowedMentions));
|
throw new ArgumentException("The Users flag is mutually exclusive with the list of User Ids.", nameof(allowedMentions));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Roles) &&
|
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Roles) &&
|
||||||
allowedMentions.RoleIds is { Count: > 0 })
|
allowedMentions.RoleIds != null && allowedMentions.RoleIds.Count > 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(allowedMentions));
|
throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(allowedMentions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false)
|
|
||||||
flags |= MessageFlags.ComponentsV2;
|
|
||||||
if (ephemeral)
|
|
||||||
flags |= MessageFlags.Ephemeral;
|
|
||||||
|
|
||||||
Preconditions.ValidateMessageFlags(flags);
|
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
{
|
{
|
||||||
Type = InteractionResponseType.ChannelMessageWithSource,
|
Type = InteractionResponseType.ChannelMessageWithSource,
|
||||||
@@ -207,8 +191,8 @@ namespace Discord.WebSocket
|
|||||||
AllowedMentions = allowedMentions?.ToModel(),
|
AllowedMentions = allowedMentions?.ToModel(),
|
||||||
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
||||||
TTS = isTTS,
|
TTS = isTTS,
|
||||||
Flags = flags,
|
Flags = ephemeral ? MessageFlags.Ephemeral : Optional<MessageFlags>.Unspecified,
|
||||||
Components = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
Components = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -266,13 +250,13 @@ namespace Discord.WebSocket
|
|||||||
{
|
{
|
||||||
var allowedMentions = args.AllowedMentions.Value;
|
var allowedMentions = args.AllowedMentions.Value;
|
||||||
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Users)
|
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Users)
|
||||||
&& allowedMentions.UserIds is { Count: > 0 })
|
&& allowedMentions.UserIds != null && allowedMentions.UserIds.Count > 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("The Users flag is mutually exclusive with the list of User Ids.", nameof(args.AllowedMentions));
|
throw new ArgumentException("The Users flag is mutually exclusive with the list of User Ids.", nameof(args.AllowedMentions));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Roles)
|
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Roles)
|
||||||
&& allowedMentions.RoleIds is { Count: > 0 })
|
&& allowedMentions.RoleIds != null && allowedMentions.RoleIds.Count > 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(args.AllowedMentions));
|
throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(args.AllowedMentions));
|
||||||
}
|
}
|
||||||
@@ -289,8 +273,8 @@ namespace Discord.WebSocket
|
|||||||
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
||||||
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
||||||
Components = args.Components.IsSpecified
|
Components = args.Components.IsSpecified
|
||||||
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? []
|
? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Array.Empty<API.ActionRowComponent>()
|
||||||
: Optional<IMessageComponent[]>.Unspecified,
|
: Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
|
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -299,7 +283,7 @@ namespace Discord.WebSocket
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var attachments = args.Attachments.Value?.ToArray() ?? [];
|
var attachments = args.Attachments.Value?.ToArray() ?? Array.Empty<FileAttachment>();
|
||||||
|
|
||||||
var response = new API.Rest.UploadInteractionFileParams(attachments)
|
var response = new API.Rest.UploadInteractionFileParams(attachments)
|
||||||
{
|
{
|
||||||
@@ -308,8 +292,8 @@ namespace Discord.WebSocket
|
|||||||
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
||||||
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
||||||
MessageComponents = args.Components.IsSpecified
|
MessageComponents = args.Components.IsSpecified
|
||||||
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? []
|
? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Array.Empty<API.ActionRowComponent>()
|
||||||
: Optional<IMessageComponent[]>.Unspecified,
|
: Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
|
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -337,13 +321,12 @@ namespace Discord.WebSocket
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -352,25 +335,19 @@ namespace Discord.WebSocket
|
|||||||
Preconditions.AtMost(embeds.Length, 10, nameof(embeds), "A max of 10 embeds are allowed.");
|
Preconditions.AtMost(embeds.Length, 10, nameof(embeds), "A max of 10 embeds are allowed.");
|
||||||
Preconditions.ValidatePoll(poll);
|
Preconditions.ValidatePoll(poll);
|
||||||
|
|
||||||
if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false)
|
|
||||||
flags |= MessageFlags.ComponentsV2;
|
|
||||||
if (ephemeral)
|
|
||||||
flags |= MessageFlags.Ephemeral;
|
|
||||||
|
|
||||||
Preconditions.ValidateMessageFlags(flags);
|
|
||||||
|
|
||||||
|
|
||||||
var args = new API.Rest.CreateWebhookMessageParams
|
var args = new API.Rest.CreateWebhookMessageParams
|
||||||
{
|
{
|
||||||
Content = text,
|
Content = text,
|
||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
||||||
Components = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
Components = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified,
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
Flags = flags,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ephemeral)
|
||||||
|
args.Flags = MessageFlags.Ephemeral;
|
||||||
|
|
||||||
return InteractionHelper.SendFollowupAsync(Discord.Rest, args, Token, Channel, options);
|
return InteractionHelper.SendFollowupAsync(Discord.Rest, args, Token, Channel, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,13 +362,12 @@ namespace Discord.WebSocket
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -409,24 +385,23 @@ namespace Discord.WebSocket
|
|||||||
if (allowedMentions != null && allowedMentions.AllowedTypes.HasValue)
|
if (allowedMentions != null && allowedMentions.AllowedTypes.HasValue)
|
||||||
{
|
{
|
||||||
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Users) &&
|
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Users) &&
|
||||||
allowedMentions.UserIds is { Count: > 0 })
|
allowedMentions.UserIds != null && allowedMentions.UserIds.Count > 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("The Users flag is mutually exclusive with the list of User Ids.", nameof(allowedMentions));
|
throw new ArgumentException("The Users flag is mutually exclusive with the list of User Ids.", nameof(allowedMentions));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Roles) &&
|
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Roles) &&
|
||||||
allowedMentions.RoleIds is { Count: > 0 })
|
allowedMentions.RoleIds != null && allowedMentions.RoleIds.Count > 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(allowedMentions));
|
throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(allowedMentions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false)
|
|
||||||
flags |= MessageFlags.ComponentsV2;
|
var flags = MessageFlags.None;
|
||||||
|
|
||||||
if (ephemeral)
|
if (ephemeral)
|
||||||
flags |= MessageFlags.Ephemeral;
|
flags |= MessageFlags.Ephemeral;
|
||||||
|
|
||||||
Preconditions.ValidateMessageFlags(flags);
|
|
||||||
|
|
||||||
var args = new API.Rest.UploadWebhookFileParams(attachments.ToArray())
|
var args = new API.Rest.UploadWebhookFileParams(attachments.ToArray())
|
||||||
{
|
{
|
||||||
Flags = flags,
|
Flags = flags,
|
||||||
@@ -434,7 +409,7 @@ namespace Discord.WebSocket
|
|||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
MessageComponents = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
MessageComponents = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
};
|
};
|
||||||
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
||||||
|
|||||||
@@ -90,13 +90,13 @@ namespace Discord.WebSocket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal SocketMessageComponentData(IInteractableComponent component, DiscordSocketClient discord, ClientState state, SocketGuild guild, API.User dmUser)
|
internal SocketMessageComponentData(IMessageComponent component, DiscordSocketClient discord, ClientState state, SocketGuild guild, API.User dmUser)
|
||||||
{
|
{
|
||||||
CustomId = component.CustomId;
|
CustomId = component.CustomId;
|
||||||
Type = component.Type;
|
Type = component.Type;
|
||||||
|
|
||||||
Value = component.Type == ComponentType.TextInput
|
Value = component.Type == ComponentType.TextInput
|
||||||
? ((TextInputComponent)component).Value
|
? (component as API.TextInputComponent).Value.Value
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (component is API.SelectMenuComponent select)
|
if (component is API.SelectMenuComponent select)
|
||||||
|
|||||||
@@ -79,8 +79,7 @@ namespace Discord.WebSocket
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
@@ -88,7 +87,7 @@ namespace Discord.WebSocket
|
|||||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -112,12 +111,6 @@ namespace Discord.WebSocket
|
|||||||
throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(allowedMentions));
|
throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(allowedMentions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false)
|
|
||||||
flags |= MessageFlags.ComponentsV2;
|
|
||||||
if (ephemeral)
|
|
||||||
flags |= MessageFlags.Ephemeral;
|
|
||||||
|
|
||||||
Preconditions.ValidateMessageFlags(flags);
|
|
||||||
|
|
||||||
var response = new API.Rest.UploadInteractionFileParams(attachments?.ToArray())
|
var response = new API.Rest.UploadInteractionFileParams(attachments?.ToArray())
|
||||||
{
|
{
|
||||||
@@ -126,8 +119,8 @@ namespace Discord.WebSocket
|
|||||||
AllowedMentions = allowedMentions != null ? allowedMentions?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions != null ? allowedMentions?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
||||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
MessageComponents = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
MessageComponents = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = flags,
|
Flags = ephemeral ? MessageFlags.Ephemeral : Optional<MessageFlags>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -143,7 +136,7 @@ namespace Discord.WebSocket
|
|||||||
HasResponded = true;
|
HasResponded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="IDiscordInteraction.RespondAsync"/>
|
/// <inheritdoc/>
|
||||||
public override async Task RespondAsync(
|
public override async Task RespondAsync(
|
||||||
string text = null,
|
string text = null,
|
||||||
Embed[] embeds = null,
|
Embed[] embeds = null,
|
||||||
@@ -153,8 +146,7 @@ namespace Discord.WebSocket
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
@@ -162,7 +154,7 @@ namespace Discord.WebSocket
|
|||||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -172,28 +164,21 @@ namespace Discord.WebSocket
|
|||||||
Preconditions.ValidatePoll(poll);
|
Preconditions.ValidatePoll(poll);
|
||||||
|
|
||||||
// check that user flag and user Id list are exclusive, same with role flag and role Id list
|
// check that user flag and user Id list are exclusive, same with role flag and role Id list
|
||||||
if (allowedMentions is { AllowedTypes: not null })
|
if (allowedMentions != null && allowedMentions.AllowedTypes.HasValue)
|
||||||
{
|
{
|
||||||
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Users) &&
|
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Users) &&
|
||||||
allowedMentions.UserIds is { Count: > 0 })
|
allowedMentions.UserIds != null && allowedMentions.UserIds.Count > 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("The Users flag is mutually exclusive with the list of User Ids.", nameof(allowedMentions));
|
throw new ArgumentException("The Users flag is mutually exclusive with the list of User Ids.", nameof(allowedMentions));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Roles) &&
|
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Roles) &&
|
||||||
allowedMentions.RoleIds is { Count: > 0 })
|
allowedMentions.RoleIds != null && allowedMentions.RoleIds.Count > 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(allowedMentions));
|
throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(allowedMentions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false)
|
|
||||||
flags |= MessageFlags.ComponentsV2;
|
|
||||||
if (ephemeral)
|
|
||||||
flags |= MessageFlags.Ephemeral;
|
|
||||||
|
|
||||||
Preconditions.ValidateMessageFlags(flags);
|
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
{
|
{
|
||||||
Type = InteractionResponseType.ChannelMessageWithSource,
|
Type = InteractionResponseType.ChannelMessageWithSource,
|
||||||
@@ -203,8 +188,8 @@ namespace Discord.WebSocket
|
|||||||
AllowedMentions = allowedMentions?.ToModel(),
|
AllowedMentions = allowedMentions?.ToModel(),
|
||||||
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
||||||
TTS = isTTS,
|
TTS = isTTS,
|
||||||
Flags = flags,
|
Flags = ephemeral ? MessageFlags.Ephemeral : Optional<MessageFlags>.Unspecified,
|
||||||
Components = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
Components = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -285,11 +270,9 @@ namespace Discord.WebSocket
|
|||||||
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
||||||
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
||||||
Components = args.Components.IsSpecified
|
Components = args.Components.IsSpecified
|
||||||
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? []
|
? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Array.Empty<API.ActionRowComponent>()
|
||||||
: Optional<IMessageComponent[]>.Unspecified,
|
: Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = args.Flags.IsSpecified
|
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
|
||||||
? args.Flags.Value ?? Optional<MessageFlags>.Unspecified
|
|
||||||
: Optional<MessageFlags>.Unspecified
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -306,8 +289,8 @@ namespace Discord.WebSocket
|
|||||||
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
||||||
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
||||||
MessageComponents = args.Components.IsSpecified
|
MessageComponents = args.Components.IsSpecified
|
||||||
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? []
|
? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Array.Empty<API.ActionRowComponent>()
|
||||||
: Optional<IMessageComponent[]>.Unspecified,
|
: Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
|
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -335,13 +318,12 @@ namespace Discord.WebSocket
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -350,24 +332,20 @@ namespace Discord.WebSocket
|
|||||||
Preconditions.AtMost(embeds.Length, 10, nameof(embeds), "A max of 10 embeds are allowed.");
|
Preconditions.AtMost(embeds.Length, 10, nameof(embeds), "A max of 10 embeds are allowed.");
|
||||||
Preconditions.ValidatePoll(poll);
|
Preconditions.ValidatePoll(poll);
|
||||||
|
|
||||||
if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false)
|
|
||||||
flags |= MessageFlags.ComponentsV2;
|
|
||||||
if (ephemeral)
|
|
||||||
flags |= MessageFlags.Ephemeral;
|
|
||||||
|
|
||||||
Preconditions.ValidateMessageFlags(flags);
|
|
||||||
|
|
||||||
var args = new API.Rest.CreateWebhookMessageParams
|
var args = new API.Rest.CreateWebhookMessageParams
|
||||||
{
|
{
|
||||||
Content = text,
|
Content = text,
|
||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
||||||
Components = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
Components = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = flags,
|
Flags = ephemeral ? MessageFlags.Ephemeral : Optional<MessageFlags>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ephemeral)
|
||||||
|
args.Flags = MessageFlags.Ephemeral;
|
||||||
|
|
||||||
return InteractionHelper.SendFollowupAsync(Discord.Rest, args, Token, Channel, options);
|
return InteractionHelper.SendFollowupAsync(Discord.Rest, args, Token, Channel, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,13 +360,12 @@ namespace Discord.WebSocket
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -418,13 +395,11 @@ namespace Discord.WebSocket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false)
|
var flags = MessageFlags.None;
|
||||||
flags |= MessageFlags.ComponentsV2;
|
|
||||||
if (ephemeral)
|
if (ephemeral)
|
||||||
flags |= MessageFlags.Ephemeral;
|
flags |= MessageFlags.Ephemeral;
|
||||||
|
|
||||||
Preconditions.ValidateMessageFlags(flags);
|
|
||||||
|
|
||||||
var args = new API.Rest.UploadWebhookFileParams(attachments.ToArray())
|
var args = new API.Rest.UploadWebhookFileParams(attachments.ToArray())
|
||||||
{
|
{
|
||||||
Flags = flags,
|
Flags = flags,
|
||||||
@@ -432,7 +407,7 @@ namespace Discord.WebSocket
|
|||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
MessageComponents = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
MessageComponents = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
};
|
};
|
||||||
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using Discord.Rest;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using DataModel = Discord.API.MessageComponentInteractionData;
|
||||||
|
using InterationModel = Discord.API.Interaction;
|
||||||
using Model = Discord.API.ModalInteractionData;
|
using Model = Discord.API.ModalInteractionData;
|
||||||
|
|
||||||
namespace Discord.WebSocket
|
namespace Discord.WebSocket
|
||||||
@@ -24,7 +26,7 @@ namespace Discord.WebSocket
|
|||||||
{
|
{
|
||||||
CustomId = model.CustomId;
|
CustomId = model.CustomId;
|
||||||
Components = model.Components
|
Components = model.Components
|
||||||
.SelectMany(x => x.Components.Select(y => y.ToEntity()).OfType<IInteractableComponent>())
|
.SelectMany(x => x.Components)
|
||||||
.Select(x => new SocketMessageComponentData(x, discord, state, guild, dmUser))
|
.Select(x => new SocketMessageComponentData(x, discord, state, guild, dmUser))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,15 +91,15 @@ namespace Discord.WebSocket
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public Task RespondAsync(RequestOptions options = null, params AutocompleteResult[] result)
|
public Task RespondAsync(RequestOptions options = null, params AutocompleteResult[] result)
|
||||||
=> RespondAsync(result, options);
|
=> RespondAsync(result, options);
|
||||||
public override Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
public override Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
||||||
public override Task<RestFollowupMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
public override Task<RestFollowupMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
||||||
public override Task<RestFollowupMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
public override Task<RestFollowupMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
||||||
public override Task DeferAsync(bool ephemeral = false, RequestOptions options = null)
|
public override Task DeferAsync(bool ephemeral = false, RequestOptions options = null)
|
||||||
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
||||||
public override Task RespondWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
public override Task RespondWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
=> throw new NotSupportedException("Autocomplete interactions don't support this method!");
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -77,8 +77,7 @@ namespace Discord.WebSocket
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
@@ -86,7 +85,7 @@ namespace Discord.WebSocket
|
|||||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -111,13 +110,6 @@ namespace Discord.WebSocket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false)
|
|
||||||
flags |= MessageFlags.ComponentsV2;
|
|
||||||
if (ephemeral)
|
|
||||||
flags |= MessageFlags.Ephemeral;
|
|
||||||
|
|
||||||
Preconditions.ValidateMessageFlags(flags);
|
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
{
|
{
|
||||||
Type = InteractionResponseType.ChannelMessageWithSource,
|
Type = InteractionResponseType.ChannelMessageWithSource,
|
||||||
@@ -127,8 +119,8 @@ namespace Discord.WebSocket
|
|||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
||||||
TTS = isTTS,
|
TTS = isTTS,
|
||||||
Components = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
Components = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Flags = flags,
|
Flags = ephemeral ? MessageFlags.Ephemeral : Optional<MessageFlags>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -191,8 +183,7 @@ namespace Discord.WebSocket
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
@@ -200,7 +191,7 @@ namespace Discord.WebSocket
|
|||||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -225,13 +216,6 @@ namespace Discord.WebSocket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false)
|
|
||||||
flags |= MessageFlags.ComponentsV2;
|
|
||||||
if (ephemeral)
|
|
||||||
flags |= MessageFlags.Ephemeral;
|
|
||||||
|
|
||||||
Preconditions.ValidateMessageFlags(flags);
|
|
||||||
|
|
||||||
var response = new API.Rest.UploadInteractionFileParams(attachments?.ToArray())
|
var response = new API.Rest.UploadInteractionFileParams(attachments?.ToArray())
|
||||||
{
|
{
|
||||||
Type = InteractionResponseType.ChannelMessageWithSource,
|
Type = InteractionResponseType.ChannelMessageWithSource,
|
||||||
@@ -239,8 +223,8 @@ namespace Discord.WebSocket
|
|||||||
AllowedMentions = allowedMentions != null ? allowedMentions?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions != null ? allowedMentions?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
||||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
Flags = flags,
|
Flags = ephemeral ? MessageFlags.Ephemeral : Optional<MessageFlags>.Unspecified,
|
||||||
MessageComponents = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
MessageComponents = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -266,13 +250,12 @@ namespace Discord.WebSocket
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -281,24 +264,19 @@ namespace Discord.WebSocket
|
|||||||
Preconditions.AtMost(embeds.Length, 10, nameof(embeds), "A max of 10 embeds are allowed.");
|
Preconditions.AtMost(embeds.Length, 10, nameof(embeds), "A max of 10 embeds are allowed.");
|
||||||
Preconditions.ValidatePoll(poll);
|
Preconditions.ValidatePoll(poll);
|
||||||
|
|
||||||
if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false)
|
|
||||||
flags |= MessageFlags.ComponentsV2;
|
|
||||||
if (ephemeral)
|
|
||||||
flags |= MessageFlags.Ephemeral;
|
|
||||||
|
|
||||||
Preconditions.ValidateMessageFlags(flags);
|
|
||||||
|
|
||||||
var args = new API.Rest.CreateWebhookMessageParams
|
var args = new API.Rest.CreateWebhookMessageParams
|
||||||
{
|
{
|
||||||
Content = text ?? Optional<string>.Unspecified,
|
Content = text ?? Optional<string>.Unspecified,
|
||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
|
||||||
Components = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
Components = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified,
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
Flags = flags,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ephemeral)
|
||||||
|
args.Flags = MessageFlags.Ephemeral;
|
||||||
|
|
||||||
return InteractionHelper.SendFollowupAsync(Discord.Rest, args, Token, Channel, options);
|
return InteractionHelper.SendFollowupAsync(Discord.Rest, args, Token, Channel, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,13 +291,12 @@ namespace Discord.WebSocket
|
|||||||
MessageComponent components = null,
|
MessageComponent components = null,
|
||||||
Embed embed = null,
|
Embed embed = null,
|
||||||
RequestOptions options = null,
|
RequestOptions options = null,
|
||||||
PollProperties poll = null,
|
PollProperties poll = null)
|
||||||
MessageFlags flags = MessageFlags.None)
|
|
||||||
{
|
{
|
||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||||
|
|
||||||
embeds ??= [];
|
embeds ??= Array.Empty<Embed>();
|
||||||
if (embed != null)
|
if (embed != null)
|
||||||
embeds = new[] { embed }.Concat(embeds).ToArray();
|
embeds = new[] { embed }.Concat(embeds).ToArray();
|
||||||
|
|
||||||
@@ -349,13 +326,11 @@ namespace Discord.WebSocket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false)
|
var flags = MessageFlags.None;
|
||||||
flags |= MessageFlags.ComponentsV2;
|
|
||||||
if (ephemeral)
|
if (ephemeral)
|
||||||
flags |= MessageFlags.Ephemeral;
|
flags |= MessageFlags.Ephemeral;
|
||||||
|
|
||||||
Preconditions.ValidateMessageFlags(flags);
|
|
||||||
|
|
||||||
var args = new API.Rest.UploadWebhookFileParams(attachments.ToArray())
|
var args = new API.Rest.UploadWebhookFileParams(attachments.ToArray())
|
||||||
{
|
{
|
||||||
Flags = flags,
|
Flags = flags,
|
||||||
@@ -363,7 +338,7 @@ namespace Discord.WebSocket
|
|||||||
IsTTS = isTTS,
|
IsTTS = isTTS,
|
||||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||||
MessageComponents = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
MessageComponents = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||||
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
Poll = poll?.ToModel() ?? Optional<CreatePollParams>.Unspecified
|
||||||
};
|
};
|
||||||
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
return InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options);
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ namespace Discord.WebSocket
|
|||||||
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
|
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
|
||||||
/// <exception cref="InvalidOperationException">The parameters provided were invalid or the token was invalid.</exception>
|
/// <exception cref="InvalidOperationException">The parameters provided were invalid or the token was invalid.</exception>
|
||||||
public abstract Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false,
|
public abstract Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false,
|
||||||
bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None);
|
bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Responds to this interaction with a file attachment.
|
/// Responds to this interaction with a file attachment.
|
||||||
@@ -237,11 +237,11 @@ namespace Discord.WebSocket
|
|||||||
/// contains the sent message.
|
/// contains the sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task RespondWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
public async Task RespondWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
{
|
{
|
||||||
using (var file = new FileAttachment(fileStream, fileName))
|
using (var file = new FileAttachment(fileStream, fileName))
|
||||||
{
|
{
|
||||||
await RespondWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
await RespondWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,11 +264,11 @@ namespace Discord.WebSocket
|
|||||||
/// contains the sent message.
|
/// contains the sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task RespondWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
public async Task RespondWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
{
|
{
|
||||||
using (var file = new FileAttachment(filePath, fileName))
|
using (var file = new FileAttachment(filePath, fileName))
|
||||||
{
|
{
|
||||||
await RespondWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
await RespondWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,8 +290,8 @@ namespace Discord.WebSocket
|
|||||||
/// contains the sent message.
|
/// contains the sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public Task RespondWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
public Task RespondWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> RespondWithFilesAsync([attachment], text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
=> RespondWithFilesAsync(new FileAttachment[] { attachment }, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Responds to this interaction with a collection of file attachments.
|
/// Responds to this interaction with a collection of file attachments.
|
||||||
@@ -311,7 +311,7 @@ namespace Discord.WebSocket
|
|||||||
/// contains the sent message.
|
/// contains the sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public abstract Task RespondWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
public abstract Task RespondWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None);
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a followup message for this interaction.
|
/// Sends a followup message for this interaction.
|
||||||
@@ -329,7 +329,7 @@ namespace Discord.WebSocket
|
|||||||
/// The sent message.
|
/// The sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public abstract Task<RestFollowupMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
public abstract Task<RestFollowupMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None);
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a followup message for this interaction.
|
/// Sends a followup message for this interaction.
|
||||||
@@ -349,11 +349,11 @@ namespace Discord.WebSocket
|
|||||||
/// The sent message.
|
/// The sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task<RestFollowupMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
public async Task<RestFollowupMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
{
|
{
|
||||||
using (var file = new FileAttachment(fileStream, fileName))
|
using (var file = new FileAttachment(fileStream, fileName))
|
||||||
{
|
{
|
||||||
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,11 +375,11 @@ namespace Discord.WebSocket
|
|||||||
/// The sent message.
|
/// The sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task<RestFollowupMessage> FollowupWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
public async Task<RestFollowupMessage> FollowupWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
{
|
{
|
||||||
using (var file = new FileAttachment(filePath, fileName))
|
using (var file = new FileAttachment(filePath, fileName))
|
||||||
{
|
{
|
||||||
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,8 +401,8 @@ namespace Discord.WebSocket
|
|||||||
/// contains the sent message.
|
/// contains the sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public Task<RestFollowupMessage> FollowupWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
public Task<RestFollowupMessage> FollowupWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
|
||||||
=> FollowupWithFilesAsync(new FileAttachment[] { attachment }, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags);
|
=> FollowupWithFilesAsync(new FileAttachment[] { attachment }, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a followup message for this interaction.
|
/// Sends a followup message for this interaction.
|
||||||
@@ -422,7 +422,7 @@ namespace Discord.WebSocket
|
|||||||
/// contains the sent message.
|
/// contains the sent message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public abstract Task<RestFollowupMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
public abstract Task<RestFollowupMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
|
||||||
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None);
|
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the original response for this interaction.
|
/// Gets the original response for this interaction.
|
||||||
@@ -509,26 +509,26 @@ namespace Discord.WebSocket
|
|||||||
=> await ModifyOriginalResponseAsync(func, options).ConfigureAwait(false);
|
=> await ModifyOriginalResponseAsync(func, options).ConfigureAwait(false);
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
async Task IDiscordInteraction.RespondAsync(string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions, MessageComponent components,
|
async Task IDiscordInteraction.RespondAsync(string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions, MessageComponent components,
|
||||||
Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags)
|
Embed embed, RequestOptions options, PollProperties poll)
|
||||||
=> await RespondAsync(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
=> await RespondAsync(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
async Task<IUserMessage> IDiscordInteraction.FollowupAsync(string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions,
|
async Task<IUserMessage> IDiscordInteraction.FollowupAsync(string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions,
|
||||||
MessageComponent components, Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags)
|
MessageComponent components, Embed embed, RequestOptions options, PollProperties poll)
|
||||||
=> await FollowupAsync(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
=> await FollowupAsync(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
async Task<IUserMessage> IDiscordInteraction.FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text, Embed[] embeds, bool isTTS,
|
async Task<IUserMessage> IDiscordInteraction.FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text, Embed[] embeds, bool isTTS,
|
||||||
bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags)
|
bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll)
|
||||||
=> await FollowupWithFilesAsync(attachments, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
=> await FollowupWithFilesAsync(attachments, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
#if NETCOREAPP3_0_OR_GREATER != true
|
#if NETCOREAPP3_0_OR_GREATER != true
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
async Task<IUserMessage> IDiscordInteraction.FollowupWithFileAsync(Stream fileStream, string fileName, string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags)
|
async Task<IUserMessage> IDiscordInteraction.FollowupWithFileAsync(Stream fileStream, string fileName, string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll)
|
||||||
=> await FollowupWithFileAsync(fileStream, fileName, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
=> await FollowupWithFileAsync(fileStream, fileName, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
async Task<IUserMessage> IDiscordInteraction.FollowupWithFileAsync(string filePath, string fileName, string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags)
|
async Task<IUserMessage> IDiscordInteraction.FollowupWithFileAsync(string filePath, string fileName, string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll)
|
||||||
=> await FollowupWithFileAsync(filePath, fileName, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
=> await FollowupWithFileAsync(filePath, fileName, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
async Task<IUserMessage> IDiscordInteraction.FollowupWithFileAsync(FileAttachment attachment, string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll, MessageFlags flags)
|
async Task<IUserMessage> IDiscordInteraction.FollowupWithFileAsync(FileAttachment attachment, string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options, PollProperties poll)
|
||||||
=> await FollowupWithFileAsync(attachment, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll, flags).ConfigureAwait(false);
|
=> await FollowupWithFileAsync(attachment, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options, poll).ConfigureAwait(false);
|
||||||
#endif
|
#endif
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user