Skip to content

Commit

Permalink
[Feature] Polls (#2902)
Browse files Browse the repository at this point in the history
no breakings hopefully
  • Loading branch information
Misha-133 committed May 11, 2024
1 parent 5dadcb2 commit 476ec06
Show file tree
Hide file tree
Showing 75 changed files with 1,372 additions and 424 deletions.
15 changes: 15 additions & 0 deletions src/Discord.Net.Core/DiscordConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,21 @@ public class DiscordConfig
/// </summary>
public const int MaxEntitlementsPerBatch = 100;

/// <summary>
/// Returns the maximum number of poll answer voters that can be gotten per-batch.
/// </summary>
public const int MaxPollVotersPerBatch = 100;

/// <summary>
/// Returns the maximum length of a poll answer text.
/// </summary>
public const int MaxPollAnswerTextLength = 55;

/// <summary>
/// Returns the maximum length of a poll question text.
/// </summary>
public const int MaxPollQuestionTextLength = 300;

/// <summary>
/// Returns the maximum number of bans that can be banned in a single bulk request.
/// </summary>
Expand Down
13 changes: 12 additions & 1 deletion src/Discord.Net.Core/DiscordErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,18 @@ public enum DiscordErrorCode

#region Onboarding (350XXX)
CannotEnableOnboardingUnmetRequirements = 350000,
CannotUpdateOnboardingBelowRequirements = 350001
CannotUpdateOnboardingBelowRequirements = 350001,
#endregion

#region Polls (520XXX)

PollVotingBlocked = 520000,
PollExpired = 520001,
InvalidChannelTypeForPollCreation = 520002,
CannotEditAPollMessage = 520003,
CannotUseAnEmojiIncludedWithThePoll = 520004,
CannotExpireANonPollMessage = 520006,

#endregion
}
}
28 changes: 23 additions & 5 deletions src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ public interface IMessageChannel : IChannel
/// <param name="embeds">A array of <see cref="Embed"/>s to send with this response. Max 10.</param>
/// <param name="flags">A message flag to be applied to the sent message, only <see cref="MessageFlags.SuppressEmbeds"/>
/// and <see cref="MessageFlags.SuppressNotification"/> is permitted.</param>
/// <param name="poll">A poll to send with the message.</param>
/// <returns>
/// A task that represents an asynchronous send operation for delivering the message. The task result
/// contains the sent message.
/// </returns>
Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None);
Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null,
AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None, PollProperties poll = null);

/// <summary>
/// Sends a file to this message channel with an optional caption.
/// </summary>
Expand Down Expand Up @@ -74,11 +78,15 @@ public interface IMessageChannel : IChannel
/// <param name="stickers">A collection of stickers to send with the file.</param>
/// <param name="embeds">A array of <see cref="Embed"/>s to send with this response. Max 10.</param>
/// <param name="flags">A message flag to be applied to the sent message, only <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.SuppressNotification"/> is permitted.</param>
/// <param name="poll">A poll to send with the message.</param>
/// <returns>
/// A task that represents an asynchronous send operation for delivering the message. The task result
/// contains the sent message.
/// </returns>
Task<IUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None);
Task<IUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null,
bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null,
ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None, PollProperties poll = null);

/// <summary>
/// Sends a file to this message channel with an optional caption.
/// </summary>
Expand Down Expand Up @@ -112,11 +120,15 @@ public interface IMessageChannel : IChannel
/// <param name="stickers">A collection of stickers to send with the file.</param>
/// <param name="embeds">A array of <see cref="Embed"/>s to send with this response. Max 10.</param>
/// <param name="flags">A message flag to be applied to the sent message, only <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.SuppressNotification"/> is permitted.</param>
/// <param name="poll">A poll to send with the message.</param>
/// <returns>
/// A task that represents an asynchronous send operation for delivering the message. The task result
/// contains the sent message.
/// </returns>
Task<IUserMessage> SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None);
Task<IUserMessage> SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null,
bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null,
ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None, PollProperties poll = null);

/// <summary>
/// Sends a file to this message channel with an optional caption.
/// </summary>
Expand All @@ -142,11 +154,14 @@ public interface IMessageChannel : IChannel
/// <param name="stickers">A collection of stickers to send with the file.</param>
/// <param name="embeds">A array of <see cref="Embed"/>s to send with this response. Max 10.</param>
/// <param name="flags">A message flag to be applied to the sent message, only <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.SuppressNotification"/> is permitted.</param>
/// <param name="poll">A poll to send with the message.</param>
/// <returns>
/// A task that represents an asynchronous send operation for delivering the message. The task result
/// contains the sent message.
/// </returns>
Task<IUserMessage> SendFileAsync(FileAttachment attachment, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None);
Task<IUserMessage> SendFileAsync(FileAttachment attachment, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null,
AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None, PollProperties poll = null);
/// <summary>
/// Sends a collection of files to this message channel.
/// </summary>
Expand All @@ -172,11 +187,14 @@ public interface IMessageChannel : IChannel
/// <param name="stickers">A collection of stickers to send with the file.</param>
/// <param name="embeds">A array of <see cref="Embed"/>s to send with this response. Max 10.</param>
/// <param name="flags">A message flag to be applied to the sent message, only <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.SuppressNotification"/> is permitted.</param>
/// <param name="poll">A poll to send with the message.</param>
/// <returns>
/// A task that represents an asynchronous send operation for delivering the message. The task result
/// contains the sent message.
/// </returns>
Task<IUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None);
Task<IUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, bool isTTS = false, Embed embed = null,
RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null,
ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None, PollProperties poll = null);

/// <summary>
/// Gets a message from this message channel.
Expand Down
Loading

0 comments on commit 476ec06

Please sign in to comment.