| @@ -127,7 +127,7 @@ publish/ | |||||
| # Publish Web Output | # Publish Web Output | ||||
| *.[Pp]ublish.xml | *.[Pp]ublish.xml | ||||
| *.azurePubxml | *.azurePubxml | ||||
| # TODO: Comment the next line if you want to checkin your web deploy settings | |||||
| # TODO: Comment the next line if you want to checkin your web deploy settings | |||||
| # but database connection strings (with potential passwords) will be unencrypted | # but database connection strings (with potential passwords) will be unencrypted | ||||
| *.pubxml | *.pubxml | ||||
| *.publishproj | *.publishproj | ||||
| @@ -151,7 +151,6 @@ AppPackages/ | |||||
| # Others | # Others | ||||
| *.[Cc]ache | *.[Cc]ache | ||||
| ClientBin/ | ClientBin/ | ||||
| [Ss]tyle[Cc]op.* | |||||
| ~$* | ~$* | ||||
| *~ | *~ | ||||
| *.dbmdl | *.dbmdl | ||||
| @@ -206,4 +205,4 @@ docs/api/\.manifest | |||||
| \.idea/ | \.idea/ | ||||
| # Codealike UID | # Codealike UID | ||||
| codealike.json | |||||
| codealike.json | |||||
| @@ -5,11 +5,11 @@ | |||||
| <LangVersion>latest</LangVersion> | <LangVersion>latest</LangVersion> | ||||
| <Authors>Discord.Net Contributors</Authors> | <Authors>Discord.Net Contributors</Authors> | ||||
| <PackageTags>discord;discordapp</PackageTags> | <PackageTags>discord;discordapp</PackageTags> | ||||
| <PackageProjectUrl>https://github.com/RogueException/Discord.Net</PackageProjectUrl> | |||||
| <PackageProjectUrl>https://github.com/Discord-Net/Discord.Net</PackageProjectUrl> | |||||
| <PackageLicenseUrl>http://opensource.org/licenses/MIT</PackageLicenseUrl> | <PackageLicenseUrl>http://opensource.org/licenses/MIT</PackageLicenseUrl> | ||||
| <PackageIconUrl>https://github.com/RogueException/Discord.Net/raw/dev/docs/marketing/logo/PackageLogo.png</PackageIconUrl> | |||||
| <PackageIconUrl>https://github.com/Discord-Net/Discord.Net/raw/dev/docs/marketing/logo/PackageLogo.png</PackageIconUrl> | |||||
| <RepositoryType>git</RepositoryType> | <RepositoryType>git</RepositoryType> | ||||
| <RepositoryUrl>git://github.com/RogueException/Discord.Net</RepositoryUrl> | |||||
| <RepositoryUrl>git://github.com/Discord-Net/Discord.Net</RepositoryUrl> | |||||
| </PropertyGroup> | </PropertyGroup> | ||||
| <PropertyGroup Condition=" '$(BuildNumber)' == '' "> | <PropertyGroup Condition=" '$(BuildNumber)' == '' "> | ||||
| <VersionSuffix Condition=" '$(VersionSuffix)' != ''">$(VersionSuffix)-dev</VersionSuffix> | <VersionSuffix Condition=" '$(VersionSuffix)' != ''">$(VersionSuffix)-dev</VersionSuffix> | ||||
| @@ -6,7 +6,12 @@ | |||||
| An unofficial .NET API Wrapper for the Discord client (https://discord.com). | An unofficial .NET API Wrapper for the Discord client (https://discord.com). | ||||
| Check out the [documentation](https://discord.foxbot.me/) or join the [Discord API Chat](https://discord.gg/jkrBmQR). | |||||
| ## Documentation | |||||
| - [Stable](https://discord.foxbot.me/) | |||||
| - Hosted by @foxbot | |||||
| - [Nightly](https://docs.stillu.cc/) | |||||
| - [Latest CI repo](https://github.com/discord-net/docs-static) | |||||
| ## Installation | ## Installation | ||||
| ### Stable (NuGet) | ### Stable (NuGet) | ||||
| @@ -0,0 +1,9 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||||
| <!-- <ItemGroup> | |||||
| <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.205" PrivateAssets="all" /> | |||||
| </ItemGroup> | |||||
| <PropertyGroup> | |||||
| <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild> | |||||
| </PropertyGroup> --> | |||||
| </Project> | |||||
| @@ -1,4 +1,4 @@ | |||||
| <configuration> | |||||
| <dllmap os="linux" cpu="x86-64" wordsize="64" dll="git2-a904fc6" target="lib/linux-x64/libgit2-a904fc6.so" /> | |||||
| <dllmap os="osx" cpu="x86,x86-64" dll="git2-a904fc6" target="lib/osx/libgit2-a904fc6.dylib" /> | |||||
| <configuration> | |||||
| <dllmap os="linux" cpu="x86-64" wordsize="64" dll="git2-ef5a385" target="lib/linux-x64/libgit2-ef5a385.so" /> | |||||
| <dllmap os="osx" cpu="x86,x86-64" dll="git2-ef5a385" target="lib/osx/libgit2-ef5a385.dylib" /> | |||||
| </configuration> | </configuration> | ||||
| @@ -27,7 +27,8 @@ | |||||
| </div> | </div> | ||||
| {{/_disableContribution}} | {{/_disableContribution}} | ||||
| <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix"> | <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix"> | ||||
| <!-- <p><a class="back-to-top" href="#top">Back to top</a><p> --> | |||||
| <h5>{{__global.inThisArticle}}</h5> | |||||
| <div></div> | |||||
| </nav> | </nav> | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| @@ -74,6 +74,9 @@ it will return the user ID of the aforementioned user. | |||||
| Several common ways to do this: | Several common ways to do this: | ||||
| 1. Make the role mentionable and mention the role, and escape it | |||||
| 1. (Easiest) Right click on the role either in the Server Settings | |||||
| or in the user's role list. | |||||
|  | |||||
| 2. Make the role mentionable and mention the role, and escape it | |||||
| using the `\` character in front. | using the `\` character in front. | ||||
| 2. Inspect the roles collection within the guild via your debugger. | |||||
| 3. Inspect the roles collection within the guild via your debugger. | |||||
| @@ -1,5 +1,6 @@ | |||||
| <Project Sdk="Microsoft.NET.Sdk"> | <Project Sdk="Microsoft.NET.Sdk"> | ||||
| <Import Project="../../Discord.Net.targets" /> | <Import Project="../../Discord.Net.targets" /> | ||||
| <Import Project="../../StyleAnalyzer.targets"/> | |||||
| <PropertyGroup> | <PropertyGroup> | ||||
| <AssemblyName>Discord.Net.Commands</AssemblyName> | <AssemblyName>Discord.Net.Commands</AssemblyName> | ||||
| <RootNamespace>Discord.Commands</RootNamespace> | <RootNamespace>Discord.Commands</RootNamespace> | ||||
| @@ -35,9 +35,10 @@ namespace Discord.Commands | |||||
| /// Specifies if notifications are sent for mentioned users and roles in the <paramref name="message"/>. | /// Specifies if notifications are sent for mentioned users and roles in the <paramref name="message"/>. | ||||
| /// If <c>null</c>, all mentioned roles and users will be notified. | /// If <c>null</c>, all mentioned roles and users will be notified. | ||||
| /// </param> | /// </param> | ||||
| protected virtual async Task<IUserMessage> ReplyAsync(string message = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null) | |||||
| /// <param name="messageReference">The message references to be included. Used to reply to specific messages.</param> | |||||
| protected virtual async Task<IUserMessage> ReplyAsync(string message = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null) | |||||
| { | { | ||||
| return await Context.Channel.SendMessageAsync(message, isTTS, embed, options, allowedMentions).ConfigureAwait(false); | |||||
| return await Context.Channel.SendMessageAsync(message, isTTS, embed, options, allowedMentions, messageReference).ConfigureAwait(false); | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| /// The method to execute before executing the command. | /// The method to execute before executing the command. | ||||
| @@ -1,4 +1,5 @@ | |||||
| using System; | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
| namespace Discord.Audio | namespace Discord.Audio | ||||
| @@ -20,6 +21,9 @@ namespace Discord.Audio | |||||
| /// <summary> Gets the estimated round-trip latency, in milliseconds, to the voice UDP server. </summary> | /// <summary> Gets the estimated round-trip latency, in milliseconds, to the voice UDP server. </summary> | ||||
| int UdpLatency { get; } | int UdpLatency { get; } | ||||
| /// <summary>Gets the current audio streams.</summary> | |||||
| IReadOnlyDictionary<ulong, AudioInStream> GetStreams(); | |||||
| Task StopAsync(); | Task StopAsync(); | ||||
| Task SetSpeakingAsync(bool value); | Task SetSpeakingAsync(bool value); | ||||
| @@ -7,6 +7,17 @@ namespace Discord | |||||
| /// </summary> | /// </summary> | ||||
| public static class CDN | public static class CDN | ||||
| { | { | ||||
| /// <summary> | |||||
| /// Returns a team icon URL. | |||||
| /// </summary> | |||||
| /// <param name="teamId">The team identifier.</param> | |||||
| /// <param name="iconId">The icon identifier.</param> | |||||
| /// <returns> | |||||
| /// A URL pointing to the team's icon. | |||||
| /// </returns> | |||||
| public static string GetTeamIconUrl(ulong teamId, string iconId) | |||||
| => iconId != null ? $"{DiscordConfig.CDNUrl}team-icons/{teamId}/{iconId}.jpg" : null; | |||||
| /// <summary> | /// <summary> | ||||
| /// Returns an application icon URL. | /// Returns an application icon URL. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -62,11 +73,21 @@ namespace Discord | |||||
| /// <param name="guildId">The guild snowflake identifier.</param> | /// <param name="guildId">The guild snowflake identifier.</param> | ||||
| /// <param name="splashId">The splash icon identifier.</param> | /// <param name="splashId">The splash icon identifier.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A URL pointing to the guild's icon. | |||||
| /// A URL pointing to the guild's splash. | |||||
| /// </returns> | /// </returns> | ||||
| public static string GetGuildSplashUrl(ulong guildId, string splashId) | public static string GetGuildSplashUrl(ulong guildId, string splashId) | ||||
| => splashId != null ? $"{DiscordConfig.CDNUrl}splashes/{guildId}/{splashId}.jpg" : null; | => splashId != null ? $"{DiscordConfig.CDNUrl}splashes/{guildId}/{splashId}.jpg" : null; | ||||
| /// <summary> | /// <summary> | ||||
| /// Returns a guild discovery splash URL. | |||||
| /// </summary> | |||||
| /// <param name="guildId">The guild snowflake identifier.</param> | |||||
| /// <param name="discoverySplashId">The discovery splash icon identifier.</param> | |||||
| /// <returns> | |||||
| /// A URL pointing to the guild's discovery splash. | |||||
| /// </returns> | |||||
| public static string GetGuildDiscoverySplashUrl(ulong guildId, string discoverySplashId) | |||||
| => discoverySplashId != null ? $"{DiscordConfig.CDNUrl}discovery-splashes/{guildId}/{discoverySplashId}.jpg" : null; | |||||
| /// <summary> | |||||
| /// Returns a channel icon URL. | /// Returns a channel icon URL. | ||||
| /// </summary> | /// </summary> | ||||
| /// <param name="channelId">The channel snowflake identifier.</param> | /// <param name="channelId">The channel snowflake identifier.</param> | ||||
| @@ -1,5 +1,6 @@ | |||||
| <Project Sdk="Microsoft.NET.Sdk"> | <Project Sdk="Microsoft.NET.Sdk"> | ||||
| <Import Project="../../Discord.Net.targets" /> | <Import Project="../../Discord.Net.targets" /> | ||||
| <Import Project="../../StyleAnalyzer.targets"/> | |||||
| <PropertyGroup> | <PropertyGroup> | ||||
| <AssemblyName>Discord.Net.Core</AssemblyName> | <AssemblyName>Discord.Net.Core</AssemblyName> | ||||
| <RootNamespace>Discord</RootNamespace> | <RootNamespace>Discord</RootNamespace> | ||||
| @@ -27,11 +27,12 @@ namespace Discord | |||||
| /// Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>. | /// Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>. | ||||
| /// If <c>null</c>, all mentioned roles and users will be notified. | /// If <c>null</c>, all mentioned roles and users will be notified. | ||||
| /// </param> | /// </param> | ||||
| /// <param name="messageReference">The message references to be included. Used to reply to specific messages.</param> | |||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents an asynchronous send operation for delivering the message. The task result | /// A task that represents an asynchronous send operation for delivering the message. The task result | ||||
| /// contains the sent message. | /// contains the sent message. | ||||
| /// </returns> | /// </returns> | ||||
| Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null); | |||||
| Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null); | |||||
| /// <summary> | /// <summary> | ||||
| /// Sends a file to this message channel with an optional caption. | /// Sends a file to this message channel with an optional caption. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -63,11 +64,12 @@ namespace Discord | |||||
| /// Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>. | /// Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>. | ||||
| /// If <c>null</c>, all mentioned roles and users will be notified. | /// If <c>null</c>, all mentioned roles and users will be notified. | ||||
| /// </param> | /// </param> | ||||
| /// <param name="messageReference">The message references to be included. Used to reply to specific messages.</param> | |||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents an asynchronous send operation for delivering the message. The task result | /// A task that represents an asynchronous send operation for delivering the message. The task result | ||||
| /// contains the sent message. | /// contains the sent message. | ||||
| /// </returns> | /// </returns> | ||||
| Task<IUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null); | |||||
| 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); | |||||
| /// <summary> | /// <summary> | ||||
| /// Sends a file to this message channel with an optional caption. | /// Sends a file to this message channel with an optional caption. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -96,11 +98,12 @@ namespace Discord | |||||
| /// Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>. | /// Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>. | ||||
| /// If <c>null</c>, all mentioned roles and users will be notified. | /// If <c>null</c>, all mentioned roles and users will be notified. | ||||
| /// </param> | /// </param> | ||||
| /// <param name="messageReference">The message references to be included. Used to reply to specific messages.</param> | |||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents an asynchronous send operation for delivering the message. The task result | /// A task that represents an asynchronous send operation for delivering the message. The task result | ||||
| /// contains the sent message. | /// contains the sent message. | ||||
| /// </returns> | /// </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); | |||||
| 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); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a message from this message channel. | /// Gets a message from this message channel. | ||||
| @@ -0,0 +1,9 @@ | |||||
| namespace Discord | |||||
| { | |||||
| /// <summary> | |||||
| /// Represents a generic news channel in a guild that can send and receive messages. | |||||
| /// </summary> | |||||
| public interface INewsChannel : ITextChannel | |||||
| { | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,22 @@ | |||||
| namespace Discord | |||||
| { | |||||
| /// <summary> | |||||
| /// Stores the gateway information related to the current bot. | |||||
| /// </summary> | |||||
| public class BotGateway | |||||
| { | |||||
| /// <summary> | |||||
| /// Gets the WSS URL that can be used for connecting to the gateway. | |||||
| /// </summary> | |||||
| public string Url { get; internal set; } | |||||
| /// <summary> | |||||
| /// Gets the recommended number of shards to use when connecting. | |||||
| /// </summary> | |||||
| public int Shards { get; internal set; } | |||||
| /// <summary> | |||||
| /// Gets the <see cref="SessionStartLimit"/> that contains the information | |||||
| /// about the current session start limit. | |||||
| /// </summary> | |||||
| public SessionStartLimit SessionStartLimit { get; internal set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,38 @@ | |||||
| namespace Discord | |||||
| { | |||||
| /// <summary> | |||||
| /// Stores the information related to the gateway identify request. | |||||
| /// </summary> | |||||
| public class SessionStartLimit | |||||
| { | |||||
| /// <summary> | |||||
| /// Gets the total number of session starts the current user is allowed. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// The maximum amount of session starts the current user is allowed. | |||||
| /// </returns> | |||||
| public int Total { get; internal set; } | |||||
| /// <summary> | |||||
| /// Gets the remaining number of session starts the current user is allowed. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// The remaining amount of session starts the current user is allowed. | |||||
| /// </returns> | |||||
| public int Remaining { get; internal set; } | |||||
| /// <summary> | |||||
| /// Gets the number of milliseconds after which the limit resets. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// The milliseconds until the limit resets back to the <see cref="Total"/>. | |||||
| /// </returns> | |||||
| public int ResetAfter { get; internal set; } | |||||
| /// <summary> | |||||
| /// Gets the maximum concurrent identify requests in a time window. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// The maximum concurrent identify requests in a time window, | |||||
| /// limited to the same rate limit key. | |||||
| /// </returns> | |||||
| public int MaxConcurrency { get; internal set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,21 @@ | |||||
| namespace Discord | |||||
| { | |||||
| /// <summary> | |||||
| /// Provides properties that are used to modify the widget of an <see cref="IGuild" /> with the specified changes. | |||||
| /// </summary> | |||||
| public class GuildWidgetProperties | |||||
| { | |||||
| /// <summary> | |||||
| /// Sets whether the widget should be enabled. | |||||
| /// </summary> | |||||
| public Optional<bool> Enabled { get; set; } | |||||
| /// <summary> | |||||
| /// Sets the channel that the invite should place its users in, if not <see langword="null" />. | |||||
| /// </summary> | |||||
| public Optional<IChannel> Channel { get; set; } | |||||
| /// <summary> | |||||
| /// Sets the channel that the invite should place its users in, if not <see langword="null" />. | |||||
| /// </summary> | |||||
| public Optional<ulong?> ChannelId { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -23,7 +23,7 @@ namespace Discord | |||||
| /// automatically moved to the AFK voice channel. | /// automatically moved to the AFK voice channel. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// An <see cref="int"/> representing the amount of time in seconds for a user to be marked as inactive | |||||
| /// An <see langword="int"/> representing the amount of time in seconds for a user to be marked as inactive | |||||
| /// and moved into the AFK voice channel. | /// and moved into the AFK voice channel. | ||||
| /// </returns> | /// </returns> | ||||
| int AFKTimeout { get; } | int AFKTimeout { get; } | ||||
| @@ -31,10 +31,17 @@ namespace Discord | |||||
| /// Gets a value that indicates whether this guild is embeddable (i.e. can use widget). | /// Gets a value that indicates whether this guild is embeddable (i.e. can use widget). | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// <c>true</c> if this guild can be embedded via widgets; otherwise <c>false</c>. | |||||
| /// <see langword="true" /> if this guild has a widget enabled; otherwise <see langword="false" />. | |||||
| /// </returns> | /// </returns> | ||||
| bool IsEmbeddable { get; } | bool IsEmbeddable { get; } | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets a value that indicates whether this guild has the widget enabled. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// <see langword="true" /> if this guild has a widget enabled; otherwise <see langword="false" />. | |||||
| /// </returns> | |||||
| bool IsWidgetEnabled { get; } | |||||
| /// <summary> | |||||
| /// Gets the default message notifications for users who haven't explicitly set their notification settings. | /// Gets the default message notifications for users who haven't explicitly set their notification settings. | ||||
| /// </summary> | /// </summary> | ||||
| DefaultMessageNotifications DefaultMessageNotifications { get; } | DefaultMessageNotifications DefaultMessageNotifications { get; } | ||||
| @@ -64,31 +71,45 @@ namespace Discord | |||||
| /// Gets the ID of this guild's icon. | /// Gets the ID of this guild's icon. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// An identifier for the splash image; <c>null</c> if none is set. | |||||
| /// An identifier for the splash image; <see langword="null" /> if none is set. | |||||
| /// </returns> | /// </returns> | ||||
| string IconId { get; } | string IconId { get; } | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets the URL of this guild's icon. | /// Gets the URL of this guild's icon. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// A URL pointing to the guild's icon; <c>null</c> if none is set. | |||||
| /// A URL pointing to the guild's icon; <see langword="null" /> if none is set. | |||||
| /// </returns> | /// </returns> | ||||
| string IconUrl { get; } | string IconUrl { get; } | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets the ID of this guild's splash image. | /// Gets the ID of this guild's splash image. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// An identifier for the splash image; <c>null</c> if none is set. | |||||
| /// An identifier for the splash image; <see langword="null" /> if none is set. | |||||
| /// </returns> | /// </returns> | ||||
| string SplashId { get; } | string SplashId { get; } | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets the URL of this guild's splash image. | /// Gets the URL of this guild's splash image. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// A URL pointing to the guild's splash image; <c>null</c> if none is set. | |||||
| /// A URL pointing to the guild's splash image; <see langword="null" /> if none is set. | |||||
| /// </returns> | /// </returns> | ||||
| string SplashUrl { get; } | string SplashUrl { get; } | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets the ID of this guild's discovery splash image. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// An identifier for the discovery splash image; <see langword="null" /> if none is set. | |||||
| /// </returns> | |||||
| string DiscoverySplashId { get; } | |||||
| /// <summary> | |||||
| /// Gets the URL of this guild's discovery splash image. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// A URL pointing to the guild's discovery splash image; <see langword="null" /> if none is set. | |||||
| /// </returns> | |||||
| string DiscoverySplashUrl { get; } | |||||
| /// <summary> | |||||
| /// Determines if this guild is currently connected and ready to be used. | /// Determines if this guild is currently connected and ready to be used. | ||||
| /// </summary> | /// </summary> | ||||
| /// <remarks> | /// <remarks> | ||||
| @@ -98,7 +119,7 @@ namespace Discord | |||||
| /// This boolean is used to determine if the guild is currently connected to the WebSocket and is ready to be used/accessed. | /// This boolean is used to determine if the guild is currently connected to the WebSocket and is ready to be used/accessed. | ||||
| /// </remarks> | /// </remarks> | ||||
| /// <returns> | /// <returns> | ||||
| /// <c>true</c> if this guild is currently connected and ready to be used; otherwise <c>false</c>. | |||||
| /// <c>true</c> if this guild is currently connected and ready to be used; otherwise <see langword="false"/>. | |||||
| /// </returns> | /// </returns> | ||||
| bool Available { get; } | bool Available { get; } | ||||
| @@ -106,7 +127,7 @@ namespace Discord | |||||
| /// Gets the ID of the AFK voice channel for this guild. | /// Gets the ID of the AFK voice channel for this guild. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// A <see cref="ulong"/> representing the snowflake identifier of the AFK voice channel; <c>null</c> if | |||||
| /// A <see langword="ulong"/> representing the snowflake identifier of the AFK voice channel; <see langword="null" /> if | |||||
| /// none is set. | /// none is set. | ||||
| /// </returns> | /// </returns> | ||||
| ulong? AFKChannelId { get; } | ulong? AFKChannelId { get; } | ||||
| @@ -121,7 +142,7 @@ namespace Discord | |||||
| /// </note> | /// </note> | ||||
| /// </remarks> | /// </remarks> | ||||
| /// <returns> | /// <returns> | ||||
| /// A <see cref="ulong"/> representing the snowflake identifier of the default text channel; <c>0</c> if | |||||
| /// A <see langword="ulong"/> representing the snowflake identifier of the default text channel; <c>0</c> if | |||||
| /// none can be found. | /// none can be found. | ||||
| /// </returns> | /// </returns> | ||||
| ulong DefaultChannelId { get; } | ulong DefaultChannelId { get; } | ||||
| @@ -129,30 +150,54 @@ namespace Discord | |||||
| /// Gets the ID of the widget embed channel of this guild. | /// Gets the ID of the widget embed channel of this guild. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// A <see cref="ulong"/> representing the snowflake identifier of the embedded channel found within the | |||||
| /// widget settings of this guild; <c>null</c> if none is set. | |||||
| /// A <see langword="ulong"/> representing the snowflake identifier of the embedded channel found within the | |||||
| /// widget settings of this guild; <see langword="null" /> if none is set. | |||||
| /// </returns> | /// </returns> | ||||
| ulong? EmbedChannelId { get; } | ulong? EmbedChannelId { get; } | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets the ID of the channel assigned to the widget of this guild. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// A <see langword="ulong"/> representing the snowflake identifier of the channel assigned to the widget found | |||||
| /// within the widget settings of this guild; <see langword="null" /> if none is set. | |||||
| /// </returns> | |||||
| ulong? WidgetChannelId { get; } | |||||
| /// <summary> | |||||
| /// Gets the ID of the channel where randomized welcome messages are sent. | /// Gets the ID of the channel where randomized welcome messages are sent. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// A <see cref="ulong"/> representing the snowflake identifier of the system channel where randomized | |||||
| /// welcome messages are sent; <c>null</c> if none is set. | |||||
| /// A <see langword="ulong"/> representing the snowflake identifier of the system channel where randomized | |||||
| /// welcome messages are sent; <see langword="null" /> if none is set. | |||||
| /// </returns> | /// </returns> | ||||
| ulong? SystemChannelId { get; } | ulong? SystemChannelId { get; } | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets the ID of the channel with the rules. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// A <see langword="ulong"/> representing the snowflake identifier of the channel that contains the rules; | |||||
| /// <see langword="null" /> if none is set. | |||||
| /// </returns> | |||||
| ulong? RulesChannelId { get; } | |||||
| /// <summary> | |||||
| /// Gets the ID of the channel where admins and moderators of Community guilds receive notices from Discord. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// A <see langword="ulong"/> representing the snowflake identifier of the channel where admins and moderators | |||||
| /// of Community guilds receive notices from Discord; <see langword="null" /> if none is set. | |||||
| /// </returns> | |||||
| ulong? PublicUpdatesChannelId { get; } | |||||
| /// <summary> | |||||
| /// Gets the ID of the user that owns this guild. | /// Gets the ID of the user that owns this guild. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// A <see cref="ulong"/> representing the snowflake identifier of the user that owns this guild. | |||||
| /// A <see langword="ulong"/> representing the snowflake identifier of the user that owns this guild. | |||||
| /// </returns> | /// </returns> | ||||
| ulong OwnerId { get; } | ulong OwnerId { get; } | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets the application ID of the guild creator if it is bot-created. | /// Gets the application ID of the guild creator if it is bot-created. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// A <see cref="ulong"/> representing the snowflake identifier of the application ID that created this guild, or <c>null</c> if it was not bot-created. | |||||
| /// A <see langword="ulong"/> representing the snowflake identifier of the application ID that created this guild, or <see langword="null" /> if it was not bot-created. | |||||
| /// </returns> | /// </returns> | ||||
| ulong? ApplicationId { get; } | ulong? ApplicationId { get; } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -208,21 +253,21 @@ namespace Discord | |||||
| /// Gets the identifier for this guilds banner image. | /// Gets the identifier for this guilds banner image. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// An identifier for the banner image; <c>null</c> if none is set. | |||||
| /// An identifier for the banner image; <see langword="null" /> if none is set. | |||||
| /// </returns> | /// </returns> | ||||
| string BannerId { get; } | string BannerId { get; } | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets the URL of this guild's banner image. | /// Gets the URL of this guild's banner image. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// A URL pointing to the guild's banner image; <c>null</c> if none is set. | |||||
| /// A URL pointing to the guild's banner image; <see langword="null" /> if none is set. | |||||
| /// </returns> | /// </returns> | ||||
| string BannerUrl { get; } | string BannerUrl { get; } | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets the code for this guild's vanity invite URL. | /// Gets the code for this guild's vanity invite URL. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// A string containing the vanity invite code for this guild; <c>null</c> if none is set. | |||||
| /// A string containing the vanity invite code for this guild; <see langword="null" /> if none is set. | |||||
| /// </returns> | /// </returns> | ||||
| string VanityURLCode { get; } | string VanityURLCode { get; } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -236,7 +281,7 @@ namespace Discord | |||||
| /// Gets the description for the guild. | /// Gets the description for the guild. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// The description for the guild; <c>null</c> if none is set. | |||||
| /// The description for the guild; <see langword="null" /> if none is set. | |||||
| /// </returns> | /// </returns> | ||||
| string Description { get; } | string Description { get; } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -246,9 +291,50 @@ namespace Discord | |||||
| /// This is the number of users who have boosted this guild. | /// This is the number of users who have boosted this guild. | ||||
| /// </remarks> | /// </remarks> | ||||
| /// <returns> | /// <returns> | ||||
| /// The number of premium subscribers of this guild. | |||||
| /// The number of premium subscribers of this guild; <see langword="null" /> if not available. | |||||
| /// </returns> | /// </returns> | ||||
| int PremiumSubscriptionCount { get; } | int PremiumSubscriptionCount { get; } | ||||
| /// <summary> | |||||
| /// Gets the maximum number of presences for the guild. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// The maximum number of presences for the guild. | |||||
| /// </returns> | |||||
| int? MaxPresences { get; } | |||||
| /// <summary> | |||||
| /// Gets the maximum number of members for the guild. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// The maximum number of members for the guild. | |||||
| /// </returns> | |||||
| int? MaxMembers { get; } | |||||
| /// <summary> | |||||
| /// Gets the maximum amount of users in a video channel. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// The maximum amount of users in a video channel. | |||||
| /// </returns> | |||||
| int? MaxVideoChannelUsers { get; } | |||||
| /// <summary> | |||||
| /// Gets the approximate number of members in this guild. | |||||
| /// </summary> | |||||
| /// <remarks> | |||||
| /// Only available when getting a guild via REST when `with_counts` is true. | |||||
| /// </remarks> | |||||
| /// <returns> | |||||
| /// The approximate number of members in this guild. | |||||
| /// </returns> | |||||
| int? ApproximateMemberCount { get; } | |||||
| /// <summary> | |||||
| /// Gets the approximate number of non-offline members in this guild. | |||||
| /// </summary> | |||||
| /// <remarks> | |||||
| /// Only available when getting a guild via REST when `with_counts` is true. | |||||
| /// </remarks> | |||||
| /// <returns> | |||||
| /// The approximate number of non-offline members in this guild. | |||||
| /// </returns> | |||||
| int? ApproximatePresenceCount { get; } | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the preferred locale of this guild in IETF BCP 47 | /// Gets the preferred locale of this guild in IETF BCP 47 | ||||
| @@ -285,8 +371,18 @@ namespace Discord | |||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous modification operation. | /// A task that represents the asynchronous modification operation. | ||||
| /// </returns> | /// </returns> | ||||
| [Obsolete("This endpoint is deprecated, use ModifyWidgetAsync instead.")] | |||||
| Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null); | Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null); | ||||
| /// <summary> | /// <summary> | ||||
| /// Modifies this guild's widget. | |||||
| /// </summary> | |||||
| /// <param name="func">The delegate containing the properties to modify the guild widget with.</param> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A task that represents the asynchronous modification operation. | |||||
| /// </returns> | |||||
| Task ModifyWidgetAsync(Action<GuildWidgetProperties> func, RequestOptions options = null); | |||||
| /// <summary> | |||||
| /// Bulk-modifies the order of channels in this guild. | /// Bulk-modifies the order of channels in this guild. | ||||
| /// </summary> | /// </summary> | ||||
| /// <param name="args">The properties used to modify the channel positions with.</param> | /// <param name="args">The properties used to modify the channel positions with.</param> | ||||
| @@ -336,7 +432,7 @@ namespace Discord | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains a ban object, which | /// A task that represents the asynchronous get operation. The task result contains a ban object, which | ||||
| /// contains the user information and the reason for the ban; <c>null</c> if the ban entry cannot be found. | |||||
| /// contains the user information and the reason for the ban; <see langword="null" /> if the ban entry cannot be found. | |||||
| /// </returns> | /// </returns> | ||||
| Task<IBan> GetBanAsync(IUser user, RequestOptions options = null); | Task<IBan> GetBanAsync(IUser user, RequestOptions options = null); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -346,7 +442,7 @@ namespace Discord | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains a ban object, which | /// A task that represents the asynchronous get operation. The task result contains a ban object, which | ||||
| /// contains the user information and the reason for the ban; <c>null</c> if the ban entry cannot be found. | |||||
| /// contains the user information and the reason for the ban; <see langword="null" /> if the ban entry cannot be found. | |||||
| /// </returns> | /// </returns> | ||||
| Task<IBan> GetBanAsync(ulong userId, RequestOptions options = null); | Task<IBan> GetBanAsync(ulong userId, RequestOptions options = null); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -410,7 +506,7 @@ namespace Discord | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the generic channel | /// A task that represents the asynchronous get operation. The task result contains the generic channel | ||||
| /// associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
| /// associated with the specified <paramref name="id"/>; <see langword="null" /> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| Task<IGuildChannel> GetChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IGuildChannel> GetChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -431,7 +527,7 @@ namespace Discord | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the text channel | /// A task that represents the asynchronous get operation. The task result contains the text channel | ||||
| /// associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
| /// associated with the specified <paramref name="id"/>; <see langword="null" /> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| Task<ITextChannel> GetTextChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<ITextChannel> GetTextChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -462,7 +558,7 @@ namespace Discord | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the voice channel associated | /// A task that represents the asynchronous get operation. The task result contains the voice channel associated | ||||
| /// with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
| /// with the specified <paramref name="id"/>; <see langword="null" /> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| Task<IVoiceChannel> GetVoiceChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IVoiceChannel> GetVoiceChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -472,7 +568,7 @@ namespace Discord | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the voice channel that the | /// A task that represents the asynchronous get operation. The task result contains the voice channel that the | ||||
| /// AFK users will be moved to after they have idled for too long; <c>null</c> if none is set. | |||||
| /// AFK users will be moved to after they have idled for too long; <see langword="null" /> if none is set. | |||||
| /// </returns> | /// </returns> | ||||
| Task<IVoiceChannel> GetAFKChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IVoiceChannel> GetAFKChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -482,7 +578,7 @@ namespace Discord | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the text channel where | /// A task that represents the asynchronous get operation. The task result contains the text channel where | ||||
| /// randomized welcome messages will be sent to; <c>null</c> if none is set. | |||||
| /// randomized welcome messages will be sent to; <see langword="null" /> if none is set. | |||||
| /// </returns> | /// </returns> | ||||
| Task<ITextChannel> GetSystemChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<ITextChannel> GetSystemChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -492,7 +588,7 @@ namespace Discord | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the first viewable text | /// A task that represents the asynchronous get operation. The task result contains the first viewable text | ||||
| /// channel in this guild; <c>null</c> if none is found. | |||||
| /// channel in this guild; <see langword="null" /> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| Task<ITextChannel> GetDefaultChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<ITextChannel> GetDefaultChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -502,9 +598,40 @@ namespace Discord | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the embed channel set | /// A task that represents the asynchronous get operation. The task result contains the embed channel set | ||||
| /// within the server's widget settings; <c>null</c> if none is set. | |||||
| /// within the server's widget settings; <see langword="null" /> if none is set. | |||||
| /// </returns> | /// </returns> | ||||
| [Obsolete("This endpoint is deprecated, use GetWidgetChannelAsync instead.")] | |||||
| Task<IGuildChannel> GetEmbedChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IGuildChannel> GetEmbedChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
| /// <summary> | |||||
| /// Gets the widget channel (i.e. the channel set in the guild's widget settings) in this guild. | |||||
| /// </summary> | |||||
| /// <param name="mode">The <see cref="CacheMode" /> that determines whether the object should be fetched from cache.</param> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A task that represents the asynchronous get operation. The task result contains the widget channel set | |||||
| /// within the server's widget settings; <see langword="null" /> if none is set. | |||||
| /// </returns> | |||||
| Task<IGuildChannel> GetWidgetChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||||
| /// <summary> | |||||
| /// Gets the text channel where Community guilds can display rules and/or guidelines. | |||||
| /// </summary> | |||||
| /// <param name="mode">The <see cref="CacheMode"/> that determines whether the object should be fetched from cache.</param> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A task that represents the asynchronous get operation. The task result contains the text channel | |||||
| /// where Community guilds can display rules and/or guidelines; <see langword="null" /> if none is set. | |||||
| /// </returns> | |||||
| Task<ITextChannel> GetRulesChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||||
| /// <summary> | |||||
| /// Gets the text channel channel where admins and moderators of Community guilds receive notices from Discord. | |||||
| /// </summary> | |||||
| /// <param name="mode">The <see cref="CacheMode"/> that determines whether the object should be fetched from cache.</param> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A task that represents the asynchronous get operation. The task result contains the text channel channel where | |||||
| /// admins and moderators of Community guilds receive notices from Discord; <see langword="null" /> if none is set. | |||||
| /// </returns> | |||||
| Task<ITextChannel> GetPublicUpdatesChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||||
| /// <summary> | /// <summary> | ||||
| /// Creates a new text channel in this guild. | /// Creates a new text channel in this guild. | ||||
| @@ -573,7 +700,7 @@ namespace Discord | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the partial metadata of | /// A task that represents the asynchronous get operation. The task result contains the partial metadata of | ||||
| /// the vanity invite found within this guild; <c>null</c> if none is found. | |||||
| /// the vanity invite found within this guild; <see langword="null" /> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| Task<IInviteMetadata> GetVanityInviteAsync(RequestOptions options = null); | Task<IInviteMetadata> GetVanityInviteAsync(RequestOptions options = null); | ||||
| @@ -582,7 +709,7 @@ namespace Discord | |||||
| /// </summary> | /// </summary> | ||||
| /// <param name="id">The snowflake identifier for the role.</param> | /// <param name="id">The snowflake identifier for the role.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A role that is associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
| /// A role that is associated with the specified <paramref name="id"/>; <see langword="null" /> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| IRole GetRole(ulong id); | IRole GetRole(ulong id); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -624,7 +751,7 @@ namespace Discord | |||||
| /// <param name="accessToken">The OAuth2 access token for the user, requested with the guilds.join scope.</param> | /// <param name="accessToken">The OAuth2 access token for the user, requested with the guilds.join scope.</param> | ||||
| /// <param name="func">The delegate containing the properties to be applied to the user upon being added to the guild.</param> | /// <param name="func">The delegate containing the properties to be applied to the user upon being added to the guild.</param> | ||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns>A guild user associated with the specified <paramref name="userId" />; <c>null</c> if the user is already in the guild.</returns> | |||||
| /// <returns>A guild user associated with the specified <paramref name="userId" />; <see langword="null" /> if the user is already in the guild.</returns> | |||||
| Task<IGuildUser> AddGuildUserAsync(ulong userId, string accessToken, Action<AddGuildUserProperties> func = null, RequestOptions options = null); | Task<IGuildUser> AddGuildUserAsync(ulong userId, string accessToken, Action<AddGuildUserProperties> func = null, RequestOptions options = null); | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of all users in this guild. | /// Gets a collection of all users in this guild. | ||||
| @@ -649,7 +776,7 @@ namespace Discord | |||||
| /// <remarks> | /// <remarks> | ||||
| /// This method retrieves a user found within this guild. | /// This method retrieves a user found within this guild. | ||||
| /// <note> | /// <note> | ||||
| /// This may return <c>null</c> in the WebSocket implementation due to incomplete user collection in | |||||
| /// This may return <see langword="null" /> in the WebSocket implementation due to incomplete user collection in | |||||
| /// large guilds. | /// large guilds. | ||||
| /// </note> | /// </note> | ||||
| /// </remarks> | /// </remarks> | ||||
| @@ -658,7 +785,7 @@ namespace Discord | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the guild user | /// A task that represents the asynchronous get operation. The task result contains the guild user | ||||
| /// associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
| /// associated with the specified <paramref name="id"/>; <see langword="null" /> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| Task<IGuildUser> GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IGuildUser> GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -705,11 +832,12 @@ namespace Discord | |||||
| /// <param name="days">The number of days required for the users to be kicked.</param> | /// <param name="days">The number of days required for the users to be kicked.</param> | ||||
| /// <param name="simulate">Whether this prune action is a simulation.</param> | /// <param name="simulate">Whether this prune action is a simulation.</param> | ||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <param name="includeRoleIds">An array of role IDs to be included in the prune of users who do not have any additional roles.</param> | |||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous prune operation. The task result contains the number of users to | /// A task that represents the asynchronous prune operation. The task result contains the number of users to | ||||
| /// be or has been removed from this guild. | /// be or has been removed from this guild. | ||||
| /// </returns> | /// </returns> | ||||
| Task<int> PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null); | |||||
| Task<int> PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null, IEnumerable<ulong> includeRoleIds = null); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of users in this guild that the name or nickname starts with the | /// Gets a collection of users in this guild that the name or nickname starts with the | ||||
| /// provided <see cref="string"/> at <paramref name="query"/>. | /// provided <see cref="string"/> at <paramref name="query"/>. | ||||
| @@ -751,7 +879,7 @@ namespace Discord | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the webhook with the | /// A task that represents the asynchronous get operation. The task result contains the webhook with the | ||||
| /// specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
| /// specified <paramref name="id"/>; <see langword="null" /> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| Task<IWebhook> GetWebhookAsync(ulong id, RequestOptions options = null); | Task<IWebhook> GetWebhookAsync(ulong id, RequestOptions options = null); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -771,7 +899,7 @@ namespace Discord | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the emote found with the | /// A task that represents the asynchronous get operation. The task result contains the emote found with the | ||||
| /// specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
| /// specified <paramref name="id"/>; <see langword="null" /> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| Task<GuildEmote> GetEmoteAsync(ulong id, RequestOptions options = null); | Task<GuildEmote> GetEmoteAsync(ulong id, RequestOptions options = null); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -22,6 +22,18 @@ namespace Discord | |||||
| /// Gets the icon URL of the application. | /// Gets the icon URL of the application. | ||||
| /// </summary> | /// </summary> | ||||
| string IconUrl { get; } | string IconUrl { get; } | ||||
| /// <summary> | |||||
| /// Gets if the bot is public. | |||||
| /// </summary> | |||||
| bool IsBotPublic { get; } | |||||
| /// <summary> | |||||
| /// Gets if the bot requires code grant. | |||||
| /// </summary> | |||||
| bool BotRequiresCodeGrant { get; } | |||||
| /// <summary> | |||||
| /// Gets the team associated with this application if there is one. | |||||
| /// </summary> | |||||
| ITeam Team { get; } | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the partial user object containing info on the owner of the application. | /// Gets the partial user object containing info on the owner of the application. | ||||
| @@ -10,6 +10,7 @@ namespace Discord | |||||
| /// <summary> | /// <summary> | ||||
| /// Updates this object's properties with its current state. | /// Updates this object's properties with its current state. | ||||
| /// </summary> | /// </summary> | ||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| Task UpdateAsync(RequestOptions options = null); | Task UpdateAsync(RequestOptions options = null); | ||||
| } | } | ||||
| } | } | ||||
| @@ -20,6 +20,13 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| string Url { get; } | string Url { get; } | ||||
| /// <summary> | |||||
| /// Gets the user that created this invite. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// A user that created this invite. | |||||
| /// </returns> | |||||
| IUser Inviter { get; } | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the channel this invite is linked to. | /// Gets the channel this invite is linked to. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -83,5 +90,19 @@ namespace Discord | |||||
| /// invite points to; <c>null</c> if one cannot be obtained. | /// invite points to; <c>null</c> if one cannot be obtained. | ||||
| /// </returns> | /// </returns> | ||||
| int? MemberCount { get; } | int? MemberCount { get; } | ||||
| /// <summary> | |||||
| /// Gets the user this invite is linked to via <see cref="TargetUserType"/>. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// A user that is linked to this invite. | |||||
| /// </returns> | |||||
| IUser TargetUser { get; } | |||||
| /// <summary> | |||||
| /// Gets the type of the linked <see cref="TargetUser"/> for this invite. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// The type of the linked user that is linked to this invite. | |||||
| /// </returns> | |||||
| TargetUserType TargetUserType { get; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -8,28 +8,22 @@ namespace Discord | |||||
| public interface IInviteMetadata : IInvite | public interface IInviteMetadata : IInvite | ||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets the user that created this invite. | |||||
| /// Gets a value that indicates whether the invite is a temporary one. | |||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// A user that created this invite. | |||||
| /// <c>true</c> if users accepting this invite will be removed from the guild when they log off; otherwise | |||||
| /// <c>false</c>. | |||||
| /// </returns> | /// </returns> | ||||
| IUser Inviter { get; } | |||||
| bool IsTemporary { get; } | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a value that indicates whether the invite has been revoked. | /// Gets a value that indicates whether the invite has been revoked. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// <c>true</c> if this invite was revoked; otherwise <c>false</c>. | /// <c>true</c> if this invite was revoked; otherwise <c>false</c>. | ||||
| /// </returns> | /// </returns> | ||||
| [Obsolete("This property doesn't exist anymore and shouldn't be used.")] | |||||
| bool IsRevoked { get; } | bool IsRevoked { get; } | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets a value that indicates whether the invite is a temporary one. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// <c>true</c> if users accepting this invite will be removed from the guild when they log off; otherwise | |||||
| /// <c>false</c>. | |||||
| /// </returns> | |||||
| bool IsTemporary { get; } | |||||
| /// <summary> | |||||
| /// Gets the time (in seconds) until the invite expires. | /// Gets the time (in seconds) until the invite expires. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| @@ -0,0 +1,14 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public enum TargetUserType | |||||
| { | |||||
| /// <summary> | |||||
| /// The invite whose target user type is not defined. | |||||
| /// </summary> | |||||
| Undefined = 0, | |||||
| /// <summary> | |||||
| /// The invite is for a Go Live stream. | |||||
| /// </summary> | |||||
| Stream = 1 | |||||
| } | |||||
| } | |||||
| @@ -49,6 +49,14 @@ namespace Discord | |||||
| /// </summary> | /// </summary> | ||||
| public List<ulong> UserIds { get; set; } = new List<ulong>(); | public List<ulong> UserIds { get; set; } = new List<ulong>(); | ||||
| /// <summary> | |||||
| /// Gets or sets whether to mention the author of the message you are replying to or not. | |||||
| /// </summary> | |||||
| /// <remarks> | |||||
| /// Specifically for inline replies. | |||||
| /// </remarks> | |||||
| public bool? MentionRepliedUser { get; set; } = null; | |||||
| /// <summary> | /// <summary> | ||||
| /// Initializes a new instance of the <see cref="AllowedMentions"/> class. | /// Initializes a new instance of the <see cref="AllowedMentions"/> class. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -92,10 +92,10 @@ namespace Discord | |||||
| /// Gets all embeds included in this message. | /// Gets all embeds included in this message. | ||||
| /// </summary> | /// </summary> | ||||
| /// <remarks> | /// <remarks> | ||||
| /// </remarks> | |||||
| /// This property gets a read-only collection of embeds associated with this message. Depending on the | /// This property gets a read-only collection of embeds associated with this message. Depending on the | ||||
| /// message, a sent message may contain one or more embeds. This is usually true when multiple link previews | /// message, a sent message may contain one or more embeds. This is usually true when multiple link previews | ||||
| /// are generated; however, only one <see cref="EmbedType.Rich"/> <see cref="Embed"/> can be featured. | /// are generated; however, only one <see cref="EmbedType.Rich"/> <see cref="Embed"/> can be featured. | ||||
| /// </remarks> | |||||
| /// <returns> | /// <returns> | ||||
| /// A read-only collection of embed objects. | /// A read-only collection of embed objects. | ||||
| /// </returns> | /// </returns> | ||||
| @@ -148,11 +148,11 @@ namespace Discord | |||||
| MessageApplication Application { get; } | MessageApplication Application { get; } | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets the reference to the original message if it was crossposted. | |||||
| /// Gets the reference to the original message if it is a crosspost, channel follow add, pin, or reply message. | |||||
| /// </summary> | /// </summary> | ||||
| /// <remarks> | /// <remarks> | ||||
| /// Sent with Cross-posted messages, meaning they were published from news channels | |||||
| /// and received by subscriber channels. | |||||
| /// Sent with cross-posted messages, meaning they were published from news channels | |||||
| /// and received by subscriber channels, channel follow adds, pins, and message replies. | |||||
| /// </remarks> | /// </remarks> | ||||
| /// <returns> | /// <returns> | ||||
| /// A message's reference, if any is associated. | /// A message's reference, if any is associated. | ||||
| @@ -164,6 +164,17 @@ namespace Discord | |||||
| /// </summary> | /// </summary> | ||||
| IReadOnlyDictionary<IEmote, ReactionMetadata> Reactions { get; } | IReadOnlyDictionary<IEmote, ReactionMetadata> Reactions { get; } | ||||
| /// <summary> | |||||
| /// Gets the flags related to this message. | |||||
| /// </summary> | |||||
| /// <remarks> | |||||
| /// This value is determined by bitwise OR-ing <see cref="MessageFlags"/> values together. | |||||
| /// </remarks> | |||||
| /// <returns> | |||||
| /// A message's flags, if any is associated. | |||||
| /// </returns> | |||||
| MessageFlags? Flags { get; } | |||||
| /// <summary> | /// <summary> | ||||
| /// Adds a reaction to this message. | /// Adds a reaction to this message. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -1,5 +1,4 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
| namespace Discord | namespace Discord | ||||
| @@ -9,6 +8,14 @@ namespace Discord | |||||
| /// </summary> | /// </summary> | ||||
| public interface IUserMessage : IMessage | public interface IUserMessage : IMessage | ||||
| { | { | ||||
| /// <summary> | |||||
| /// Gets the referenced message if it is a crosspost, channel follow add, pin, or reply message. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// The referenced message, if any is associated and still exists. | |||||
| /// </returns> | |||||
| IUserMessage ReferencedMessage { get; } | |||||
| /// <summary> | /// <summary> | ||||
| /// Modifies this message. | /// Modifies this message. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -0,0 +1,36 @@ | |||||
| using System; | |||||
| namespace Discord | |||||
| { | |||||
| [Flags] | |||||
| public enum MessageFlags | |||||
| { | |||||
| /// <summary> | |||||
| /// Default value for flags, when none are given to a message. | |||||
| /// </summary> | |||||
| None = 0, | |||||
| /// <summary> | |||||
| /// Flag given to messages that have been published to subscribed | |||||
| /// channels (via Channel Following). | |||||
| /// </summary> | |||||
| Crossposted = 1 << 0, | |||||
| /// <summary> | |||||
| /// Flag given to messages that originated from a message in another | |||||
| /// channel (via Channel Following). | |||||
| /// </summary> | |||||
| IsCrosspost = 1 << 1, | |||||
| /// <summary> | |||||
| /// Flag given to messages that do not display any embeds. | |||||
| /// </summary> | |||||
| SuppressEmbeds = 1 << 2, | |||||
| /// <summary> | |||||
| /// Flag given to messages that the source message for this crosspost | |||||
| /// has been deleted (via Channel Following). | |||||
| /// </summary> | |||||
| SourceMessageDeleted = 1 << 3, | |||||
| /// <summary> | |||||
| /// Flag given to messages that came from the urgent message system. | |||||
| /// </summary> | |||||
| Urgent = 1 << 4, | |||||
| } | |||||
| } | |||||
| @@ -21,5 +21,17 @@ namespace Discord | |||||
| /// Gets or sets the embed the message should display. | /// Gets or sets the embed the message should display. | ||||
| /// </summary> | /// </summary> | ||||
| public Optional<Embed> Embed { get; set; } | public Optional<Embed> Embed { get; set; } | ||||
| /// <summary> | |||||
| /// Gets or sets the flags of the message. | |||||
| /// </summary> | |||||
| /// <remarks> | |||||
| /// Only <see cref="MessageFlags.SuppressEmbeds"/> can be set/unset and you need to be | |||||
| /// the author of the message. | |||||
| /// </remarks> | |||||
| public Optional<MessageFlags?> Flags { get; set; } | |||||
| /// <summary> | |||||
| /// Gets or sets the allowed mentions of the message. | |||||
| /// </summary> | |||||
| public Optional<AllowedMentions> AllowedMentions { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -3,7 +3,7 @@ using System.Diagnostics; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// Contains the IDs sent from a crossposted message. | |||||
| /// Contains the IDs sent from a crossposted message or inline reply. | |||||
| /// </summary> | /// </summary> | ||||
| [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
| public class MessageReference | public class MessageReference | ||||
| @@ -16,13 +16,36 @@ namespace Discord | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the Channel ID of the original message. | /// Gets the Channel ID of the original message. | ||||
| /// </summary> | /// </summary> | ||||
| public ulong ChannelId { get; internal set; } | |||||
| /// <remarks> | |||||
| /// It only will be the default value (zero) if it was instantiated with a <see langword="null"/> in the constructor. | |||||
| /// </remarks> | |||||
| public ulong ChannelId { get => InternalChannelId.GetValueOrDefault(); } | |||||
| internal Optional<ulong> InternalChannelId; | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the Guild ID of the original message. | /// Gets the Guild ID of the original message. | ||||
| /// </summary> | /// </summary> | ||||
| public Optional<ulong> GuildId { get; internal set; } | public Optional<ulong> GuildId { get; internal set; } | ||||
| /// <summary> | |||||
| /// Initializes a new instance of the <see cref="MessageReference"/> class. | |||||
| /// </summary> | |||||
| /// <param name="messageId"> | |||||
| /// The ID of the message that will be referenced. Used to reply to specific messages and the only parameter required for it. | |||||
| /// </param> | |||||
| /// <param name="channelId"> | |||||
| /// The ID of the channel that will be referenced. It will be validated if sent. | |||||
| /// </param> | |||||
| /// <param name="guildId"> | |||||
| /// The ID of the guild that will be referenced. It will be validated if sent. | |||||
| /// </param> | |||||
| public MessageReference(ulong? messageId = null, ulong? channelId = null, ulong? guildId = null) | |||||
| { | |||||
| MessageId = messageId ?? Optional.Create<ulong>(); | |||||
| InternalChannelId = channelId ?? Optional.Create<ulong>(); | |||||
| GuildId = guildId ?? Optional.Create<ulong>(); | |||||
| } | |||||
| private string DebuggerDisplay | private string DebuggerDisplay | ||||
| => $"Channel ID: ({ChannelId}){(GuildId.IsSpecified ? $", Guild ID: ({GuildId.Value})" : "")}" + | => $"Channel ID: ({ChannelId}){(GuildId.IsSpecified ? $", Guild ID: ({GuildId.Value})" : "")}" + | ||||
| $"{(MessageId.IsSpecified ? $", Message ID: ({MessageId.Value})" : "")}"; | $"{(MessageId.IsSpecified ? $", Message ID: ({MessageId.Value})" : "")}"; | ||||
| @@ -57,5 +57,12 @@ namespace Discord | |||||
| /// The message for when a news channel subscription is added to a text channel. | /// The message for when a news channel subscription is added to a text channel. | ||||
| /// </summary> | /// </summary> | ||||
| ChannelFollowAdd = 12, | ChannelFollowAdd = 12, | ||||
| /// <summary> | |||||
| /// The message is an inline reply. | |||||
| /// </summary> | |||||
| /// <remarks> | |||||
| /// Only available in API v8. | |||||
| /// </remarks> | |||||
| Reply = 19, | |||||
| } | } | ||||
| } | } | ||||
| @@ -17,7 +17,7 @@ namespace Discord | |||||
| /// <summary> Gets a <see cref="ChannelPermissions"/> that grants all permissions for category channels. </summary> | /// <summary> Gets a <see cref="ChannelPermissions"/> that grants all permissions for category channels. </summary> | ||||
| public static readonly ChannelPermissions Category = new ChannelPermissions(0b01100_1111110_1111111110001_010001); | public static readonly ChannelPermissions Category = new ChannelPermissions(0b01100_1111110_1111111110001_010001); | ||||
| /// <summary> Gets a <see cref="ChannelPermissions"/> that grants all permissions for direct message channels. </summary> | /// <summary> Gets a <see cref="ChannelPermissions"/> that grants all permissions for direct message channels. </summary> | ||||
| public static readonly ChannelPermissions DM = new ChannelPermissions(0b00000_1000110_1011100110000_000000); | |||||
| public static readonly ChannelPermissions DM = new ChannelPermissions(0b00000_1000110_1011100110001_000000); | |||||
| /// <summary> Gets a <see cref="ChannelPermissions"/> that grants all permissions for group channels. </summary> | /// <summary> Gets a <see cref="ChannelPermissions"/> that grants all permissions for group channels. </summary> | ||||
| public static readonly ChannelPermissions Group = new ChannelPermissions(0b00000_1000110_0001101100000_000000); | public static readonly ChannelPermissions Group = new ChannelPermissions(0b00000_1000110_0001101100000_000000); | ||||
| /// <summary> Gets a <see cref="ChannelPermissions"/> that grants all permissions for a given channel type. </summary> | /// <summary> Gets a <see cref="ChannelPermissions"/> that grants all permissions for a given channel type. </summary> | ||||
| @@ -51,6 +51,10 @@ namespace Discord | |||||
| /// authentication when used on a guild that has server-wide 2FA enabled. | /// authentication when used on a guild that has server-wide 2FA enabled. | ||||
| /// </remarks> | /// </remarks> | ||||
| ManageGuild = 0x00_00_00_20, | ManageGuild = 0x00_00_00_20, | ||||
| /// <summary> | |||||
| /// Allows for viewing of guild insights | |||||
| /// </summary> | |||||
| ViewGuildInsights = 0x00_08_00_00, | |||||
| // Text | // Text | ||||
| /// <summary> | /// <summary> | ||||
| @@ -12,7 +12,7 @@ namespace Discord | |||||
| /// <summary> Gets a <see cref="GuildPermissions"/> that grants all guild permissions for webhook users. </summary> | /// <summary> Gets a <see cref="GuildPermissions"/> that grants all guild permissions for webhook users. </summary> | ||||
| public static readonly GuildPermissions Webhook = new GuildPermissions(0b00000_0000000_0001101100000_000000); | public static readonly GuildPermissions Webhook = new GuildPermissions(0b00000_0000000_0001101100000_000000); | ||||
| /// <summary> Gets a <see cref="GuildPermissions"/> that grants all guild permissions. </summary> | /// <summary> Gets a <see cref="GuildPermissions"/> that grants all guild permissions. </summary> | ||||
| public static readonly GuildPermissions All = new GuildPermissions(0b11111_1111110_1111111111111_111111); | |||||
| public static readonly GuildPermissions All = new GuildPermissions(0b11111_1111111_1111111111111_111111); | |||||
| /// <summary> Gets a packed value representing all the permissions in this <see cref="GuildPermissions"/>. </summary> | /// <summary> Gets a packed value representing all the permissions in this <see cref="GuildPermissions"/>. </summary> | ||||
| public ulong RawValue { get; } | public ulong RawValue { get; } | ||||
| @@ -34,6 +34,8 @@ namespace Discord | |||||
| public bool AddReactions => Permissions.GetValue(RawValue, GuildPermission.AddReactions); | public bool AddReactions => Permissions.GetValue(RawValue, GuildPermission.AddReactions); | ||||
| /// <summary> If <c>true</c>, a user may view the audit log. </summary> | /// <summary> If <c>true</c>, a user may view the audit log. </summary> | ||||
| public bool ViewAuditLog => Permissions.GetValue(RawValue, GuildPermission.ViewAuditLog); | public bool ViewAuditLog => Permissions.GetValue(RawValue, GuildPermission.ViewAuditLog); | ||||
| /// <summary> If <c>true</c>, a user may view the guild insights. </summary> | |||||
| public bool ViewGuildInsights => Permissions.GetValue(RawValue, GuildPermission.ViewGuildInsights); | |||||
| /// <summary> If True, a user may join channels. </summary> | /// <summary> If True, a user may join channels. </summary> | ||||
| [Obsolete("Use ViewChannel instead.")] | [Obsolete("Use ViewChannel instead.")] | ||||
| @@ -97,6 +99,7 @@ namespace Discord | |||||
| bool? manageGuild = null, | bool? manageGuild = null, | ||||
| bool? addReactions = null, | bool? addReactions = null, | ||||
| bool? viewAuditLog = null, | bool? viewAuditLog = null, | ||||
| bool? viewGuildInsights = null, | |||||
| bool? viewChannel = null, | bool? viewChannel = null, | ||||
| bool? sendMessages = null, | bool? sendMessages = null, | ||||
| bool? sendTTSMessages = null, | bool? sendTTSMessages = null, | ||||
| @@ -130,6 +133,7 @@ namespace Discord | |||||
| Permissions.SetValue(ref value, manageGuild, GuildPermission.ManageGuild); | Permissions.SetValue(ref value, manageGuild, GuildPermission.ManageGuild); | ||||
| Permissions.SetValue(ref value, addReactions, GuildPermission.AddReactions); | Permissions.SetValue(ref value, addReactions, GuildPermission.AddReactions); | ||||
| Permissions.SetValue(ref value, viewAuditLog, GuildPermission.ViewAuditLog); | Permissions.SetValue(ref value, viewAuditLog, GuildPermission.ViewAuditLog); | ||||
| Permissions.SetValue(ref value, viewGuildInsights, GuildPermission.ViewGuildInsights); | |||||
| Permissions.SetValue(ref value, viewChannel, GuildPermission.ViewChannel); | Permissions.SetValue(ref value, viewChannel, GuildPermission.ViewChannel); | ||||
| Permissions.SetValue(ref value, sendMessages, GuildPermission.SendMessages); | Permissions.SetValue(ref value, sendMessages, GuildPermission.SendMessages); | ||||
| Permissions.SetValue(ref value, sendTTSMessages, GuildPermission.SendTTSMessages); | Permissions.SetValue(ref value, sendTTSMessages, GuildPermission.SendTTSMessages); | ||||
| @@ -166,6 +170,7 @@ namespace Discord | |||||
| bool manageGuild = false, | bool manageGuild = false, | ||||
| bool addReactions = false, | bool addReactions = false, | ||||
| bool viewAuditLog = false, | bool viewAuditLog = false, | ||||
| bool viewGuildInsights = false, | |||||
| bool viewChannel = false, | bool viewChannel = false, | ||||
| bool sendMessages = false, | bool sendMessages = false, | ||||
| bool sendTTSMessages = false, | bool sendTTSMessages = false, | ||||
| @@ -198,6 +203,7 @@ namespace Discord | |||||
| manageGuild: manageGuild, | manageGuild: manageGuild, | ||||
| addReactions: addReactions, | addReactions: addReactions, | ||||
| viewAuditLog: viewAuditLog, | viewAuditLog: viewAuditLog, | ||||
| viewGuildInsights: viewGuildInsights, | |||||
| viewChannel: viewChannel, | viewChannel: viewChannel, | ||||
| sendMessages: sendMessages, | sendMessages: sendMessages, | ||||
| sendTTSMessages: sendTTSMessages, | sendTTSMessages: sendTTSMessages, | ||||
| @@ -231,6 +237,7 @@ namespace Discord | |||||
| bool? manageGuild = null, | bool? manageGuild = null, | ||||
| bool? addReactions = null, | bool? addReactions = null, | ||||
| bool? viewAuditLog = null, | bool? viewAuditLog = null, | ||||
| bool? viewGuildInsights = null, | |||||
| bool? viewChannel = null, | bool? viewChannel = null, | ||||
| bool? sendMessages = null, | bool? sendMessages = null, | ||||
| bool? sendTTSMessages = null, | bool? sendTTSMessages = null, | ||||
| @@ -254,7 +261,7 @@ namespace Discord | |||||
| bool? manageWebhooks = null, | bool? manageWebhooks = null, | ||||
| bool? manageEmojis = null) | bool? manageEmojis = null) | ||||
| => new GuildPermissions(RawValue, createInstantInvite, kickMembers, banMembers, administrator, manageChannels, manageGuild, addReactions, | => new GuildPermissions(RawValue, createInstantInvite, kickMembers, banMembers, administrator, manageChannels, manageGuild, addReactions, | ||||
| viewAuditLog, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, | |||||
| viewAuditLog, viewGuildInsights, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, | |||||
| readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers, | readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers, | ||||
| useVoiceActivation, prioritySpeaker, stream, changeNickname, manageNicknames, manageRoles, manageWebhooks, manageEmojis); | useVoiceActivation, prioritySpeaker, stream, changeNickname, manageNicknames, manageRoles, manageWebhooks, manageEmojis); | ||||
| @@ -65,6 +65,13 @@ namespace Discord | |||||
| /// An <see cref="int"/> representing the position of the role in the role list of the guild. | /// An <see cref="int"/> representing the position of the role in the role list of the guild. | ||||
| /// </returns> | /// </returns> | ||||
| int Position { get; } | int Position { get; } | ||||
| /// <summary> | |||||
| /// Gets the tags related to this role. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// A <see cref="RoleTags"/> object containing all tags related to this role. | |||||
| /// </returns> | |||||
| RoleTags Tags { get; } | |||||
| /// <summary> | /// <summary> | ||||
| /// Modifies this role. | /// Modifies this role. | ||||
| @@ -0,0 +1,40 @@ | |||||
| namespace Discord | |||||
| { | |||||
| /// <summary> | |||||
| /// Provides tags related to a discord role. | |||||
| /// </summary> | |||||
| public class RoleTags | |||||
| { | |||||
| /// <summary> | |||||
| /// Gets the identifier of the bot that this role belongs to, if it does. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// A <see langword="ulong"/> if this role belongs to a bot; otherwise | |||||
| /// <see langword="null"/>. | |||||
| /// </returns> | |||||
| public ulong? BotId { get; } | |||||
| /// <summary> | |||||
| /// Gets the identifier of the integration that this role belongs to, if it does. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// A <see langword="ulong"/> if this role belongs to an integration; otherwise | |||||
| /// <see langword="null"/>. | |||||
| /// </returns> | |||||
| public ulong? IntegrationId { get; } | |||||
| /// <summary> | |||||
| /// Gets if this role is the guild's premium subscriber (booster) role. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// <see langword="true"/> if this role is the guild's premium subscriber role; | |||||
| /// otherwise <see langword="false"/>. | |||||
| /// </returns> | |||||
| public bool IsPremiumSubscriberRole { get; } | |||||
| internal RoleTags(ulong? botId, ulong? integrationId, bool isPremiumSubscriber) | |||||
| { | |||||
| BotId = botId; | |||||
| IntegrationId = integrationId; | |||||
| IsPremiumSubscriberRole = isPremiumSubscriber; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,27 @@ | |||||
| using System.Collections.Generic; | |||||
| namespace Discord | |||||
| { | |||||
| /// <summary> | |||||
| /// Represents a Discord Team. | |||||
| /// </summary> | |||||
| public interface ITeam | |||||
| { | |||||
| /// <summary> | |||||
| /// Gets the team icon url. | |||||
| /// </summary> | |||||
| string IconUrl { get; } | |||||
| /// <summary> | |||||
| /// Gets the team unique identifier. | |||||
| /// </summary> | |||||
| ulong Id { get; } | |||||
| /// <summary> | |||||
| /// Gets the members of this team. | |||||
| /// </summary> | |||||
| IReadOnlyList<ITeamMember> TeamMembers { get; } | |||||
| /// <summary> | |||||
| /// Gets the user identifier that owns this team. | |||||
| /// </summary> | |||||
| ulong OwnerUserId { get; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,25 @@ | |||||
| namespace Discord | |||||
| { | |||||
| /// <summary> | |||||
| /// Represents a Discord Team member. | |||||
| /// </summary> | |||||
| public interface ITeamMember | |||||
| { | |||||
| /// <summary> | |||||
| /// Gets the membership state of this team member. | |||||
| /// </summary> | |||||
| MembershipState MembershipState { get; } | |||||
| /// <summary> | |||||
| /// Gets the permissions of this team member. | |||||
| /// </summary> | |||||
| string[] Permissions { get; } | |||||
| /// <summary> | |||||
| /// Gets the team unique identifier for this team member. | |||||
| /// </summary> | |||||
| ulong TeamId { get; } | |||||
| /// <summary> | |||||
| /// Gets the Discord user of this team member. | |||||
| /// </summary> | |||||
| IUser User { get; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,11 @@ | |||||
| namespace Discord | |||||
| { | |||||
| /// <summary> | |||||
| /// Represents the membership state of a team member. | |||||
| /// </summary> | |||||
| public enum MembershipState | |||||
| { | |||||
| Invited, | |||||
| Accepted, | |||||
| } | |||||
| } | |||||
| @@ -68,12 +68,17 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| IReadOnlyCollection<ulong> RoleIds { get; } | IReadOnlyCollection<ulong> RoleIds { get; } | ||||
| /// <summary> | |||||
| /// Whether the user has passed the guild's Membership Screening requirements. | |||||
| /// </summary> | |||||
| bool? IsPending { get; } | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the level permissions granted to this user to a given channel. | /// Gets the level permissions granted to this user to a given channel. | ||||
| /// </summary> | /// </summary> | ||||
| /// <example> | /// <example> | ||||
| /// <para>The following example checks if the current user has the ability to send a message with attachment in | /// <para>The following example checks if the current user has the ability to send a message with attachment in | ||||
| /// this channel; if so, uploads a file via <see cref="IMessageChannel.SendFileAsync(string, string, bool, Embed, RequestOptions, bool, AllowedMentions)"/>.</para> | |||||
| /// this channel; if so, uploads a file via <see cref="IMessageChannel.SendFileAsync(string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference)"/>.</para> | |||||
| /// <code language="cs"> | /// <code language="cs"> | ||||
| /// if (currentUser?.GetPermissions(targetChannel)?.AttachFiles) | /// if (currentUser?.GetPermissions(targetChannel)?.AttachFiles) | ||||
| /// await targetChannel.SendFileAsync("fortnite.png"); | /// await targetChannel.SendFileAsync("fortnite.png"); | ||||
| @@ -75,6 +75,16 @@ namespace Discord | |||||
| /// Gets the username for this user. | /// Gets the username for this user. | ||||
| /// </summary> | /// </summary> | ||||
| string Username { get; } | string Username { get; } | ||||
| /// <summary> | |||||
| /// Gets the public flags that are applied to this user's account. | |||||
| /// </summary> | |||||
| /// <remarks> | |||||
| /// This value is determined by bitwise OR-ing <see cref="UserProperties"/> values together. | |||||
| /// </remarks> | |||||
| /// <returns> | |||||
| /// The value of public flags for this user. | |||||
| /// </returns> | |||||
| UserProperties? PublicFlags { get; } | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the direct message channel of this user, or create one if it does not already exist. | /// Gets the direct message channel of this user, or create one if it does not already exist. | ||||
| @@ -10,32 +10,62 @@ namespace Discord | |||||
| /// </summary> | /// </summary> | ||||
| None = 0, | None = 0, | ||||
| /// <summary> | /// <summary> | ||||
| /// Flag given to Discord staff. | |||||
| /// Flag given to users who are a Discord employee. | |||||
| /// </summary> | /// </summary> | ||||
| Staff = 0b1, | |||||
| Staff = 1 << 0, | |||||
| /// <summary> | /// <summary> | ||||
| /// Flag given to Discord partners. | |||||
| /// Flag given to users who are owners of a partnered Discord server. | |||||
| /// </summary> | /// </summary> | ||||
| Partner = 0b10, | |||||
| Partner = 1 << 1, | |||||
| /// <summary> | |||||
| /// Flag given to users in HypeSquad events. | |||||
| /// </summary> | |||||
| HypeSquadEvents = 1 << 2, | |||||
| /// <summary> | /// <summary> | ||||
| /// Flag given to users who have participated in the bug report program. | /// Flag given to users who have participated in the bug report program. | ||||
| /// This flag is obsolete, use <see cref="BugHunterLevel1"/> instead. | |||||
| /// </summary> | |||||
| [Obsolete("Use BugHunterLevel1 instead.")] | |||||
| BugHunter = 1 << 3, | |||||
| /// <summary> | |||||
| /// Flag given to users who have participated in the bug report program and are level 1. | |||||
| /// </summary> | /// </summary> | ||||
| BugHunter = 0b1000, | |||||
| BugHunterLevel1 = 1 << 3, | |||||
| /// <summary> | /// <summary> | ||||
| /// Flag given to users who are in the HypeSquad House of Bravery. | /// Flag given to users who are in the HypeSquad House of Bravery. | ||||
| /// </summary> | /// </summary> | ||||
| HypeSquadBravery = 0b100_0000, | |||||
| HypeSquadBravery = 1 << 6, | |||||
| /// <summary> | /// <summary> | ||||
| /// Flag given to users who are in the HypeSquad House of Brilliance. | /// Flag given to users who are in the HypeSquad House of Brilliance. | ||||
| /// </summary> | /// </summary> | ||||
| HypeSquadBrilliance = 0b1000_0000, | |||||
| HypeSquadBrilliance = 1 << 7, | |||||
| /// <summary> | /// <summary> | ||||
| /// Flag given to users who are in the HypeSquad House of Balance. | /// Flag given to users who are in the HypeSquad House of Balance. | ||||
| /// </summary> | /// </summary> | ||||
| HypeSquadBalance = 0b1_0000_0000, | |||||
| HypeSquadBalance = 1 << 8, | |||||
| /// <summary> | /// <summary> | ||||
| /// Flag given to users who subscribed to Nitro before games were added. | /// Flag given to users who subscribed to Nitro before games were added. | ||||
| /// </summary> | /// </summary> | ||||
| EarlySupporter = 0b10_0000_0000, | |||||
| EarlySupporter = 1 << 9, | |||||
| /// <summary> | |||||
| /// Flag given to users who are part of a team. | |||||
| /// </summary> | |||||
| TeamUser = 1 << 10, | |||||
| /// <summary> | |||||
| /// Flag given to users who represent Discord (System). | |||||
| /// </summary> | |||||
| System = 1 << 12, | |||||
| /// <summary> | |||||
| /// Flag given to users who have participated in the bug report program and are level 2. | |||||
| /// </summary> | |||||
| BugHunterLevel2 = 1 << 14, | |||||
| /// <summary> | |||||
| /// Flag given to users who are verified bots. | |||||
| /// </summary> | |||||
| VerifiedBot = 1 << 16, | |||||
| /// <summary> | |||||
| /// Flag given to users that developed bots and early verified their accounts. | |||||
| /// </summary> | |||||
| EarlyVerifiedBotDeveloper = 1 << 17, | |||||
| } | } | ||||
| } | } | ||||
| @@ -71,5 +71,25 @@ namespace Discord | |||||
| foreach (var rxn in reactions) | foreach (var rxn in reactions) | ||||
| await msg.RemoveReactionAsync(rxn, user, options).ConfigureAwait(false); | await msg.RemoveReactionAsync(rxn, user, options).ConfigureAwait(false); | ||||
| } | } | ||||
| /// <summary> | |||||
| /// Sends an inline reply that references a message. | |||||
| /// </summary> | |||||
| /// <param name="text">The message to be sent.</param> | |||||
| /// <param name="isTTS">Determines whether the message should be read aloud by Discord or not.</param> | |||||
| /// <param name="embed">The <see cref="Discord.EmbedType.Rich"/> <see cref="Embed"/> to be sent.</param> | |||||
| /// <param name="allowedMentions"> | |||||
| /// Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>. | |||||
| /// If <c>null</c>, all mentioned roles and users will be notified. | |||||
| /// </param> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A task that represents an asynchronous send operation for delivering the message. The task result | |||||
| /// contains the sent message. | |||||
| /// </returns> | |||||
| public static async Task<IUserMessage> ReplyAsync(this IUserMessage msg, string text = null, bool isTTS = false, Embed embed = null, AllowedMentions allowedMentions = null, RequestOptions options = null) | |||||
| { | |||||
| return await msg.Channel.SendMessageAsync(text, isTTS, embed, options, allowedMentions, new MessageReference(messageId: msg.Id)).ConfigureAwait(false); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -274,5 +274,15 @@ namespace Discord | |||||
| /// that represents the number of shards that should be used with this account. | /// that represents the number of shards that should be used with this account. | ||||
| /// </returns> | /// </returns> | ||||
| Task<int> GetRecommendedShardCountAsync(RequestOptions options = null); | Task<int> GetRecommendedShardCountAsync(RequestOptions options = null); | ||||
| /// <summary> | |||||
| /// Gets the gateway information related to the bot. | |||||
| /// </summary> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A task that represents the asynchronous get operation. The task result contains a <see cref="BotGateway"/> | |||||
| /// that represents the gateway information related to the bot. | |||||
| /// </returns> | |||||
| Task<BotGateway> GetBotGatewayAsync(RequestOptions options = null); | |||||
| } | } | ||||
| } | } | ||||
| @@ -61,6 +61,7 @@ namespace Discord | |||||
| internal BucketId BucketId { get; set; } | internal BucketId BucketId { get; set; } | ||||
| internal bool IsClientBucket { get; set; } | internal bool IsClientBucket { get; set; } | ||||
| internal bool IsReactionBucket { get; set; } | internal bool IsReactionBucket { get; set; } | ||||
| internal bool IsGatewayBucket { get; set; } | |||||
| internal static RequestOptions CreateOrClone(RequestOptions options) | internal static RequestOptions CreateOrClone(RequestOptions options) | ||||
| { | { | ||||
| @@ -2,7 +2,7 @@ using Newtonsoft.Json; | |||||
| namespace Discord.API | namespace Discord.API | ||||
| { | { | ||||
| public class AllowedMentions | |||||
| internal class AllowedMentions | |||||
| { | { | ||||
| [JsonProperty("parse")] | [JsonProperty("parse")] | ||||
| public Optional<string[]> Parse { get; set; } | public Optional<string[]> Parse { get; set; } | ||||
| @@ -11,5 +11,7 @@ namespace Discord.API | |||||
| public Optional<ulong[]> Roles { get; set; } | public Optional<ulong[]> Roles { get; set; } | ||||
| [JsonProperty("users")] | [JsonProperty("users")] | ||||
| public Optional<ulong[]> Users { get; set; } | public Optional<ulong[]> Users { get; set; } | ||||
| [JsonProperty("replied_user")] | |||||
| public Optional<bool> RepliedUser { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| #pragma warning disable CS1591 | |||||
| #pragma warning disable CS1591 | |||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| namespace Discord.API | namespace Discord.API | ||||
| @@ -15,6 +15,12 @@ namespace Discord.API | |||||
| public ulong Id { get; set; } | public ulong Id { get; set; } | ||||
| [JsonProperty("icon")] | [JsonProperty("icon")] | ||||
| public string Icon { get; set; } | public string Icon { get; set; } | ||||
| [JsonProperty("bot_public")] | |||||
| public bool IsBotPublic { get; set; } | |||||
| [JsonProperty("bot_require_code_grant")] | |||||
| public bool BotRequiresCodeGrant { get; set; } | |||||
| [JsonProperty("team")] | |||||
| public Team Team { get; set; } | |||||
| [JsonProperty("flags"), Int53] | [JsonProperty("flags"), Int53] | ||||
| public Optional<ulong> Flags { get; set; } | public Optional<ulong> Flags { get; set; } | ||||
| @@ -13,6 +13,8 @@ namespace Discord.API | |||||
| public string Icon { get; set; } | public string Icon { get; set; } | ||||
| [JsonProperty("splash")] | [JsonProperty("splash")] | ||||
| public string Splash { get; set; } | public string Splash { get; set; } | ||||
| [JsonProperty("discovery_splash")] | |||||
| public string DiscoverySplash { get; set; } | |||||
| [JsonProperty("owner_id")] | [JsonProperty("owner_id")] | ||||
| public ulong OwnerId { get; set; } | public ulong OwnerId { get; set; } | ||||
| [JsonProperty("region")] | [JsonProperty("region")] | ||||
| @@ -22,9 +24,9 @@ namespace Discord.API | |||||
| [JsonProperty("afk_timeout")] | [JsonProperty("afk_timeout")] | ||||
| public int AFKTimeout { get; set; } | public int AFKTimeout { get; set; } | ||||
| [JsonProperty("embed_enabled")] | [JsonProperty("embed_enabled")] | ||||
| public bool EmbedEnabled { get; set; } | |||||
| public Optional<bool> EmbedEnabled { get; set; } | |||||
| [JsonProperty("embed_channel_id")] | [JsonProperty("embed_channel_id")] | ||||
| public ulong? EmbedChannelId { get; set; } | |||||
| public Optional<ulong?> EmbedChannelId { get; set; } | |||||
| [JsonProperty("verification_level")] | [JsonProperty("verification_level")] | ||||
| public VerificationLevel VerificationLevel { get; set; } | public VerificationLevel VerificationLevel { get; set; } | ||||
| [JsonProperty("default_message_notifications")] | [JsonProperty("default_message_notifications")] | ||||
| @@ -43,6 +45,10 @@ namespace Discord.API | |||||
| public MfaLevel MfaLevel { get; set; } | public MfaLevel MfaLevel { get; set; } | ||||
| [JsonProperty("application_id")] | [JsonProperty("application_id")] | ||||
| public ulong? ApplicationId { get; set; } | public ulong? ApplicationId { get; set; } | ||||
| [JsonProperty("widget_enabled")] | |||||
| public Optional<bool> WidgetEnabled { get; set; } | |||||
| [JsonProperty("widget_channel_id")] | |||||
| public Optional<ulong?> WidgetChannelId { get; set; } | |||||
| [JsonProperty("system_channel_id")] | [JsonProperty("system_channel_id")] | ||||
| public ulong? SystemChannelId { get; set; } | public ulong? SystemChannelId { get; set; } | ||||
| [JsonProperty("premium_tier")] | [JsonProperty("premium_tier")] | ||||
| @@ -56,9 +62,23 @@ namespace Discord.API | |||||
| // this value is inverted, flags set will turn OFF features | // this value is inverted, flags set will turn OFF features | ||||
| [JsonProperty("system_channel_flags")] | [JsonProperty("system_channel_flags")] | ||||
| public SystemChannelMessageDeny SystemChannelFlags { get; set; } | public SystemChannelMessageDeny SystemChannelFlags { get; set; } | ||||
| [JsonProperty("rules_channel_id")] | |||||
| public ulong? RulesChannelId { get; set; } | |||||
| [JsonProperty("max_presences")] | |||||
| public Optional<int?> MaxPresences { get; set; } | |||||
| [JsonProperty("max_members")] | |||||
| public Optional<int> MaxMembers { get; set; } | |||||
| [JsonProperty("premium_subscription_count")] | [JsonProperty("premium_subscription_count")] | ||||
| public int? PremiumSubscriptionCount { get; set; } | public int? PremiumSubscriptionCount { get; set; } | ||||
| [JsonProperty("preferred_locale")] | [JsonProperty("preferred_locale")] | ||||
| public string PreferredLocale { get; set; } | public string PreferredLocale { get; set; } | ||||
| [JsonProperty("public_updates_channel_id")] | |||||
| public ulong? PublicUpdatesChannelId { get; set; } | |||||
| [JsonProperty("max_video_channel_users")] | |||||
| public Optional<int> MaxVideoChannelUsers { get; set; } | |||||
| [JsonProperty("approximate_member_count")] | |||||
| public Optional<int> ApproximateMemberCount { get; set; } | |||||
| [JsonProperty("approximate_presence_count")] | |||||
| public Optional<int> ApproximatePresenceCount { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| #pragma warning disable CS1591 | |||||
| #pragma warning disable CS1591 | |||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| namespace Discord.API | namespace Discord.API | ||||
| @@ -8,6 +8,6 @@ namespace Discord.API | |||||
| [JsonProperty("enabled")] | [JsonProperty("enabled")] | ||||
| public bool Enabled { get; set; } | public bool Enabled { get; set; } | ||||
| [JsonProperty("channel_id")] | [JsonProperty("channel_id")] | ||||
| public ulong ChannelId { get; set; } | |||||
| public ulong? ChannelId { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -18,6 +18,8 @@ namespace Discord.API | |||||
| public Optional<bool> Deaf { get; set; } | public Optional<bool> Deaf { get; set; } | ||||
| [JsonProperty("mute")] | [JsonProperty("mute")] | ||||
| public Optional<bool> Mute { get; set; } | public Optional<bool> Mute { get; set; } | ||||
| [JsonProperty("pending")] | |||||
| public Optional<bool> Pending { get; set; } | |||||
| [JsonProperty("premium_since")] | [JsonProperty("premium_since")] | ||||
| public Optional<DateTimeOffset?> PremiumSince { get; set; } | public Optional<DateTimeOffset?> PremiumSince { get; set; } | ||||
| } | } | ||||
| @@ -0,0 +1,13 @@ | |||||
| #pragma warning disable CS1591 | |||||
| using Newtonsoft.Json; | |||||
| namespace Discord.API | |||||
| { | |||||
| internal class GuildWidget | |||||
| { | |||||
| [JsonProperty("enabled")] | |||||
| public bool Enabled { get; set; } | |||||
| [JsonProperty("channel_id")] | |||||
| public ulong? ChannelId { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -11,9 +11,15 @@ namespace Discord.API | |||||
| public Optional<InviteGuild> Guild { get; set; } | public Optional<InviteGuild> Guild { get; set; } | ||||
| [JsonProperty("channel")] | [JsonProperty("channel")] | ||||
| public InviteChannel Channel { get; set; } | public InviteChannel Channel { get; set; } | ||||
| [JsonProperty("inviter")] | |||||
| public Optional<User> Inviter { get; set; } | |||||
| [JsonProperty("approximate_presence_count")] | [JsonProperty("approximate_presence_count")] | ||||
| public Optional<int?> PresenceCount { get; set; } | public Optional<int?> PresenceCount { get; set; } | ||||
| [JsonProperty("approximate_member_count")] | [JsonProperty("approximate_member_count")] | ||||
| public Optional<int?> MemberCount { get; set; } | public Optional<int?> MemberCount { get; set; } | ||||
| [JsonProperty("target_user")] | |||||
| public Optional<User> TargetUser { get; set; } | |||||
| [JsonProperty("target_user_type")] | |||||
| public Optional<TargetUserType> TargetUserType { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -6,19 +6,15 @@ namespace Discord.API | |||||
| { | { | ||||
| internal class InviteMetadata : Invite | internal class InviteMetadata : Invite | ||||
| { | { | ||||
| [JsonProperty("inviter")] | |||||
| public User Inviter { get; set; } | |||||
| [JsonProperty("uses")] | [JsonProperty("uses")] | ||||
| public Optional<int> Uses { get; set; } | |||||
| public int Uses { get; set; } | |||||
| [JsonProperty("max_uses")] | [JsonProperty("max_uses")] | ||||
| public Optional<int> MaxUses { get; set; } | |||||
| public int MaxUses { get; set; } | |||||
| [JsonProperty("max_age")] | [JsonProperty("max_age")] | ||||
| public Optional<int> MaxAge { get; set; } | |||||
| public int MaxAge { get; set; } | |||||
| [JsonProperty("temporary")] | [JsonProperty("temporary")] | ||||
| public bool Temporary { get; set; } | public bool Temporary { get; set; } | ||||
| [JsonProperty("created_at")] | [JsonProperty("created_at")] | ||||
| public Optional<DateTimeOffset> CreatedAt { get; set; } | |||||
| [JsonProperty("revoked")] | |||||
| public bool Revoked { get; set; } | |||||
| public DateTimeOffset CreatedAt { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,9 @@ | |||||
| namespace Discord.API | |||||
| { | |||||
| internal enum MembershipState | |||||
| { | |||||
| None = 0, | |||||
| Invited = 1, | |||||
| Accepted = 2, | |||||
| } | |||||
| } | |||||
| @@ -56,5 +56,7 @@ namespace Discord.API | |||||
| 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; } | ||||
| [JsonProperty("referenced_message")] | |||||
| public Optional<Message> ReferencedMessage { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,10 +0,0 @@ | |||||
| using System; | |||||
| namespace Discord.API | |||||
| { | |||||
| [Flags] | |||||
| internal enum MessageFlags : byte // probably safe to constrain this to 8 values, if not, it's internal so who cares | |||||
| { | |||||
| Suppressed = 0x04, | |||||
| } | |||||
| } | |||||
| @@ -8,7 +8,7 @@ namespace Discord.API | |||||
| public Optional<ulong> MessageId { get; set; } | public Optional<ulong> MessageId { get; set; } | ||||
| [JsonProperty("channel_id")] | [JsonProperty("channel_id")] | ||||
| public ulong ChannelId { get; set; } | |||||
| public Optional<ulong> ChannelId { get; set; } // Optional when sending, always present when receiving | |||||
| [JsonProperty("guild_id")] | [JsonProperty("guild_id")] | ||||
| public Optional<ulong> GuildId { get; set; } | public Optional<ulong> GuildId { get; set; } | ||||
| @@ -1,4 +1,4 @@ | |||||
| #pragma warning disable CS1591 | |||||
| #pragma warning disable CS1591 | |||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| namespace Discord.API | namespace Discord.API | ||||
| @@ -21,5 +21,7 @@ namespace Discord.API | |||||
| public ulong Permissions { get; set; } | public ulong Permissions { get; set; } | ||||
| [JsonProperty("managed")] | [JsonProperty("managed")] | ||||
| public bool Managed { get; set; } | public bool Managed { get; set; } | ||||
| [JsonProperty("tags")] | |||||
| public Optional<RoleTags> Tags { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,15 @@ | |||||
| #pragma warning disable CS1591 | |||||
| using Newtonsoft.Json; | |||||
| namespace Discord.API | |||||
| { | |||||
| internal class RoleTags | |||||
| { | |||||
| [JsonProperty("bot_id")] | |||||
| public Optional<ulong> BotId { get; set; } | |||||
| [JsonProperty("integration_id")] | |||||
| public Optional<ulong> IntegrationId { get; set; } | |||||
| [JsonProperty("premium_subscriber")] | |||||
| public Optional<bool?> IsPremiumSubscriber { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| using Newtonsoft.Json; | |||||
| namespace Discord.API.Rest | |||||
| { | |||||
| internal class SessionStartLimit | |||||
| { | |||||
| [JsonProperty("total")] | |||||
| public int Total { get; set; } | |||||
| [JsonProperty("remaining")] | |||||
| public int Remaining { get; set; } | |||||
| [JsonProperty("reset_after")] | |||||
| public int ResetAfter { get; set; } | |||||
| [JsonProperty("max_concurrency")] | |||||
| public int MaxConcurrency { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,17 @@ | |||||
| #pragma warning disable CS1591 | |||||
| using Newtonsoft.Json; | |||||
| namespace Discord.API | |||||
| { | |||||
| internal class Team | |||||
| { | |||||
| [JsonProperty("icon")] | |||||
| public Optional<string> Icon { get; set; } | |||||
| [JsonProperty("id")] | |||||
| public ulong Id { get; set; } | |||||
| [JsonProperty("members")] | |||||
| public TeamMember[] TeamMembers { get; set; } | |||||
| [JsonProperty("owner_user_id")] | |||||
| public ulong OwnerUserId { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,17 @@ | |||||
| #pragma warning disable CS1591 | |||||
| using Newtonsoft.Json; | |||||
| namespace Discord.API | |||||
| { | |||||
| internal class TeamMember | |||||
| { | |||||
| [JsonProperty("membership_state")] | |||||
| public MembershipState MembershipState { get; set; } | |||||
| [JsonProperty("permissions")] | |||||
| public string[] Permissions { get; set; } | |||||
| [JsonProperty("team_id")] | |||||
| public ulong TeamId { get; set; } | |||||
| [JsonProperty("user")] | |||||
| public User User { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -29,5 +29,7 @@ namespace Discord.API | |||||
| public Optional<PremiumType> PremiumType { get; set; } | public Optional<PremiumType> PremiumType { get; set; } | ||||
| [JsonProperty("locale")] | [JsonProperty("locale")] | ||||
| public Optional<string> Locale { get; set; } | public Optional<string> Locale { get; set; } | ||||
| [JsonProperty("public_flags")] | |||||
| public Optional<UserProperties> PublicFlags { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -17,6 +17,8 @@ namespace Discord.API.Rest | |||||
| public Optional<Embed> Embed { get; set; } | public Optional<Embed> Embed { get; set; } | ||||
| [JsonProperty("allowed_mentions")] | [JsonProperty("allowed_mentions")] | ||||
| public Optional<AllowedMentions> AllowedMentions { get; set; } | public Optional<AllowedMentions> AllowedMentions { get; set; } | ||||
| [JsonProperty("message_reference")] | |||||
| public Optional<MessageReference> MessageReference { get; set; } | |||||
| public CreateMessageParams(string content) | public CreateMessageParams(string content) | ||||
| { | { | ||||
| @@ -1,4 +1,4 @@ | |||||
| #pragma warning disable CS1591 | |||||
| #pragma warning disable CS1591 | |||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| namespace Discord.API.Rest | namespace Discord.API.Rest | ||||
| @@ -9,5 +9,7 @@ namespace Discord.API.Rest | |||||
| public string Url { get; set; } | public string Url { get; set; } | ||||
| [JsonProperty("shards")] | [JsonProperty("shards")] | ||||
| public int Shards { get; set; } | public int Shards { get; set; } | ||||
| [JsonProperty("session_start_limit")] | |||||
| public SessionStartLimit SessionStartLimit { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -9,9 +9,13 @@ namespace Discord.API.Rest | |||||
| [JsonProperty("days")] | [JsonProperty("days")] | ||||
| public int Days { get; } | public int Days { get; } | ||||
| public GuildPruneParams(int days) | |||||
| [JsonProperty("include_roles")] | |||||
| public ulong[] IncludeRoleIds { get; } | |||||
| public GuildPruneParams(int days, ulong[] includeRoleIds) | |||||
| { | { | ||||
| Days = days; | Days = days; | ||||
| IncludeRoleIds = includeRoleIds; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,14 @@ | |||||
| #pragma warning disable CS1591 | |||||
| using Newtonsoft.Json; | |||||
| namespace Discord.API.Rest | |||||
| { | |||||
| [JsonObject(MemberSerialization = MemberSerialization.OptIn)] | |||||
| internal class ModifyGuildWidgetParams | |||||
| { | |||||
| [JsonProperty("enabled")] | |||||
| public Optional<bool> Enabled { get; set; } | |||||
| [JsonProperty("channel")] | |||||
| public Optional<ulong?> ChannelId { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -1,4 +1,4 @@ | |||||
| #pragma warning disable CS1591 | |||||
| #pragma warning disable CS1591 | |||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| namespace Discord.API.Rest | namespace Discord.API.Rest | ||||
| @@ -10,5 +10,9 @@ namespace Discord.API.Rest | |||||
| public Optional<string> Content { get; set; } | public Optional<string> Content { get; set; } | ||||
| [JsonProperty("embed")] | [JsonProperty("embed")] | ||||
| public Optional<Embed> Embed { get; set; } | public Optional<Embed> Embed { get; set; } | ||||
| [JsonProperty("flags")] | |||||
| public Optional<MessageFlags?> Flags { get; set; } | |||||
| [JsonProperty("allowed_mentions")] | |||||
| public Optional<AllowedMentions> AllowedMentions { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -20,6 +20,7 @@ namespace Discord.API.Rest | |||||
| public Optional<bool> IsTTS { get; set; } | public Optional<bool> IsTTS { get; set; } | ||||
| public Optional<Embed> Embed { get; set; } | public Optional<Embed> Embed { get; set; } | ||||
| public Optional<AllowedMentions> AllowedMentions { get; set; } | public Optional<AllowedMentions> AllowedMentions { get; set; } | ||||
| public Optional<MessageReference> MessageReference { get; set; } | |||||
| public bool IsSpoiler { get; set; } = false; | public bool IsSpoiler { get; set; } = false; | ||||
| public UploadFileParams(Stream file) | public UploadFileParams(Stream file) | ||||
| @@ -46,12 +46,12 @@ namespace Discord.Rest | |||||
| _restLogger = LogManager.CreateLogger("Rest"); | _restLogger = LogManager.CreateLogger("Rest"); | ||||
| _isFirstLogin = config.DisplayInitialLog; | _isFirstLogin = config.DisplayInitialLog; | ||||
| ApiClient.RequestQueue.RateLimitTriggered += async (id, info) => | |||||
| ApiClient.RequestQueue.RateLimitTriggered += async (id, info, endpoint) => | |||||
| { | { | ||||
| if (info == null) | if (info == null) | ||||
| await _restLogger.VerboseAsync($"Preemptive Rate limit triggered: {id?.ToString() ?? "null"}").ConfigureAwait(false); | |||||
| await _restLogger.VerboseAsync($"Preemptive Rate limit triggered: {endpoint} {(id.IsHashBucket ? $"(Bucket: {id.BucketHash})" : "")}").ConfigureAwait(false); | |||||
| else | else | ||||
| await _restLogger.WarningAsync($"Rate limit triggered: {id?.ToString() ?? "null"}").ConfigureAwait(false); | |||||
| await _restLogger.WarningAsync($"Rate limit triggered: {endpoint} {(id.IsHashBucket ? $"(Bucket: {id.BucketHash})" : "")}").ConfigureAwait(false); | |||||
| }; | }; | ||||
| ApiClient.SentRequest += async (method, endpoint, millis) => await _restLogger.VerboseAsync($"{method} {endpoint}: {millis} ms").ConfigureAwait(false); | ApiClient.SentRequest += async (method, endpoint, millis) => await _restLogger.VerboseAsync($"{method} {endpoint}: {millis} ms").ConfigureAwait(false); | ||||
| } | } | ||||
| @@ -152,6 +152,10 @@ namespace Discord.Rest | |||||
| public Task<int> GetRecommendedShardCountAsync(RequestOptions options = null) | public Task<int> GetRecommendedShardCountAsync(RequestOptions options = null) | ||||
| => ClientHelper.GetRecommendShardCountAsync(this, options); | => ClientHelper.GetRecommendShardCountAsync(this, options); | ||||
| /// <inheritdoc /> | |||||
| public Task<BotGateway> GetBotGatewayAsync(RequestOptions options = null) | |||||
| => ClientHelper.GetBotGatewayAsync(this, options); | |||||
| //IDiscordClient | //IDiscordClient | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| ConnectionState IDiscordClient.ConnectionState => ConnectionState.Disconnected; | ConnectionState IDiscordClient.ConnectionState => ConnectionState.Disconnected; | ||||
| @@ -62,9 +62,9 @@ namespace Discord.Rest | |||||
| } | } | ||||
| public static async Task<RestGuild> GetGuildAsync(BaseDiscordClient client, | public static async Task<RestGuild> GetGuildAsync(BaseDiscordClient client, | ||||
| ulong id, RequestOptions options) | |||||
| ulong id, bool withCounts, RequestOptions options) | |||||
| { | { | ||||
| var model = await client.ApiClient.GetGuildAsync(id, options).ConfigureAwait(false); | |||||
| var model = await client.ApiClient.GetGuildAsync(id, withCounts, options).ConfigureAwait(false); | |||||
| if (model != null) | if (model != null) | ||||
| return RestGuild.Create(client, model); | return RestGuild.Create(client, model); | ||||
| return null; | return null; | ||||
| @@ -77,6 +77,14 @@ namespace Discord.Rest | |||||
| return RestGuildEmbed.Create(model); | return RestGuildEmbed.Create(model); | ||||
| return null; | return null; | ||||
| } | } | ||||
| public static async Task<RestGuildWidget?> GetGuildWidgetAsync(BaseDiscordClient client, | |||||
| ulong id, RequestOptions options) | |||||
| { | |||||
| var model = await client.ApiClient.GetGuildWidgetAsync(id, options).ConfigureAwait(false); | |||||
| if (model != null) | |||||
| return RestGuildWidget.Create(model); | |||||
| return null; | |||||
| } | |||||
| public static IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(BaseDiscordClient client, | public static IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(BaseDiscordClient client, | ||||
| ulong? fromGuildId, int? limit, RequestOptions options) | ulong? fromGuildId, int? limit, RequestOptions options) | ||||
| { | { | ||||
| @@ -106,13 +114,13 @@ namespace Discord.Rest | |||||
| count: limit | count: limit | ||||
| ); | ); | ||||
| } | } | ||||
| public static async Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(BaseDiscordClient client, RequestOptions options) | |||||
| public static async Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(BaseDiscordClient client, bool withCounts, RequestOptions options) | |||||
| { | { | ||||
| var summaryModels = await GetGuildSummariesAsync(client, null, null, options).FlattenAsync().ConfigureAwait(false); | var summaryModels = await GetGuildSummariesAsync(client, null, null, options).FlattenAsync().ConfigureAwait(false); | ||||
| var guilds = ImmutableArray.CreateBuilder<RestGuild>(); | var guilds = ImmutableArray.CreateBuilder<RestGuild>(); | ||||
| foreach (var summaryModel in summaryModels) | foreach (var summaryModel in summaryModels) | ||||
| { | { | ||||
| var guildModel = await client.ApiClient.GetGuildAsync(summaryModel.Id).ConfigureAwait(false); | |||||
| var guildModel = await client.ApiClient.GetGuildAsync(summaryModel.Id, withCounts).ConfigureAwait(false); | |||||
| if (guildModel != null) | if (guildModel != null) | ||||
| guilds.Add(RestGuild.Create(client, guildModel)); | guilds.Add(RestGuild.Create(client, guildModel)); | ||||
| } | } | ||||
| @@ -140,7 +148,7 @@ namespace Discord.Rest | |||||
| public static async Task<RestGuildUser> GetGuildUserAsync(BaseDiscordClient client, | public static async Task<RestGuildUser> GetGuildUserAsync(BaseDiscordClient client, | ||||
| ulong guildId, ulong id, RequestOptions options) | ulong guildId, ulong id, RequestOptions options) | ||||
| { | { | ||||
| var guild = await GetGuildAsync(client, guildId, options).ConfigureAwait(false); | |||||
| var guild = await GetGuildAsync(client, guildId, false, options).ConfigureAwait(false); | |||||
| if (guild == null) | if (guild == null) | ||||
| return null; | return null; | ||||
| @@ -176,5 +184,22 @@ namespace Discord.Rest | |||||
| var response = await client.ApiClient.GetBotGatewayAsync(options).ConfigureAwait(false); | var response = await client.ApiClient.GetBotGatewayAsync(options).ConfigureAwait(false); | ||||
| return response.Shards; | return response.Shards; | ||||
| } | } | ||||
| public static async Task<BotGateway> GetBotGatewayAsync(BaseDiscordClient client, RequestOptions options) | |||||
| { | |||||
| var response = await client.ApiClient.GetBotGatewayAsync(options).ConfigureAwait(false); | |||||
| return new BotGateway | |||||
| { | |||||
| Url = response.Url, | |||||
| Shards = response.Shards, | |||||
| SessionStartLimit = new SessionStartLimit | |||||
| { | |||||
| Total = response.SessionStartLimit.Total, | |||||
| Remaining = response.SessionStartLimit.Remaining, | |||||
| ResetAfter = response.SessionStartLimit.ResetAfter, | |||||
| MaxConcurrency = response.SessionStartLimit.MaxConcurrency | |||||
| } | |||||
| }; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,5 +1,6 @@ | |||||
| <Project Sdk="Microsoft.NET.Sdk"> | <Project Sdk="Microsoft.NET.Sdk"> | ||||
| <Import Project="../../Discord.Net.targets" /> | <Import Project="../../Discord.Net.targets" /> | ||||
| <Import Project="../../StyleAnalyzer.targets"/> | |||||
| <PropertyGroup> | <PropertyGroup> | ||||
| <AssemblyName>Discord.Net.Rest</AssemblyName> | <AssemblyName>Discord.Net.Rest</AssemblyName> | ||||
| <RootNamespace>Discord.Rest</RootNamespace> | <RootNamespace>Discord.Rest</RootNamespace> | ||||
| @@ -787,7 +787,7 @@ namespace Discord.API | |||||
| } | } | ||||
| //Guilds | //Guilds | ||||
| public async Task<Guild> GetGuildAsync(ulong guildId, RequestOptions options = null) | |||||
| public async Task<Guild> GetGuildAsync(ulong guildId, bool withCounts, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | Preconditions.NotEqual(guildId, 0, nameof(guildId)); | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| @@ -795,7 +795,7 @@ namespace Discord.API | |||||
| try | try | ||||
| { | { | ||||
| var ids = new BucketIds(guildId: guildId); | var ids = new BucketIds(guildId: guildId); | ||||
| return await SendAsync<Guild>("GET", () => $"guilds/{guildId}", ids, options: options).ConfigureAwait(false); | |||||
| return await SendAsync<Guild>("GET", () => $"guilds/{guildId}?with_counts={(withCounts ? "true" : "false")}", ids, options: options).ConfigureAwait(false); | |||||
| } | } | ||||
| catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; } | catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; } | ||||
| } | } | ||||
| @@ -853,10 +853,11 @@ namespace Discord.API | |||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | Preconditions.NotEqual(guildId, 0, nameof(guildId)); | ||||
| Preconditions.NotNull(args, nameof(args)); | Preconditions.NotNull(args, nameof(args)); | ||||
| Preconditions.AtLeast(args.Days, 1, nameof(args.Days)); | Preconditions.AtLeast(args.Days, 1, nameof(args.Days)); | ||||
| string endpointRoleIds = args.IncludeRoleIds?.Length > 0 ? $"&include_roles={string.Join(",", args.IncludeRoleIds)}" : ""; | |||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| var ids = new BucketIds(guildId: guildId); | var ids = new BucketIds(guildId: guildId); | ||||
| return await SendAsync<GetGuildPruneCountResponse>("GET", () => $"guilds/{guildId}/prune?days={args.Days}", ids, options: options).ConfigureAwait(false); | |||||
| return await SendAsync<GetGuildPruneCountResponse>("GET", () => $"guilds/{guildId}/prune?days={args.Days}{endpointRoleIds}", ids, options: options).ConfigureAwait(false); | |||||
| } | } | ||||
| //Guild Bans | //Guild Bans | ||||
| @@ -937,6 +938,32 @@ namespace Discord.API | |||||
| return await SendJsonAsync<GuildEmbed>("PATCH", () => $"guilds/{guildId}/embed", args, ids, options: options).ConfigureAwait(false); | return await SendJsonAsync<GuildEmbed>("PATCH", () => $"guilds/{guildId}/embed", args, ids, options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| //Guild Widget | |||||
| /// <exception cref="ArgumentException"><paramref name="guildId"/> must not be equal to zero.</exception> | |||||
| public async Task<GuildWidget> GetGuildWidgetAsync(ulong guildId, RequestOptions options = null) | |||||
| { | |||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||||
| options = RequestOptions.CreateOrClone(options); | |||||
| try | |||||
| { | |||||
| var ids = new BucketIds(guildId: guildId); | |||||
| return await SendAsync<GuildWidget>("GET", () => $"guilds/{guildId}/widget", ids, options: options).ConfigureAwait(false); | |||||
| } | |||||
| catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; } | |||||
| } | |||||
| /// <exception cref="ArgumentException"><paramref name="guildId"/> must not be equal to zero.</exception> | |||||
| /// <exception cref="ArgumentNullException"><paramref name="args"/> must not be <see langword="null"/>.</exception> | |||||
| public async Task<GuildWidget> ModifyGuildWidgetAsync(ulong guildId, Rest.ModifyGuildWidgetParams args, RequestOptions options = null) | |||||
| { | |||||
| Preconditions.NotNull(args, nameof(args)); | |||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||||
| options = RequestOptions.CreateOrClone(options); | |||||
| var ids = new BucketIds(guildId: guildId); | |||||
| return await SendJsonAsync<GuildWidget>("PATCH", () => $"guilds/{guildId}/widget", args, ids, options: options).ConfigureAwait(false); | |||||
| } | |||||
| //Guild Integrations | //Guild Integrations | ||||
| /// <exception cref="ArgumentException"><paramref name="guildId"/> must not be equal to zero.</exception> | /// <exception cref="ArgumentException"><paramref name="guildId"/> must not be equal to zero.</exception> | ||||
| public async Task<IReadOnlyCollection<Integration>> GetGuildIntegrationsAsync(ulong guildId, RequestOptions options = null) | public async Task<IReadOnlyCollection<Integration>> GetGuildIntegrationsAsync(ulong guildId, RequestOptions options = null) | ||||
| @@ -1,3 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Collections.Immutable; | using System.Collections.Immutable; | ||||
| using System.IO; | using System.IO; | ||||
| @@ -28,10 +29,10 @@ namespace Discord.Rest | |||||
| internal DiscordRestClient(DiscordRestConfig config, API.DiscordRestApiClient api) : base(config, api) { } | internal DiscordRestClient(DiscordRestConfig config, API.DiscordRestApiClient api) : base(config, api) { } | ||||
| private static API.DiscordRestApiClient CreateApiClient(DiscordRestConfig config) | private static API.DiscordRestApiClient CreateApiClient(DiscordRestConfig config) | ||||
| => new API.DiscordRestApiClient(config.RestClientProvider, | |||||
| DiscordRestConfig.UserAgent, | |||||
| rateLimitPrecision: config.RateLimitPrecision, | |||||
| useSystemClock: config.UseSystemClock); | |||||
| => new API.DiscordRestApiClient(config.RestClientProvider, | |||||
| DiscordRestConfig.UserAgent, | |||||
| rateLimitPrecision: config.RateLimitPrecision, | |||||
| useSystemClock: config.UseSystemClock); | |||||
| internal override void Dispose(bool disposing) | internal override void Dispose(bool disposing) | ||||
| { | { | ||||
| @@ -76,15 +77,22 @@ namespace Discord.Rest | |||||
| => ClientHelper.GetInviteAsync(this, inviteId, options); | => ClientHelper.GetInviteAsync(this, inviteId, options); | ||||
| public Task<RestGuild> GetGuildAsync(ulong id, RequestOptions options = null) | public Task<RestGuild> GetGuildAsync(ulong id, RequestOptions options = null) | ||||
| => ClientHelper.GetGuildAsync(this, id, options); | |||||
| => ClientHelper.GetGuildAsync(this, id, false, options); | |||||
| public Task<RestGuild> GetGuildAsync(ulong id, bool withCounts, RequestOptions options = null) | |||||
| => ClientHelper.GetGuildAsync(this, id, withCounts, options); | |||||
| [Obsolete("This endpoint is deprecated, use GetGuildWidgetAsync instead.")] | |||||
| public Task<RestGuildEmbed?> GetGuildEmbedAsync(ulong id, RequestOptions options = null) | public Task<RestGuildEmbed?> GetGuildEmbedAsync(ulong id, RequestOptions options = null) | ||||
| => ClientHelper.GetGuildEmbedAsync(this, id, options); | => ClientHelper.GetGuildEmbedAsync(this, id, options); | ||||
| public Task<RestGuildWidget?> GetGuildWidgetAsync(ulong id, RequestOptions options = null) | |||||
| => ClientHelper.GetGuildWidgetAsync(this, id, options); | |||||
| public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(RequestOptions options = null) | public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(RequestOptions options = null) | ||||
| => ClientHelper.GetGuildSummariesAsync(this, null, null, options); | => ClientHelper.GetGuildSummariesAsync(this, null, null, options); | ||||
| public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(ulong fromGuildId, int limit, RequestOptions options = null) | public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(ulong fromGuildId, int limit, RequestOptions options = null) | ||||
| => ClientHelper.GetGuildSummariesAsync(this, fromGuildId, limit, options); | => ClientHelper.GetGuildSummariesAsync(this, fromGuildId, limit, options); | ||||
| public Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(RequestOptions options = null) | ||||
| => ClientHelper.GetGuildsAsync(this, options); | |||||
| => ClientHelper.GetGuildsAsync(this, false, options); | |||||
| public Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(bool withCounts, RequestOptions options = null) | |||||
| => ClientHelper.GetGuildsAsync(this, withCounts, options); | |||||
| public Task<RestGuild> CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon = null, RequestOptions options = null) | public Task<RestGuild> CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon = null, RequestOptions options = null) | ||||
| => ClientHelper.CreateGuildAsync(this, name, region, jpegIcon, options); | => ClientHelper.CreateGuildAsync(this, name, region, jpegIcon, options); | ||||
| @@ -6,7 +6,6 @@ using System.IO; | |||||
| using System.Linq; | using System.Linq; | ||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
| using Model = Discord.API.Channel; | using Model = Discord.API.Channel; | ||||
| using UserModel = Discord.API.User; | |||||
| namespace Discord.Rest | namespace Discord.Rest | ||||
| { | { | ||||
| @@ -130,7 +129,7 @@ namespace Discord.Rest | |||||
| var model = await client.ApiClient.GetChannelMessageAsync(channel.Id, id, options).ConfigureAwait(false); | var model = await client.ApiClient.GetChannelMessageAsync(channel.Id, id, options).ConfigureAwait(false); | ||||
| if (model == null) | if (model == null) | ||||
| return null; | return null; | ||||
| var author = GetAuthor(client, guild, model.Author.Value, model.WebhookId.ToNullable()); | |||||
| var author = MessageHelper.GetAuthor(client, guild, model.Author.Value, model.WebhookId.ToNullable()); | |||||
| return RestMessage.Create(client, channel, author, model); | return RestMessage.Create(client, channel, author, model); | ||||
| } | } | ||||
| public static IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessageChannel channel, BaseDiscordClient client, | public static IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessageChannel channel, BaseDiscordClient client, | ||||
| @@ -165,7 +164,7 @@ namespace Discord.Rest | |||||
| var builder = ImmutableArray.CreateBuilder<RestMessage>(); | var builder = ImmutableArray.CreateBuilder<RestMessage>(); | ||||
| foreach (var model in models) | foreach (var model in models) | ||||
| { | { | ||||
| var author = GetAuthor(client, guild, model.Author.Value, model.WebhookId.ToNullable()); | |||||
| var author = MessageHelper.GetAuthor(client, guild, model.Author.Value, model.WebhookId.ToNullable()); | |||||
| builder.Add(RestMessage.Create(client, channel, author, model)); | builder.Add(RestMessage.Create(client, channel, author, model)); | ||||
| } | } | ||||
| return builder.ToImmutable(); | return builder.ToImmutable(); | ||||
| @@ -193,7 +192,7 @@ namespace Discord.Rest | |||||
| var builder = ImmutableArray.CreateBuilder<RestMessage>(); | var builder = ImmutableArray.CreateBuilder<RestMessage>(); | ||||
| foreach (var model in models) | foreach (var model in models) | ||||
| { | { | ||||
| var author = GetAuthor(client, guild, model.Author.Value, model.WebhookId.ToNullable()); | |||||
| var author = MessageHelper.GetAuthor(client, guild, model.Author.Value, model.WebhookId.ToNullable()); | |||||
| builder.Add(RestMessage.Create(client, channel, author, model)); | builder.Add(RestMessage.Create(client, channel, author, model)); | ||||
| } | } | ||||
| return builder.ToImmutable(); | return builder.ToImmutable(); | ||||
| @@ -201,7 +200,7 @@ namespace Discord.Rest | |||||
| /// <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> | ||||
| public static async Task<RestUserMessage> SendMessageAsync(IMessageChannel channel, BaseDiscordClient client, | public static async Task<RestUserMessage> SendMessageAsync(IMessageChannel channel, BaseDiscordClient client, | ||||
| string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, RequestOptions options) | |||||
| string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, RequestOptions options) | |||||
| { | { | ||||
| Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); | Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); | ||||
| 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."); | ||||
| @@ -222,7 +221,7 @@ namespace Discord.Rest | |||||
| } | } | ||||
| } | } | ||||
| var args = new CreateMessageParams(text) { IsTTS = isTTS, Embed = embed?.ToModel(), AllowedMentions = allowedMentions?.ToModel() }; | |||||
| var args = new CreateMessageParams(text) { IsTTS = isTTS, Embed = embed?.ToModel(), AllowedMentions = allowedMentions?.ToModel(), MessageReference = messageReference?.ToModel() }; | |||||
| var model = await client.ApiClient.CreateMessageAsync(channel.Id, args, options).ConfigureAwait(false); | var model = await client.ApiClient.CreateMessageAsync(channel.Id, args, options).ConfigureAwait(false); | ||||
| return RestUserMessage.Create(client, channel, client.CurrentUser, model); | return RestUserMessage.Create(client, channel, client.CurrentUser, model); | ||||
| } | } | ||||
| @@ -252,16 +251,16 @@ namespace Discord.Rest | |||||
| /// <exception cref="IOException">An I/O error occurred while opening the file.</exception> | /// <exception cref="IOException">An I/O error occurred while opening the file.</exception> | ||||
| /// <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> | ||||
| public static async Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client, | public static async Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client, | ||||
| string filePath, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, RequestOptions options, bool isSpoiler) | |||||
| string filePath, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, RequestOptions options, bool isSpoiler) | |||||
| { | { | ||||
| string filename = Path.GetFileName(filePath); | string filename = Path.GetFileName(filePath); | ||||
| using (var file = File.OpenRead(filePath)) | using (var file = File.OpenRead(filePath)) | ||||
| return await SendFileAsync(channel, client, file, filename, text, isTTS, embed, allowedMentions, options, isSpoiler).ConfigureAwait(false); | |||||
| return await SendFileAsync(channel, client, file, filename, text, isTTS, embed, allowedMentions, messageReference, options, isSpoiler).ConfigureAwait(false); | |||||
| } | } | ||||
| /// <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> | ||||
| public static async Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client, | public static async Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client, | ||||
| Stream stream, string filename, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, RequestOptions options, bool isSpoiler) | |||||
| Stream stream, string filename, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, RequestOptions options, bool isSpoiler) | |||||
| { | { | ||||
| Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); | Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); | ||||
| 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."); | ||||
| @@ -282,7 +281,7 @@ namespace Discord.Rest | |||||
| } | } | ||||
| } | } | ||||
| var args = new UploadFileParams(stream) { Filename = filename, Content = text, IsTTS = isTTS, Embed = embed?.ToModel() ?? Optional<API.Embed>.Unspecified, AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified, IsSpoiler = isSpoiler }; | |||||
| var args = new UploadFileParams(stream) { Filename = filename, Content = text, IsTTS = isTTS, Embed = embed?.ToModel() ?? Optional<API.Embed>.Unspecified, AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified, MessageReference = messageReference?.ToModel() ?? Optional<API.MessageReference>.Unspecified, IsSpoiler = isSpoiler }; | |||||
| var model = await client.ApiClient.UploadFileAsync(channel.Id, args, options).ConfigureAwait(false); | var model = await client.ApiClient.UploadFileAsync(channel.Id, args, options).ConfigureAwait(false); | ||||
| return RestUserMessage.Create(client, channel, client.CurrentUser, model); | return RestUserMessage.Create(client, channel, client.CurrentUser, model); | ||||
| } | } | ||||
| @@ -450,16 +449,5 @@ namespace Discord.Rest | |||||
| }; | }; | ||||
| await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false); | await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false); | ||||
| } | } | ||||
| //Helpers | |||||
| private static IUser GetAuthor(BaseDiscordClient client, IGuild guild, UserModel model, ulong? webhookId) | |||||
| { | |||||
| IUser author = null; | |||||
| if (guild != null) | |||||
| author = guild.GetUserAsync(model.Id, CacheMode.CacheOnly).Result; | |||||
| if (author == null) | |||||
| author = RestUser.Create(client, guild, model, webhookId); | |||||
| return author; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -24,17 +24,18 @@ namespace Discord.Rest | |||||
| /// Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>. | /// Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>. | ||||
| /// If <c>null</c>, all mentioned roles and users will be notified. | /// If <c>null</c>, all mentioned roles and users will be notified. | ||||
| /// </param> | /// </param> | ||||
| /// <param name="messageReference">The message references to be included. Used to reply to specific messages.</param> | |||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents an asynchronous send operation for delivering the message. The task result | /// A task that represents an asynchronous send operation for delivering the message. The task result | ||||
| /// contains the sent message. | /// contains the sent message. | ||||
| /// </returns> | /// </returns> | ||||
| new Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null); | |||||
| new Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null); | |||||
| /// <summary> | /// <summary> | ||||
| /// Sends a file to this message channel with an optional caption. | /// Sends a file to this message channel with an optional caption. | ||||
| /// </summary> | /// </summary> | ||||
| /// <remarks> | /// <remarks> | ||||
| /// This method follows the same behavior as described in | /// This method follows the same behavior as described in | ||||
| /// <see cref="IMessageChannel.SendFileAsync(string, string, bool, Embed, RequestOptions, bool, AllowedMentions)"/>. Please visit | |||||
| /// <see cref="IMessageChannel.SendFileAsync(string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference)"/>. Please visit | |||||
| /// its documentation for more details on this method. | /// its documentation for more details on this method. | ||||
| /// </remarks> | /// </remarks> | ||||
| /// <param name="filePath">The file path of the file.</param> | /// <param name="filePath">The file path of the file.</param> | ||||
| @@ -47,16 +48,17 @@ namespace Discord.Rest | |||||
| /// Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>. | /// Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>. | ||||
| /// If <c>null</c>, all mentioned roles and users will be notified. | /// If <c>null</c>, all mentioned roles and users will be notified. | ||||
| /// </param> | /// </param> | ||||
| /// <param name="messageReference">The message references to be included. Used to reply to specific messages.</param> | |||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents an asynchronous send operation for delivering the message. The task result | /// A task that represents an asynchronous send operation for delivering the message. The task result | ||||
| /// contains the sent message. | /// contains the sent message. | ||||
| /// </returns> | /// </returns> | ||||
| new Task<RestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null); | |||||
| new Task<RestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null); | |||||
| /// <summary> | /// <summary> | ||||
| /// Sends a file to this message channel with an optional caption. | /// Sends a file to this message channel with an optional caption. | ||||
| /// </summary> | /// </summary> | ||||
| /// <remarks> | /// <remarks> | ||||
| /// This method follows the same behavior as described in <see cref="IMessageChannel.SendFileAsync(Stream, string, string, bool, Embed, RequestOptions, bool, AllowedMentions)"/>. | |||||
| /// This method follows the same behavior as described in <see cref="IMessageChannel.SendFileAsync(Stream, string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference)"/>. | |||||
| /// Please visit its documentation for more details on this method. | /// Please visit its documentation for more details on this method. | ||||
| /// </remarks> | /// </remarks> | ||||
| /// <param name="stream">The <see cref="Stream" /> of the file to be sent.</param> | /// <param name="stream">The <see cref="Stream" /> of the file to be sent.</param> | ||||
| @@ -70,11 +72,12 @@ namespace Discord.Rest | |||||
| /// Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>. | /// Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>. | ||||
| /// If <c>null</c>, all mentioned roles and users will be notified. | /// If <c>null</c>, all mentioned roles and users will be notified. | ||||
| /// </param> | /// </param> | ||||
| /// <param name="messageReference">The message references to be included. Used to reply to specific messages.</param> | |||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents an asynchronous send operation for delivering the message. The task result | /// A task that represents an asynchronous send operation for delivering the message. The task result | ||||
| /// contains the sent message. | /// contains the sent message. | ||||
| /// </returns> | /// </returns> | ||||
| new Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null); | |||||
| new Task<RestUserMessage> 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); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a message from this message channel. | /// Gets a message from this message channel. | ||||
| @@ -93,8 +93,8 @@ namespace Discord.Rest | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <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> | ||||
| public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null) | |||||
| => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, options); | |||||
| public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null) | |||||
| => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <exception cref="ArgumentException"> | /// <exception cref="ArgumentException"> | ||||
| @@ -121,12 +121,12 @@ namespace Discord.Rest | |||||
| /// <exception cref="NotSupportedException"><paramref name="filePath" /> is in an invalid format.</exception> | /// <exception cref="NotSupportedException"><paramref name="filePath" /> is in an invalid format.</exception> | ||||
| /// <exception cref="IOException">An I/O error occurred while opening the file.</exception> | /// <exception cref="IOException">An I/O error occurred while opening the file.</exception> | ||||
| /// <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> | ||||
| public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null) | |||||
| => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, options, isSpoiler); | |||||
| public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null) | |||||
| => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, options, isSpoiler); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <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> | ||||
| public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null) | |||||
| => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, options, isSpoiler); | |||||
| public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null) | |||||
| => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, options, isSpoiler); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) | public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) | ||||
| @@ -200,14 +200,14 @@ namespace Discord.Rest | |||||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | ||||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions) | |||||
| => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions).ConfigureAwait(false); | |||||
| async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference) | |||||
| => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference).ConfigureAwait(false); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions) | |||||
| => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions).ConfigureAwait(false); | |||||
| async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference) | |||||
| => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference).ConfigureAwait(false); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions) | |||||
| => await SendMessageAsync(text, isTTS, embed, options, allowedMentions).ConfigureAwait(false); | |||||
| async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference) | |||||
| => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference).ConfigureAwait(false); | |||||
| //IChannel | //IChannel | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| @@ -95,8 +95,8 @@ namespace Discord.Rest | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <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> | ||||
| public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null) | |||||
| => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, options); | |||||
| public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null) | |||||
| => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <exception cref="ArgumentException"> | /// <exception cref="ArgumentException"> | ||||
| @@ -123,12 +123,12 @@ namespace Discord.Rest | |||||
| /// <exception cref="NotSupportedException"><paramref name="filePath" /> is in an invalid format.</exception> | /// <exception cref="NotSupportedException"><paramref name="filePath" /> is in an invalid format.</exception> | ||||
| /// <exception cref="IOException">An I/O error occurred while opening the file.</exception> | /// <exception cref="IOException">An I/O error occurred while opening the file.</exception> | ||||
| /// <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> | ||||
| public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null) | |||||
| => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, options, isSpoiler); | |||||
| public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null) | |||||
| => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, options, isSpoiler); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <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> | ||||
| public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null) | |||||
| => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, options, isSpoiler); | |||||
| public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null) | |||||
| => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, options, isSpoiler); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task TriggerTypingAsync(RequestOptions options = null) | public Task TriggerTypingAsync(RequestOptions options = null) | ||||
| @@ -178,14 +178,14 @@ namespace Discord.Rest | |||||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | ||||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | ||||
| async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions) | |||||
| => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions).ConfigureAwait(false); | |||||
| async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference) | |||||
| => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference).ConfigureAwait(false); | |||||
| async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions) | |||||
| => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions).ConfigureAwait(false); | |||||
| async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference) | |||||
| => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference).ConfigureAwait(false); | |||||
| async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions) | |||||
| => await SendMessageAsync(text, isTTS, embed, options, allowedMentions).ConfigureAwait(false); | |||||
| async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference) | |||||
| => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference).ConfigureAwait(false); | |||||
| //IAudioChannel | //IAudioChannel | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| @@ -12,7 +12,7 @@ namespace Discord.Rest | |||||
| /// Represents a REST-based news channel in a guild that has the same properties as a <see cref="RestTextChannel"/>. | /// Represents a REST-based news channel in a guild that has the same properties as a <see cref="RestTextChannel"/>. | ||||
| /// </summary> | /// </summary> | ||||
| [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
| public class RestNewsChannel : RestTextChannel | |||||
| public class RestNewsChannel : RestTextChannel, INewsChannel | |||||
| { | { | ||||
| internal RestNewsChannel(BaseDiscordClient discord, IGuild guild, ulong id) | internal RestNewsChannel(BaseDiscordClient discord, IGuild guild, ulong id) | ||||
| :base(discord, guild, id) | :base(discord, guild, id) | ||||
| @@ -102,8 +102,8 @@ namespace Discord.Rest | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <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> | ||||
| public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null) | |||||
| => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, options); | |||||
| public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null) | |||||
| => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <exception cref="ArgumentException"> | /// <exception cref="ArgumentException"> | ||||
| @@ -130,13 +130,13 @@ namespace Discord.Rest | |||||
| /// <exception cref="NotSupportedException"><paramref name="filePath" /> is in an invalid format.</exception> | /// <exception cref="NotSupportedException"><paramref name="filePath" /> is in an invalid format.</exception> | ||||
| /// <exception cref="IOException">An I/O error occurred while opening the file.</exception> | /// <exception cref="IOException">An I/O error occurred while opening the file.</exception> | ||||
| /// <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> | ||||
| public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null) | |||||
| => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, options, isSpoiler); | |||||
| public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null) | |||||
| => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, options, isSpoiler); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <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> | ||||
| public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null) | |||||
| => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, options, isSpoiler); | |||||
| public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null) | |||||
| => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, options, isSpoiler); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) | public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) | ||||
| @@ -267,15 +267,15 @@ namespace Discord.Rest | |||||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions) | |||||
| => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions).ConfigureAwait(false); | |||||
| async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference) | |||||
| => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference).ConfigureAwait(false); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions) | |||||
| => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions).ConfigureAwait(false); | |||||
| async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference) | |||||
| => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference).ConfigureAwait(false); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions) | |||||
| => await SendMessageAsync(text, isTTS, embed, options, allowedMentions).ConfigureAwait(false); | |||||
| async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference) | |||||
| => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference).ConfigureAwait(false); | |||||
| //IGuildChannel | //IGuildChannel | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| @@ -5,6 +5,7 @@ using System.Collections.Immutable; | |||||
| using System.Linq; | using System.Linq; | ||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
| using EmbedModel = Discord.API.GuildEmbed; | using EmbedModel = Discord.API.GuildEmbed; | ||||
| using WidgetModel = Discord.API.GuildWidget; | |||||
| using Model = Discord.API.Guild; | using Model = Discord.API.Guild; | ||||
| using RoleModel = Discord.API.Role; | using RoleModel = Discord.API.Role; | ||||
| using ImageModel = Discord.API.Image; | using ImageModel = Discord.API.Image; | ||||
| @@ -99,6 +100,27 @@ namespace Discord.Rest | |||||
| return await client.ApiClient.ModifyGuildEmbedAsync(guild.Id, apiArgs, options).ConfigureAwait(false); | return await client.ApiClient.ModifyGuildEmbedAsync(guild.Id, apiArgs, options).ConfigureAwait(false); | ||||
| } | } | ||||
| /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | |||||
| public static async Task<WidgetModel> ModifyWidgetAsync(IGuild guild, BaseDiscordClient client, | |||||
| Action<GuildWidgetProperties> func, RequestOptions options) | |||||
| { | |||||
| if (func == null) | |||||
| throw new ArgumentNullException(nameof(func)); | |||||
| var args = new GuildWidgetProperties(); | |||||
| func(args); | |||||
| var apiArgs = new API.Rest.ModifyGuildWidgetParams | |||||
| { | |||||
| Enabled = args.Enabled | |||||
| }; | |||||
| if (args.Channel.IsSpecified) | |||||
| apiArgs.ChannelId = args.Channel.Value?.Id; | |||||
| else if (args.ChannelId.IsSpecified) | |||||
| apiArgs.ChannelId = args.ChannelId.Value; | |||||
| return await client.ApiClient.ModifyGuildWidgetAsync(guild.Id, apiArgs, options).ConfigureAwait(false); | |||||
| } | |||||
| public static async Task ReorderChannelsAsync(IGuild guild, BaseDiscordClient client, | public static async Task ReorderChannelsAsync(IGuild guild, BaseDiscordClient client, | ||||
| IEnumerable<ReorderChannelProperties> args, RequestOptions options) | IEnumerable<ReorderChannelProperties> args, RequestOptions options) | ||||
| { | { | ||||
| @@ -404,9 +426,9 @@ namespace Discord.Rest | |||||
| ); | ); | ||||
| } | } | ||||
| public static async Task<int> PruneUsersAsync(IGuild guild, BaseDiscordClient client, | public static async Task<int> PruneUsersAsync(IGuild guild, BaseDiscordClient client, | ||||
| int days, bool simulate, RequestOptions options) | |||||
| int days, bool simulate, RequestOptions options, IEnumerable<ulong> includeRoleIds) | |||||
| { | { | ||||
| var args = new GuildPruneParams(days); | |||||
| var args = new GuildPruneParams(days, includeRoleIds?.ToArray()); | |||||
| GetGuildPruneCountResponse model; | GetGuildPruneCountResponse model; | ||||
| if (simulate) | if (simulate) | ||||
| model = await client.ApiClient.GetGuildPruneCountAsync(guild.Id, args, options).ConfigureAwait(false); | model = await client.ApiClient.GetGuildPruneCountAsync(guild.Id, args, options).ConfigureAwait(false); | ||||
| @@ -479,7 +501,7 @@ namespace Discord.Rest | |||||
| var emote = await client.ApiClient.GetGuildEmoteAsync(guild.Id, id, options).ConfigureAwait(false); | var emote = await client.ApiClient.GetGuildEmoteAsync(guild.Id, id, options).ConfigureAwait(false); | ||||
| return emote.ToEntity(); | return emote.ToEntity(); | ||||
| } | } | ||||
| public static async Task<GuildEmote> CreateEmoteAsync(IGuild guild, BaseDiscordClient client, string name, Image image, Optional<IEnumerable<IRole>> roles, | |||||
| public static async Task<GuildEmote> CreateEmoteAsync(IGuild guild, BaseDiscordClient client, string name, Image image, Optional<IEnumerable<IRole>> roles, | |||||
| RequestOptions options) | RequestOptions options) | ||||
| { | { | ||||
| var apiargs = new CreateGuildEmoteParams | var apiargs = new CreateGuildEmoteParams | ||||
| @@ -494,7 +516,7 @@ namespace Discord.Rest | |||||
| return emote.ToEntity(); | return emote.ToEntity(); | ||||
| } | } | ||||
| /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | ||||
| public static async Task<GuildEmote> ModifyEmoteAsync(IGuild guild, BaseDiscordClient client, ulong id, Action<EmoteProperties> func, | |||||
| public static async Task<GuildEmote> ModifyEmoteAsync(IGuild guild, BaseDiscordClient client, ulong id, Action<EmoteProperties> func, | |||||
| RequestOptions options) | RequestOptions options) | ||||
| { | { | ||||
| if (func == null) throw new ArgumentNullException(paramName: nameof(func)); | if (func == null) throw new ArgumentNullException(paramName: nameof(func)); | ||||
| @@ -512,7 +534,7 @@ namespace Discord.Rest | |||||
| var emote = await client.ApiClient.ModifyGuildEmoteAsync(guild.Id, id, apiargs, options).ConfigureAwait(false); | var emote = await client.ApiClient.ModifyGuildEmoteAsync(guild.Id, id, apiargs, options).ConfigureAwait(false); | ||||
| return emote.ToEntity(); | return emote.ToEntity(); | ||||
| } | } | ||||
| public static Task DeleteEmoteAsync(IGuild guild, BaseDiscordClient client, ulong id, RequestOptions options) | |||||
| public static Task DeleteEmoteAsync(IGuild guild, BaseDiscordClient client, ulong id, RequestOptions options) | |||||
| => client.ApiClient.DeleteGuildEmoteAsync(guild.Id, id, options); | => client.ApiClient.DeleteGuildEmoteAsync(guild.Id, id, options); | ||||
| } | } | ||||
| } | } | ||||
| @@ -7,6 +7,7 @@ using System.Globalization; | |||||
| using System.Linq; | using System.Linq; | ||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
| using EmbedModel = Discord.API.GuildEmbed; | using EmbedModel = Discord.API.GuildEmbed; | ||||
| using WidgetModel = Discord.API.GuildWidget; | |||||
| using Model = Discord.API.Guild; | using Model = Discord.API.Guild; | ||||
| namespace Discord.Rest | namespace Discord.Rest | ||||
| @@ -28,6 +29,8 @@ namespace Discord.Rest | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public bool IsEmbeddable { get; private set; } | public bool IsEmbeddable { get; private set; } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public bool IsWidgetEnabled { get; private set; } | |||||
| /// <inheritdoc /> | |||||
| public VerificationLevel VerificationLevel { get; private set; } | public VerificationLevel VerificationLevel { get; private set; } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public MfaLevel MfaLevel { get; private set; } | public MfaLevel MfaLevel { get; private set; } | ||||
| @@ -41,8 +44,14 @@ namespace Discord.Rest | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public ulong? EmbedChannelId { get; private set; } | public ulong? EmbedChannelId { get; private set; } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public ulong? WidgetChannelId { get; private set; } | |||||
| /// <inheritdoc /> | |||||
| public ulong? SystemChannelId { get; private set; } | public ulong? SystemChannelId { get; private set; } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public ulong? RulesChannelId { get; private set; } | |||||
| /// <inheritdoc /> | |||||
| public ulong? PublicUpdatesChannelId { get; private set; } | |||||
| /// <inheritdoc /> | |||||
| public ulong OwnerId { get; private set; } | public ulong OwnerId { get; private set; } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public string VoiceRegionId { get; private set; } | public string VoiceRegionId { get; private set; } | ||||
| @@ -50,6 +59,8 @@ namespace Discord.Rest | |||||
| public string IconId { get; private set; } | public string IconId { get; private set; } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public string SplashId { get; private set; } | public string SplashId { get; private set; } | ||||
| /// <inheritdoc /> | |||||
| public string DiscoverySplashId { get; private set; } | |||||
| internal bool Available { get; private set; } | internal bool Available { get; private set; } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public ulong? ApplicationId { get; private set; } | public ulong? ApplicationId { get; private set; } | ||||
| @@ -67,6 +78,16 @@ namespace Discord.Rest | |||||
| public int PremiumSubscriptionCount { get; private set; } | public int PremiumSubscriptionCount { get; private set; } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public string PreferredLocale { get; private set; } | public string PreferredLocale { get; private set; } | ||||
| /// <inheritdoc /> | |||||
| public int? MaxPresences { get; private set; } | |||||
| /// <inheritdoc /> | |||||
| public int? MaxMembers { get; private set; } | |||||
| /// <inheritdoc /> | |||||
| public int? MaxVideoChannelUsers { get; private set; } | |||||
| /// <inheritdoc /> | |||||
| public int? ApproximateMemberCount { get; private set; } | |||||
| /// <inheritdoc /> | |||||
| public int? ApproximatePresenceCount { get; private set; } | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public CultureInfo PreferredCulture { get; private set; } | public CultureInfo PreferredCulture { get; private set; } | ||||
| @@ -81,6 +102,8 @@ namespace Discord.Rest | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); | public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public string DiscoverySplashUrl => CDN.GetGuildDiscoverySplashUrl(Id, DiscoverySplashId); | |||||
| /// <inheritdoc /> | |||||
| public string BannerUrl => CDN.GetGuildBannerUrl(Id, BannerId); | public string BannerUrl => CDN.GetGuildBannerUrl(Id, BannerId); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -110,15 +133,24 @@ namespace Discord.Rest | |||||
| internal void Update(Model model) | internal void Update(Model model) | ||||
| { | { | ||||
| AFKChannelId = model.AFKChannelId; | AFKChannelId = model.AFKChannelId; | ||||
| EmbedChannelId = model.EmbedChannelId; | |||||
| if (model.EmbedChannelId.IsSpecified) | |||||
| EmbedChannelId = model.EmbedChannelId.Value; | |||||
| if (model.WidgetChannelId.IsSpecified) | |||||
| WidgetChannelId = model.WidgetChannelId.Value; | |||||
| SystemChannelId = model.SystemChannelId; | SystemChannelId = model.SystemChannelId; | ||||
| RulesChannelId = model.RulesChannelId; | |||||
| PublicUpdatesChannelId = model.PublicUpdatesChannelId; | |||||
| AFKTimeout = model.AFKTimeout; | AFKTimeout = model.AFKTimeout; | ||||
| IsEmbeddable = model.EmbedEnabled; | |||||
| if (model.EmbedEnabled.IsSpecified) | |||||
| IsEmbeddable = model.EmbedEnabled.Value; | |||||
| if (model.WidgetEnabled.IsSpecified) | |||||
| IsWidgetEnabled = model.WidgetEnabled.Value; | |||||
| IconId = model.Icon; | IconId = model.Icon; | ||||
| Name = model.Name; | Name = model.Name; | ||||
| OwnerId = model.OwnerId; | OwnerId = model.OwnerId; | ||||
| VoiceRegionId = model.Region; | VoiceRegionId = model.Region; | ||||
| SplashId = model.Splash; | SplashId = model.Splash; | ||||
| DiscoverySplashId = model.DiscoverySplash; | |||||
| VerificationLevel = model.VerificationLevel; | VerificationLevel = model.VerificationLevel; | ||||
| MfaLevel = model.MfaLevel; | MfaLevel = model.MfaLevel; | ||||
| DefaultMessageNotifications = model.DefaultMessageNotifications; | DefaultMessageNotifications = model.DefaultMessageNotifications; | ||||
| @@ -130,8 +162,18 @@ namespace Discord.Rest | |||||
| SystemChannelFlags = model.SystemChannelFlags; | SystemChannelFlags = model.SystemChannelFlags; | ||||
| Description = model.Description; | Description = model.Description; | ||||
| PremiumSubscriptionCount = model.PremiumSubscriptionCount.GetValueOrDefault(); | PremiumSubscriptionCount = model.PremiumSubscriptionCount.GetValueOrDefault(); | ||||
| if (model.MaxPresences.IsSpecified) | |||||
| MaxPresences = model.MaxPresences.Value ?? 25000; | |||||
| if (model.MaxMembers.IsSpecified) | |||||
| MaxMembers = model.MaxMembers.Value; | |||||
| if (model.MaxVideoChannelUsers.IsSpecified) | |||||
| MaxVideoChannelUsers = model.MaxVideoChannelUsers.Value; | |||||
| PreferredLocale = model.PreferredLocale; | PreferredLocale = model.PreferredLocale; | ||||
| PreferredCulture = new CultureInfo(PreferredLocale); | PreferredCulture = new CultureInfo(PreferredLocale); | ||||
| if (model.ApproximateMemberCount.IsSpecified) | |||||
| ApproximateMemberCount = model.ApproximateMemberCount.Value; | |||||
| if (model.ApproximatePresenceCount.IsSpecified) | |||||
| ApproximatePresenceCount = model.ApproximatePresenceCount.Value; | |||||
| if (model.Emojis != null) | if (model.Emojis != null) | ||||
| { | { | ||||
| @@ -163,17 +205,36 @@ namespace Discord.Rest | |||||
| EmbedChannelId = model.ChannelId; | EmbedChannelId = model.ChannelId; | ||||
| IsEmbeddable = model.Enabled; | IsEmbeddable = model.Enabled; | ||||
| } | } | ||||
| internal void Update(WidgetModel model) | |||||
| { | |||||
| WidgetChannelId = model.ChannelId; | |||||
| IsWidgetEnabled = model.Enabled; | |||||
| } | |||||
| //General | //General | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public async Task UpdateAsync(RequestOptions options = null) | public async Task UpdateAsync(RequestOptions options = null) | ||||
| => Update(await Discord.ApiClient.GetGuildAsync(Id, options).ConfigureAwait(false)); | |||||
| => Update(await Discord.ApiClient.GetGuildAsync(Id, false, options).ConfigureAwait(false)); | |||||
| /// <summary> | |||||
| /// Updates this object's properties with its current state. | |||||
| /// </summary> | |||||
| /// <param name="withCounts"> | |||||
| /// If true, <see cref="ApproximateMemberCount"/> and <see cref="ApproximatePresenceCount"/> | |||||
| /// will be updated as well. | |||||
| /// </param> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <remarks> | |||||
| /// If <paramref name="withCounts"/> is true, <see cref="ApproximateMemberCount"/> and | |||||
| /// <see cref="ApproximatePresenceCount"/> will be updated as well. | |||||
| /// </remarks> | |||||
| public async Task UpdateAsync(bool withCounts, RequestOptions options = null) | |||||
| => Update(await Discord.ApiClient.GetGuildAsync(Id, withCounts, options).ConfigureAwait(false)); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteAsync(RequestOptions options = null) | public Task DeleteAsync(RequestOptions options = null) | ||||
| => GuildHelper.DeleteAsync(this, Discord, options); | => GuildHelper.DeleteAsync(this, Discord, options); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | |||||
| /// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception> | |||||
| public async Task ModifyAsync(Action<GuildProperties> func, RequestOptions options = null) | public async Task ModifyAsync(Action<GuildProperties> func, RequestOptions options = null) | ||||
| { | { | ||||
| var model = await GuildHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false); | var model = await GuildHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false); | ||||
| @@ -181,7 +242,8 @@ namespace Discord.Rest | |||||
| } | } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | |||||
| /// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception> | |||||
| [Obsolete("This endpoint is deprecated, use ModifyWidgetAsync instead.")] | |||||
| public async Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null) | public async Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null) | ||||
| { | { | ||||
| var model = await GuildHelper.ModifyEmbedAsync(this, Discord, func, options).ConfigureAwait(false); | var model = await GuildHelper.ModifyEmbedAsync(this, Discord, func, options).ConfigureAwait(false); | ||||
| @@ -189,7 +251,15 @@ namespace Discord.Rest | |||||
| } | } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <exception cref="ArgumentNullException"><paramref name="args" /> is <c>null</c>.</exception> | |||||
| /// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception> | |||||
| public async Task ModifyWidgetAsync(Action<GuildWidgetProperties> func, RequestOptions options = null) | |||||
| { | |||||
| var model = await GuildHelper.ModifyWidgetAsync(this, Discord, func, options).ConfigureAwait(false); | |||||
| Update(model); | |||||
| } | |||||
| /// <inheritdoc /> | |||||
| /// <exception cref="ArgumentNullException"><paramref name="args" /> is <see langword="null"/>.</exception> | |||||
| public async Task ReorderChannelsAsync(IEnumerable<ReorderChannelProperties> args, RequestOptions options = null) | public async Task ReorderChannelsAsync(IEnumerable<ReorderChannelProperties> args, RequestOptions options = null) | ||||
| { | { | ||||
| var arr = args.ToArray(); | var arr = args.ToArray(); | ||||
| @@ -205,7 +275,7 @@ namespace Discord.Rest | |||||
| role?.Update(model); | role?.Update(model); | ||||
| } | } | ||||
| } | } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task LeaveAsync(RequestOptions options = null) | public Task LeaveAsync(RequestOptions options = null) | ||||
| => GuildHelper.LeaveAsync(this, Discord, options); | => GuildHelper.LeaveAsync(this, Discord, options); | ||||
| @@ -230,7 +300,7 @@ namespace Discord.Rest | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains a ban object, which | /// A task that represents the asynchronous get operation. The task result contains a ban object, which | ||||
| /// contains the user information and the reason for the ban; <c>null</c> if the ban entry cannot be found. | |||||
| /// contains the user information and the reason for the ban; <see langword="null"/> if the ban entry cannot be found. | |||||
| /// </returns> | /// </returns> | ||||
| public Task<RestBan> GetBanAsync(IUser user, RequestOptions options = null) | public Task<RestBan> GetBanAsync(IUser user, RequestOptions options = null) | ||||
| => GuildHelper.GetBanAsync(this, Discord, user.Id, options); | => GuildHelper.GetBanAsync(this, Discord, user.Id, options); | ||||
| @@ -241,7 +311,7 @@ namespace Discord.Rest | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains a ban object, which | /// A task that represents the asynchronous get operation. The task result contains a ban object, which | ||||
| /// contains the user information and the reason for the ban; <c>null</c> if the ban entry cannot be found. | |||||
| /// contains the user information and the reason for the ban; <see langword="null"/> if the ban entry cannot be found. | |||||
| /// </returns> | /// </returns> | ||||
| public Task<RestBan> GetBanAsync(ulong userId, RequestOptions options = null) | public Task<RestBan> GetBanAsync(ulong userId, RequestOptions options = null) | ||||
| => GuildHelper.GetBanAsync(this, Discord, userId, options); | => GuildHelper.GetBanAsync(this, Discord, userId, options); | ||||
| @@ -279,7 +349,7 @@ namespace Discord.Rest | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the generic channel | /// A task that represents the asynchronous get operation. The task result contains the generic channel | ||||
| /// associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
| /// associated with the specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| public Task<RestGuildChannel> GetChannelAsync(ulong id, RequestOptions options = null) | public Task<RestGuildChannel> GetChannelAsync(ulong id, RequestOptions options = null) | ||||
| => GuildHelper.GetChannelAsync(this, Discord, id, options); | => GuildHelper.GetChannelAsync(this, Discord, id, options); | ||||
| @@ -291,7 +361,7 @@ namespace Discord.Rest | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the text channel | /// A task that represents the asynchronous get operation. The task result contains the text channel | ||||
| /// associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
| /// associated with the specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| public async Task<RestTextChannel> GetTextChannelAsync(ulong id, RequestOptions options = null) | public async Task<RestTextChannel> GetTextChannelAsync(ulong id, RequestOptions options = null) | ||||
| { | { | ||||
| @@ -320,7 +390,7 @@ namespace Discord.Rest | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the voice channel associated | /// A task that represents the asynchronous get operation. The task result contains the voice channel associated | ||||
| /// with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
| /// with the specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| public async Task<RestVoiceChannel> GetVoiceChannelAsync(ulong id, RequestOptions options = null) | public async Task<RestVoiceChannel> GetVoiceChannelAsync(ulong id, RequestOptions options = null) | ||||
| { | { | ||||
| @@ -362,7 +432,7 @@ namespace Discord.Rest | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the voice channel that the | /// A task that represents the asynchronous get operation. The task result contains the voice channel that the | ||||
| /// AFK users will be moved to after they have idled for too long; <c>null</c> if none is set. | |||||
| /// AFK users will be moved to after they have idled for too long; <see langword="null"/> if none is set. | |||||
| /// </returns> | /// </returns> | ||||
| public async Task<RestVoiceChannel> GetAFKChannelAsync(RequestOptions options = null) | public async Task<RestVoiceChannel> GetAFKChannelAsync(RequestOptions options = null) | ||||
| { | { | ||||
| @@ -381,7 +451,7 @@ namespace Discord.Rest | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the first viewable text | /// A task that represents the asynchronous get operation. The task result contains the first viewable text | ||||
| /// channel in this guild; <c>null</c> if none is found. | |||||
| /// channel in this guild; <see langword="null"/> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| public async Task<RestTextChannel> GetDefaultChannelAsync(RequestOptions options = null) | public async Task<RestTextChannel> GetDefaultChannelAsync(RequestOptions options = null) | ||||
| { | { | ||||
| @@ -399,8 +469,9 @@ namespace Discord.Rest | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the embed channel set | /// A task that represents the asynchronous get operation. The task result contains the embed channel set | ||||
| /// within the server's widget settings; <c>null</c> if none is set. | |||||
| /// within the server's widget settings; <see langword="null"/> if none is set. | |||||
| /// </returns> | /// </returns> | ||||
| [Obsolete("This endpoint is deprecated, use GetWidgetChannelAsync instead.")] | |||||
| public async Task<RestGuildChannel> GetEmbedChannelAsync(RequestOptions options = null) | public async Task<RestGuildChannel> GetEmbedChannelAsync(RequestOptions options = null) | ||||
| { | { | ||||
| var embedId = EmbedChannelId; | var embedId = EmbedChannelId; | ||||
| @@ -410,12 +481,28 @@ namespace Discord.Rest | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets the first viewable text channel in this guild. | |||||
| /// Gets the widget channel (i.e. the channel set in the guild's widget settings) in this guild. | |||||
| /// </summary> | /// </summary> | ||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the first viewable text | |||||
| /// channel in this guild; <c>null</c> if none is found. | |||||
| /// A task that represents the asynchronous get operation. The task result contains the widget channel set | |||||
| /// within the server's widget settings; <see langword="null"/> if none is set. | |||||
| /// </returns> | |||||
| public async Task<RestGuildChannel> GetWidgetChannelAsync(RequestOptions options = null) | |||||
| { | |||||
| var widgetChannelId = WidgetChannelId; | |||||
| if (widgetChannelId.HasValue) | |||||
| return await GuildHelper.GetChannelAsync(this, Discord, widgetChannelId.Value, options).ConfigureAwait(false); | |||||
| return null; | |||||
| } | |||||
| /// <summary> | |||||
| /// Gets the text channel where guild notices such as welcome messages and boost events are posted. | |||||
| /// </summary> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A task that represents the asynchronous get operation. The task result contains the text channel | |||||
| /// where guild notices such as welcome messages and boost events are poste; <see langword="null"/> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| public async Task<RestTextChannel> GetSystemChannelAsync(RequestOptions options = null) | public async Task<RestTextChannel> GetSystemChannelAsync(RequestOptions options = null) | ||||
| { | { | ||||
| @@ -427,6 +514,45 @@ namespace Discord.Rest | |||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| /// <summary> | |||||
| /// Gets the text channel where Community guilds can display rules and/or guidelines. | |||||
| /// </summary> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A task that represents the asynchronous get operation. The task result contains the text channel | |||||
| /// where Community guilds can display rules and/or guidelines; <see langword="null"/> if none is set. | |||||
| /// </returns> | |||||
| public async Task<RestTextChannel> GetRulesChannelAsync(RequestOptions options = null) | |||||
| { | |||||
| var rulesChannelId = RulesChannelId; | |||||
| if (rulesChannelId.HasValue) | |||||
| { | |||||
| var channel = await GuildHelper.GetChannelAsync(this, Discord, rulesChannelId.Value, options).ConfigureAwait(false); | |||||
| return channel as RestTextChannel; | |||||
| } | |||||
| return null; | |||||
| } | |||||
| /// <summary> | |||||
| /// Gets the text channel channel where admins and moderators of Community guilds receive notices from Discord. | |||||
| /// </summary> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A task that represents the asynchronous get operation. The task result contains the text channel channel where | |||||
| /// admins and moderators of Community guilds receive notices from Discord; <see langword="null"/> if none is set. | |||||
| /// </returns> | |||||
| public async Task<RestTextChannel> GetPublicUpdatesChannelAsync(RequestOptions options = null) | |||||
| { | |||||
| var publicUpdatesChannelId = PublicUpdatesChannelId; | |||||
| if (publicUpdatesChannelId.HasValue) | |||||
| { | |||||
| var channel = await GuildHelper.GetChannelAsync(this, Discord, publicUpdatesChannelId.Value, options).ConfigureAwait(false); | |||||
| return channel as RestTextChannel; | |||||
| } | |||||
| return null; | |||||
| } | |||||
| /// <summary> | /// <summary> | ||||
| /// Creates a new text channel in this guild. | /// Creates a new text channel in this guild. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -458,7 +584,7 @@ namespace Discord.Rest | |||||
| /// <param name="name">The name of the new channel.</param> | /// <param name="name">The name of the new channel.</param> | ||||
| /// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param> | /// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param> | ||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <exception cref="ArgumentNullException"><paramref name="name" /> is <c>null</c>.</exception> | |||||
| /// <exception cref="ArgumentNullException"><paramref name="name" /> is <see langword="null"/>.</exception> | |||||
| /// <returns> | /// <returns> | ||||
| /// The created voice channel. | /// The created voice channel. | ||||
| /// </returns> | /// </returns> | ||||
| @@ -470,7 +596,7 @@ namespace Discord.Rest | |||||
| /// <param name="name">The name of the new channel.</param> | /// <param name="name">The name of the new channel.</param> | ||||
| /// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param> | /// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param> | ||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <exception cref="ArgumentNullException"><paramref name="name" /> is <c>null</c>.</exception> | |||||
| /// <exception cref="ArgumentNullException"><paramref name="name" /> is <see langword="null"/>.</exception> | |||||
| /// <returns> | /// <returns> | ||||
| /// The created category channel. | /// The created category channel. | ||||
| /// </returns> | /// </returns> | ||||
| @@ -521,7 +647,7 @@ namespace Discord.Rest | |||||
| /// </summary> | /// </summary> | ||||
| /// <param name="id">The snowflake identifier for the role.</param> | /// <param name="id">The snowflake identifier for the role.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A role that is associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
| /// A role that is associated with the specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| public RestRole GetRole(ulong id) | public RestRole GetRole(ulong id) | ||||
| { | { | ||||
| @@ -585,7 +711,7 @@ namespace Discord.Rest | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the guild user | /// A task that represents the asynchronous get operation. The task result contains the guild user | ||||
| /// associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
| /// associated with the specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| public Task<RestGuildUser> GetUserAsync(ulong id, RequestOptions options = null) | public Task<RestGuildUser> GetUserAsync(ulong id, RequestOptions options = null) | ||||
| => GuildHelper.GetUserAsync(this, Discord, id, options); | => GuildHelper.GetUserAsync(this, Discord, id, options); | ||||
| @@ -631,8 +757,8 @@ namespace Discord.Rest | |||||
| /// A task that represents the asynchronous prune operation. The task result contains the number of users to | /// A task that represents the asynchronous prune operation. The task result contains the number of users to | ||||
| /// be or has been removed from this guild. | /// be or has been removed from this guild. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<int> PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null) | |||||
| => GuildHelper.PruneUsersAsync(this, Discord, days, simulate, options); | |||||
| public Task<int> PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null, IEnumerable<ulong> includeRoleIds = null) | |||||
| => GuildHelper.PruneUsersAsync(this, Discord, days, simulate, options, includeRoleIds); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of users in this guild that the name or nickname starts with the | /// Gets a collection of users in this guild that the name or nickname starts with the | ||||
| @@ -675,7 +801,7 @@ namespace Discord.Rest | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous get operation. The task result contains the webhook with the | /// A task that represents the asynchronous get operation. The task result contains the webhook with the | ||||
| /// specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
| /// specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||||
| /// </returns> | /// </returns> | ||||
| public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null) | public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null) | ||||
| => GuildHelper.GetWebhookAsync(this, Discord, id, options); | => GuildHelper.GetWebhookAsync(this, Discord, id, options); | ||||
| @@ -708,7 +834,7 @@ namespace Discord.Rest | |||||
| public Task<GuildEmote> CreateEmoteAsync(string name, Image image, Optional<IEnumerable<IRole>> roles = default(Optional<IEnumerable<IRole>>), RequestOptions options = null) | public Task<GuildEmote> CreateEmoteAsync(string name, Image image, Optional<IEnumerable<IRole>> roles = default(Optional<IEnumerable<IRole>>), RequestOptions options = null) | ||||
| => GuildHelper.CreateEmoteAsync(this, Discord, name, image, roles, options); | => GuildHelper.CreateEmoteAsync(this, Discord, name, image, roles, options); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | |||||
| /// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception> | |||||
| public Task<GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action<EmoteProperties> func, RequestOptions options = null) | public Task<GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action<EmoteProperties> func, RequestOptions options = null) | ||||
| => GuildHelper.ModifyEmoteAsync(this, Discord, emote.Id, func, options); | => GuildHelper.ModifyEmoteAsync(this, Discord, emote.Id, func, options); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| @@ -808,6 +934,7 @@ namespace Discord.Rest | |||||
| return null; | return null; | ||||
| } | } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| [Obsolete("This endpoint is deprecated, use GetWidgetChannelAsync instead.")] | |||||
| async Task<IGuildChannel> IGuild.GetEmbedChannelAsync(CacheMode mode, RequestOptions options) | async Task<IGuildChannel> IGuild.GetEmbedChannelAsync(CacheMode mode, RequestOptions options) | ||||
| { | { | ||||
| if (mode == CacheMode.AllowDownload) | if (mode == CacheMode.AllowDownload) | ||||
| @@ -816,6 +943,14 @@ namespace Discord.Rest | |||||
| return null; | return null; | ||||
| } | } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IGuildChannel> IGuild.GetWidgetChannelAsync(CacheMode mode, RequestOptions options) | |||||
| { | |||||
| if (mode == CacheMode.AllowDownload) | |||||
| return await GetWidgetChannelAsync(options).ConfigureAwait(false); | |||||
| else | |||||
| return null; | |||||
| } | |||||
| /// <inheritdoc /> | |||||
| async Task<ITextChannel> IGuild.GetSystemChannelAsync(CacheMode mode, RequestOptions options) | async Task<ITextChannel> IGuild.GetSystemChannelAsync(CacheMode mode, RequestOptions options) | ||||
| { | { | ||||
| if (mode == CacheMode.AllowDownload) | if (mode == CacheMode.AllowDownload) | ||||
| @@ -824,6 +959,22 @@ namespace Discord.Rest | |||||
| return null; | return null; | ||||
| } | } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<ITextChannel> IGuild.GetRulesChannelAsync(CacheMode mode, RequestOptions options) | |||||
| { | |||||
| if (mode == CacheMode.AllowDownload) | |||||
| return await GetRulesChannelAsync(options).ConfigureAwait(false); | |||||
| else | |||||
| return null; | |||||
| } | |||||
| /// <inheritdoc /> | |||||
| async Task<ITextChannel> IGuild.GetPublicUpdatesChannelAsync(CacheMode mode, RequestOptions options) | |||||
| { | |||||
| if (mode == CacheMode.AllowDownload) | |||||
| return await GetPublicUpdatesChannelAsync(options).ConfigureAwait(false); | |||||
| else | |||||
| return null; | |||||
| } | |||||
| /// <inheritdoc /> | |||||
| async Task<ITextChannel> IGuild.CreateTextChannelAsync(string name, Action<TextChannelProperties> func, RequestOptions options) | async Task<ITextChannel> IGuild.CreateTextChannelAsync(string name, Action<TextChannelProperties> func, RequestOptions options) | ||||
| => await CreateTextChannelAsync(name, func, options).ConfigureAwait(false); | => await CreateTextChannelAsync(name, func, options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| @@ -0,0 +1,25 @@ | |||||
| using System.Diagnostics; | |||||
| using Model = Discord.API.GuildWidget; | |||||
| namespace Discord.Rest | |||||
| { | |||||
| [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | |||||
| public struct RestGuildWidget | |||||
| { | |||||
| public bool IsEnabled { get; private set; } | |||||
| public ulong? ChannelId { get; private set; } | |||||
| internal RestGuildWidget(bool isEnabled, ulong? channelId) | |||||
| { | |||||
| ChannelId = channelId; | |||||
| IsEnabled = isEnabled; | |||||
| } | |||||
| internal static RestGuildWidget Create(Model model) | |||||
| { | |||||
| return new RestGuildWidget(model.Enabled, model.ChannelId); | |||||
| } | |||||
| public override string ToString() => ChannelId?.ToString() ?? "Unknown"; | |||||
| private string DebuggerDisplay => $"{ChannelId} ({(IsEnabled ? "Enabled" : "Disabled")})"; | |||||
| } | |||||
| } | |||||
| @@ -21,6 +21,12 @@ namespace Discord.Rest | |||||
| public ulong ChannelId { get; private set; } | public ulong ChannelId { get; private set; } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public ulong? GuildId { get; private set; } | public ulong? GuildId { get; private set; } | ||||
| /// <inheritdoc /> | |||||
| public IUser Inviter { get; private set; } | |||||
| /// <inheritdoc /> | |||||
| public IUser TargetUser { get; private set; } | |||||
| /// <inheritdoc /> | |||||
| public TargetUserType TargetUserType { get; private set; } | |||||
| internal IChannel Channel { get; } | internal IChannel Channel { get; } | ||||
| internal IGuild Guild { get; } | internal IGuild Guild { get; } | ||||
| @@ -50,6 +56,9 @@ namespace Discord.Rest | |||||
| MemberCount = model.MemberCount.IsSpecified ? model.MemberCount.Value : null; | MemberCount = model.MemberCount.IsSpecified ? model.MemberCount.Value : null; | ||||
| PresenceCount = model.PresenceCount.IsSpecified ? model.PresenceCount.Value : null; | PresenceCount = model.PresenceCount.IsSpecified ? model.PresenceCount.Value : null; | ||||
| ChannelType = (ChannelType)model.Channel.Type; | ChannelType = (ChannelType)model.Channel.Type; | ||||
| Inviter = model.Inviter.IsSpecified ? RestUser.Create(Discord, model.Inviter.Value) : null; | |||||
| TargetUser = model.TargetUser.IsSpecified ? RestUser.Create(Discord, model.TargetUser.Value) : null; | |||||
| TargetUserType = model.TargetUserType.IsSpecified ? model.TargetUserType.Value : TargetUserType.Undefined; | |||||
| } | } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| @@ -6,9 +6,10 @@ namespace Discord.Rest | |||||
| /// <summary> Represents additional information regarding the REST-based invite object. </summary> | /// <summary> Represents additional information regarding the REST-based invite object. </summary> | ||||
| public class RestInviteMetadata : RestInvite, IInviteMetadata | public class RestInviteMetadata : RestInvite, IInviteMetadata | ||||
| { | { | ||||
| private long? _createdAtTicks; | |||||
| private long _createdAtTicks; | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| [Obsolete("This property doesn't exist anymore and shouldn't be used.")] | |||||
| public bool IsRevoked { get; private set; } | public bool IsRevoked { get; private set; } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public bool IsTemporary { get; private set; } | public bool IsTemporary { get; private set; } | ||||
| @@ -18,10 +19,6 @@ namespace Discord.Rest | |||||
| public int? MaxUses { get; private set; } | public int? MaxUses { get; private set; } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public int? Uses { get; private set; } | public int? Uses { get; private set; } | ||||
| /// <summary> | |||||
| /// Gets the user that created this invite. | |||||
| /// </summary> | |||||
| public RestUser Inviter { get; private set; } | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public DateTimeOffset? CreatedAt => DateTimeUtils.FromTicks(_createdAtTicks); | public DateTimeOffset? CreatedAt => DateTimeUtils.FromTicks(_createdAtTicks); | ||||
| @@ -39,16 +36,11 @@ namespace Discord.Rest | |||||
| internal void Update(Model model) | internal void Update(Model model) | ||||
| { | { | ||||
| base.Update(model); | base.Update(model); | ||||
| Inviter = model.Inviter != null ? RestUser.Create(Discord, model.Inviter) : null; | |||||
| IsRevoked = model.Revoked; | |||||
| IsTemporary = model.Temporary; | IsTemporary = model.Temporary; | ||||
| MaxAge = model.MaxAge.IsSpecified ? model.MaxAge.Value : (int?)null; | |||||
| MaxUses = model.MaxUses.IsSpecified ? model.MaxUses.Value : (int?)null; | |||||
| Uses = model.Uses.IsSpecified ? model.Uses.Value : (int?)null; | |||||
| _createdAtTicks = model.CreatedAt.IsSpecified ? model.CreatedAt.Value.UtcTicks : (long?)null; | |||||
| MaxAge = model.MaxAge; | |||||
| MaxUses = model.MaxUses; | |||||
| Uses = model.Uses; | |||||
| _createdAtTicks = model.CreatedAt.UtcTicks; | |||||
| } | } | ||||
| /// <inheritdoc /> | |||||
| IUser IInviteMetadata.Inviter => Inviter; | |||||
| } | } | ||||
| } | } | ||||
| @@ -3,7 +3,7 @@ using Model = Discord.API.Attachment; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| /// <inheritdoc/> | |||||
| /// <inheritdoc cref="IAttachment"/> | |||||
| [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
| public class Attachment : IAttachment | public class Attachment : IAttachment | ||||
| { | { | ||||