From a4d32d366d1526562ed3cf074e412161ef5ebe03 Mon Sep 17 00:00:00 2001 From: Paulo Date: Sun, 20 Dec 2020 07:09:44 -0300 Subject: [PATCH 01/21] fix: IMessage.Embeds docs remarks --- src/Discord.Net.Core/Entities/Messages/IMessage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Discord.Net.Core/Entities/Messages/IMessage.cs b/src/Discord.Net.Core/Entities/Messages/IMessage.cs index 35458d87d..1f3f5b945 100644 --- a/src/Discord.Net.Core/Entities/Messages/IMessage.cs +++ b/src/Discord.Net.Core/Entities/Messages/IMessage.cs @@ -92,10 +92,10 @@ namespace Discord /// Gets all embeds included in this message. /// /// - /// /// 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 /// are generated; however, only one can be featured. + /// /// /// A read-only collection of embed objects. /// From 4a7f8fec937f296bfdbdf60d4ed924e6897f9a75 Mon Sep 17 00:00:00 2001 From: Paulo Date: Sun, 20 Dec 2020 07:37:32 -0300 Subject: [PATCH 02/21] fix: Move and fix internal AllowedMentions object (#1727) --- .../{Entities/Messages => API/Common}/AllowedMentions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/Discord.Net.Rest/{Entities/Messages => API/Common}/AllowedMentions.cs (92%) diff --git a/src/Discord.Net.Rest/Entities/Messages/AllowedMentions.cs b/src/Discord.Net.Rest/API/Common/AllowedMentions.cs similarity index 92% rename from src/Discord.Net.Rest/Entities/Messages/AllowedMentions.cs rename to src/Discord.Net.Rest/API/Common/AllowedMentions.cs index 8b8870be2..7737a464f 100644 --- a/src/Discord.Net.Rest/Entities/Messages/AllowedMentions.cs +++ b/src/Discord.Net.Rest/API/Common/AllowedMentions.cs @@ -2,7 +2,7 @@ using Newtonsoft.Json; namespace Discord.API { - public class AllowedMentions + internal class AllowedMentions { [JsonProperty("parse")] public Optional Parse { get; set; } From 5934c7949a03d492dfc85c94c2c4fc920aaba670 Mon Sep 17 00:00:00 2001 From: Paulo Date: Wed, 23 Dec 2020 12:46:12 -0300 Subject: [PATCH 03/21] misc: VoiceRegions and related changes (#1720) --- src/Discord.Net.WebSocket/BaseSocketClient.cs | 21 +++++++ .../DiscordShardedClient.cs | 14 +++++ .../DiscordSocketClient.cs | 55 +++++++++++++------ 3 files changed, 73 insertions(+), 17 deletions(-) diff --git a/src/Discord.Net.WebSocket/BaseSocketClient.cs b/src/Discord.Net.WebSocket/BaseSocketClient.cs index 548bb75bf..425889613 100644 --- a/src/Discord.Net.WebSocket/BaseSocketClient.cs +++ b/src/Discord.Net.WebSocket/BaseSocketClient.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; @@ -75,6 +76,7 @@ namespace Discord.WebSocket /// /// A read-only collection of voice regions that the user has access to. /// + [Obsolete("This property is obsolete, use the GetVoiceRegionsAsync method instead.")] public abstract IReadOnlyCollection VoiceRegions { get; } internal BaseSocketClient(DiscordSocketConfig config, DiscordRestApiClient client) @@ -169,7 +171,26 @@ namespace Discord.WebSocket /// A REST-based voice region associated with the identifier; null if the voice region is not /// found. /// + [Obsolete("This method is obsolete, use GetVoiceRegionAsync instead.")] public abstract RestVoiceRegion GetVoiceRegion(string id); + /// + /// Gets all voice regions. + /// + /// The options to be used when sending the request. + /// + /// A task that contains a read-only collection of REST-based voice regions. + /// + public abstract ValueTask> GetVoiceRegionsAsync(RequestOptions options = null); + /// + /// Gets a voice region. + /// + /// The identifier of the voice region (e.g. eu-central ). + /// The options to be used when sending the request. + /// + /// A task that contains a REST-based voice region associated with the identifier; null if the + /// voice region is not found. + /// + public abstract ValueTask GetVoiceRegionAsync(string id, RequestOptions options = null); /// public abstract Task StartAsync(); /// diff --git a/src/Discord.Net.WebSocket/DiscordShardedClient.cs b/src/Discord.Net.WebSocket/DiscordShardedClient.cs index a2c89d4e5..4c94b14e8 100644 --- a/src/Discord.Net.WebSocket/DiscordShardedClient.cs +++ b/src/Discord.Net.WebSocket/DiscordShardedClient.cs @@ -37,6 +37,7 @@ namespace Discord.WebSocket public override IReadOnlyCollection PrivateChannels => GetPrivateChannels().ToReadOnlyCollection(GetPrivateChannelCount); public IReadOnlyCollection Shards => _shards; /// + [Obsolete("This property is obsolete, use the GetVoiceRegionsAsync method instead.")] public override IReadOnlyCollection VoiceRegions => _shards[0].VoiceRegions; /// @@ -264,9 +265,22 @@ namespace Discord.WebSocket } /// + [Obsolete("This method is obsolete, use GetVoiceRegionAsync instead.")] public override RestVoiceRegion GetVoiceRegion(string id) => _shards[0].GetVoiceRegion(id); + /// + public override async ValueTask> GetVoiceRegionsAsync(RequestOptions options = null) + { + return await _shards[0].GetVoiceRegionsAsync().ConfigureAwait(false); + } + + /// + public override async ValueTask GetVoiceRegionAsync(string id, RequestOptions options = null) + { + return await _shards[0].GetVoiceRegionAsync(id, options).ConfigureAwait(false); + } + /// /// is public override async Task DownloadUsersAsync(IEnumerable guilds) diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index 0a2123ef2..d4c96ab26 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -110,7 +110,8 @@ namespace Discord.WebSocket public IReadOnlyCollection GroupChannels => State.PrivateChannels.OfType().ToImmutableArray(); /// - public override IReadOnlyCollection VoiceRegions => _voiceRegions.ToReadOnlyCollection(); + [Obsolete("This property is obsolete, use the GetVoiceRegionsAsync method instead.")] + public override IReadOnlyCollection VoiceRegions => GetVoiceRegionsAsync().GetAwaiter().GetResult(); /// /// Initializes a new REST/WebSocket-based Discord client. @@ -178,7 +179,6 @@ namespace Discord.WebSocket return Task.Delay(0); }; - _voiceRegions = ImmutableDictionary.Create(); _largeGuilds = new ConcurrentQueue(); } private static API.DiscordSocketApiClient CreateApiClient(DiscordSocketConfig config) @@ -204,13 +204,6 @@ namespace Discord.WebSocket /// internal override async Task OnLoginAsync(TokenType tokenType, string token) { - if (_parentClient == null) - { - var voiceRegions = await ApiClient.GetVoiceRegionsAsync(new RequestOptions { IgnoreState = true, RetryMode = RetryMode.AlwaysRetry }).ConfigureAwait(false); - _voiceRegions = voiceRegions.Select(x => RestVoiceRegion.Create(this, x)).ToImmutableDictionary(x => x.Id); - } - else - _voiceRegions = _parentClient._voiceRegions; await Rest.OnLoginAsync(tokenType, token); } /// @@ -218,7 +211,7 @@ namespace Discord.WebSocket { await StopAsync().ConfigureAwait(false); _applicationInfo = null; - _voiceRegions = ImmutableDictionary.Create(); + _voiceRegions = null; await Rest.OnLogoutAsync(); } @@ -350,11 +343,39 @@ namespace Discord.WebSocket => State.RemoveUser(id); /// + [Obsolete("This method is obsolete, use GetVoiceRegionAsync instead.")] public override RestVoiceRegion GetVoiceRegion(string id) + => GetVoiceRegionAsync(id).GetAwaiter().GetResult(); + + /// + public override async ValueTask> GetVoiceRegionsAsync(RequestOptions options = null) { - if (_voiceRegions.TryGetValue(id, out RestVoiceRegion region)) - return region; - return null; + if (_parentClient == null) + { + if (_voiceRegions == null) + { + options = RequestOptions.CreateOrClone(options); + options.IgnoreState = true; + var voiceRegions = await ApiClient.GetVoiceRegionsAsync(options).ConfigureAwait(false); + _voiceRegions = voiceRegions.Select(x => RestVoiceRegion.Create(this, x)).ToImmutableDictionary(x => x.Id); + } + return _voiceRegions.ToReadOnlyCollection(); + } + return await _parentClient.GetVoiceRegionsAsync().ConfigureAwait(false); + } + + /// + public override async ValueTask GetVoiceRegionAsync(string id, RequestOptions options = null) + { + if (_parentClient == null) + { + if (_voiceRegions == null) + await GetVoiceRegionsAsync().ConfigureAwait(false); + if (_voiceRegions.TryGetValue(id, out RestVoiceRegion region)) + return region; + return null; + } + return await _parentClient.GetVoiceRegionAsync(id, options).ConfigureAwait(false); } /// @@ -2120,11 +2141,11 @@ namespace Discord.WebSocket => Task.FromResult(GetUser(username, discriminator)); /// - Task> IDiscordClient.GetVoiceRegionsAsync(RequestOptions options) - => Task.FromResult>(VoiceRegions); + async Task> IDiscordClient.GetVoiceRegionsAsync(RequestOptions options) + => await GetVoiceRegionsAsync(options).ConfigureAwait(false); /// - Task IDiscordClient.GetVoiceRegionAsync(string id, RequestOptions options) - => Task.FromResult(GetVoiceRegion(id)); + async Task IDiscordClient.GetVoiceRegionAsync(string id, RequestOptions options) + => await GetVoiceRegionAsync(id, options).ConfigureAwait(false); /// async Task IDiscordClient.StartAsync() From 6a62c4770c363710e555c510619986f30b683324 Mon Sep 17 00:00:00 2001 From: Paulo Date: Wed, 23 Dec 2020 12:46:27 -0300 Subject: [PATCH 04/21] feature: Add role tags (#1721) --- src/Discord.Net.Core/Entities/Roles/IRole.cs | 7 ++++ .../Entities/Roles/RoleTags.cs | 40 +++++++++++++++++++ src/Discord.Net.Rest/API/Common/Role.cs | 4 +- src/Discord.Net.Rest/API/Common/RoleTags.cs | 15 +++++++ .../Entities/Roles/RestRole.cs | 4 ++ .../Extensions/EntityExtensions.cs | 7 ++++ .../Entities/Roles/SocketRole.cs | 4 ++ 7 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/Discord.Net.Core/Entities/Roles/RoleTags.cs create mode 100644 src/Discord.Net.Rest/API/Common/RoleTags.cs diff --git a/src/Discord.Net.Core/Entities/Roles/IRole.cs b/src/Discord.Net.Core/Entities/Roles/IRole.cs index 66556fc2c..c02322be9 100644 --- a/src/Discord.Net.Core/Entities/Roles/IRole.cs +++ b/src/Discord.Net.Core/Entities/Roles/IRole.cs @@ -65,6 +65,13 @@ namespace Discord /// An representing the position of the role in the role list of the guild. /// int Position { get; } + /// + /// Gets the tags related to this role. + /// + /// + /// A object containing all tags related to this role. + /// + RoleTags Tags { get; } /// /// Modifies this role. diff --git a/src/Discord.Net.Core/Entities/Roles/RoleTags.cs b/src/Discord.Net.Core/Entities/Roles/RoleTags.cs new file mode 100644 index 000000000..d0cbd3580 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Roles/RoleTags.cs @@ -0,0 +1,40 @@ +namespace Discord +{ + /// + /// Provides tags related to a discord role. + /// + public class RoleTags + { + /// + /// Gets the identifier of the bot that this role belongs to, if it does. + /// + /// + /// A if this role belongs to a bot; otherwise + /// . + /// + public ulong? BotId { get; } + /// + /// Gets the identifier of the integration that this role belongs to, if it does. + /// + /// + /// A if this role belongs to an integration; otherwise + /// . + /// + public ulong? IntegrationId { get; } + /// + /// Gets if this role is the guild's premium subscriber (booster) role. + /// + /// + /// if this role is the guild's premium subscriber role; + /// otherwise . + /// + public bool IsPremiumSubscriberRole { get; } + + internal RoleTags(ulong? botId, ulong? integrationId, bool isPremiumSubscriber) + { + BotId = botId; + IntegrationId = integrationId; + IsPremiumSubscriberRole = isPremiumSubscriber; + } + } +} diff --git a/src/Discord.Net.Rest/API/Common/Role.cs b/src/Discord.Net.Rest/API/Common/Role.cs index 856a8695f..190ae25c0 100644 --- a/src/Discord.Net.Rest/API/Common/Role.cs +++ b/src/Discord.Net.Rest/API/Common/Role.cs @@ -1,4 +1,4 @@ -#pragma warning disable CS1591 +#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API @@ -21,5 +21,7 @@ namespace Discord.API public ulong Permissions { get; set; } [JsonProperty("managed")] public bool Managed { get; set; } + [JsonProperty("tags")] + public Optional Tags { get; set; } } } diff --git a/src/Discord.Net.Rest/API/Common/RoleTags.cs b/src/Discord.Net.Rest/API/Common/RoleTags.cs new file mode 100644 index 000000000..6446f2037 --- /dev/null +++ b/src/Discord.Net.Rest/API/Common/RoleTags.cs @@ -0,0 +1,15 @@ +#pragma warning disable CS1591 +using Newtonsoft.Json; + +namespace Discord.API +{ + internal class RoleTags + { + [JsonProperty("bot_id")] + public Optional BotId { get; set; } + [JsonProperty("integration_id")] + public Optional IntegrationId { get; set; } + [JsonProperty("premium_subscriber")] + public Optional IsPremiumSubscriber { get; set; } + } +} diff --git a/src/Discord.Net.Rest/Entities/Roles/RestRole.cs b/src/Discord.Net.Rest/Entities/Roles/RestRole.cs index 7c1a3aaa2..aa33ae7e5 100644 --- a/src/Discord.Net.Rest/Entities/Roles/RestRole.cs +++ b/src/Discord.Net.Rest/Entities/Roles/RestRole.cs @@ -26,6 +26,8 @@ namespace Discord.Rest public GuildPermissions Permissions { get; private set; } /// public int Position { get; private set; } + /// + public RoleTags Tags { get; private set; } /// public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); @@ -56,6 +58,8 @@ namespace Discord.Rest Position = model.Position; Color = new Color(model.Color); Permissions = new GuildPermissions(model.Permissions); + if (model.Tags.IsSpecified) + Tags = model.Tags.Value.ToEntity(); } /// diff --git a/src/Discord.Net.Rest/Extensions/EntityExtensions.cs b/src/Discord.Net.Rest/Extensions/EntityExtensions.cs index 8e1b9c6d8..f8676c783 100644 --- a/src/Discord.Net.Rest/Extensions/EntityExtensions.cs +++ b/src/Discord.Net.Rest/Extensions/EntityExtensions.cs @@ -34,6 +34,13 @@ namespace Discord.Rest model.Thumbnail.IsSpecified ? model.Thumbnail.Value.ToEntity() : (EmbedThumbnail?)null, model.Fields.IsSpecified ? model.Fields.Value.Select(x => x.ToEntity()).ToImmutableArray() : ImmutableArray.Create()); } + public static RoleTags ToEntity(this API.RoleTags model) + { + return new RoleTags( + model.BotId.IsSpecified ? model.BotId.Value : null, + model.IntegrationId.IsSpecified ? model.IntegrationId.Value : null, + model.IsPremiumSubscriber.IsSpecified ? true : false); + } public static API.Embed ToModel(this Embed entity) { if (entity == null) return null; diff --git a/src/Discord.Net.WebSocket/Entities/Roles/SocketRole.cs b/src/Discord.Net.WebSocket/Entities/Roles/SocketRole.cs index b5e26ad78..e6aac2c04 100644 --- a/src/Discord.Net.WebSocket/Entities/Roles/SocketRole.cs +++ b/src/Discord.Net.WebSocket/Entities/Roles/SocketRole.cs @@ -36,6 +36,8 @@ namespace Discord.WebSocket public GuildPermissions Permissions { get; private set; } /// public int Position { get; private set; } + /// + public RoleTags Tags { get; private set; } /// public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); @@ -71,6 +73,8 @@ namespace Discord.WebSocket Position = model.Position; Color = new Color(model.Color); Permissions = new GuildPermissions(model.Permissions); + if (model.Tags.IsSpecified) + Tags = model.Tags.Value.ToEntity(); } /// From c683b2901d5768bb402993765c9c329aa26537eb Mon Sep 17 00:00:00 2001 From: Paulo Date: Wed, 23 Dec 2020 12:46:42 -0300 Subject: [PATCH 05/21] feature: Add user public flags (#1722) --- src/Discord.Net.Core/Entities/Users/IUser.cs | 10 ++++ .../Entities/Users/UserProperties.cs | 48 +++++++++++++++---- src/Discord.Net.Rest/API/Common/User.cs | 2 + .../Entities/Users/RestUser.cs | 4 ++ .../Entities/Users/SocketUser.cs | 7 +++ 5 files changed, 62 insertions(+), 9 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Users/IUser.cs b/src/Discord.Net.Core/Entities/Users/IUser.cs index c36fb2326..e6008aab6 100644 --- a/src/Discord.Net.Core/Entities/Users/IUser.cs +++ b/src/Discord.Net.Core/Entities/Users/IUser.cs @@ -75,6 +75,16 @@ namespace Discord /// Gets the username for this user. /// string Username { get; } + /// + /// Gets the public flags that are applied to this user's account. + /// + /// + /// This value is determined by bitwise OR-ing values together. + /// + /// + /// The value of public flags for this user. + /// + UserProperties? PublicFlags { get; } /// /// Gets the direct message channel of this user, or create one if it does not already exist. diff --git a/src/Discord.Net.Core/Entities/Users/UserProperties.cs b/src/Discord.Net.Core/Entities/Users/UserProperties.cs index 4f7272daa..b6deb744b 100644 --- a/src/Discord.Net.Core/Entities/Users/UserProperties.cs +++ b/src/Discord.Net.Core/Entities/Users/UserProperties.cs @@ -10,32 +10,62 @@ namespace Discord /// None = 0, /// - /// Flag given to Discord staff. + /// Flag given to users who are a Discord employee. /// - Staff = 0b1, + Staff = 1 << 0, /// - /// Flag given to Discord partners. + /// Flag given to users who are owners of a partnered Discord server. /// - Partner = 0b10, + Partner = 1 << 1, + /// + /// Flag given to users in HypeSquad events. + /// + HypeSquadEvents = 1 << 2, /// /// Flag given to users who have participated in the bug report program. + /// This flag is obsolete, use instead. + /// + [Obsolete("Use BugHunterLevel1 instead.")] + BugHunter = 1 << 3, + /// + /// Flag given to users who have participated in the bug report program and are level 1. /// - BugHunter = 0b1000, + BugHunterLevel1 = 1 << 3, /// /// Flag given to users who are in the HypeSquad House of Bravery. /// - HypeSquadBravery = 0b100_0000, + HypeSquadBravery = 1 << 6, /// /// Flag given to users who are in the HypeSquad House of Brilliance. /// - HypeSquadBrilliance = 0b1000_0000, + HypeSquadBrilliance = 1 << 7, /// /// Flag given to users who are in the HypeSquad House of Balance. /// - HypeSquadBalance = 0b1_0000_0000, + HypeSquadBalance = 1 << 8, /// /// Flag given to users who subscribed to Nitro before games were added. /// - EarlySupporter = 0b10_0000_0000, + EarlySupporter = 1 << 9, + /// + /// Flag given to users who are part of a team. + /// + TeamUser = 1 << 10, + /// + /// Flag given to users who represent Discord (System). + /// + System = 1 << 12, + /// + /// Flag given to users who have participated in the bug report program and are level 2. + /// + BugHunterLevel2 = 1 << 14, + /// + /// Flag given to users who are verified bots. + /// + VerifiedBot = 1 << 16, + /// + /// Flag given to users that developed bots and early verified their accounts. + /// + EarlyVerifiedBotDeveloper = 1 << 17, } } diff --git a/src/Discord.Net.Rest/API/Common/User.cs b/src/Discord.Net.Rest/API/Common/User.cs index 2eff3753d..d1f436afb 100644 --- a/src/Discord.Net.Rest/API/Common/User.cs +++ b/src/Discord.Net.Rest/API/Common/User.cs @@ -29,5 +29,7 @@ namespace Discord.API public Optional PremiumType { get; set; } [JsonProperty("locale")] public Optional Locale { get; set; } + [JsonProperty("public_flags")] + public Optional PublicFlags { get; set; } } } diff --git a/src/Discord.Net.Rest/Entities/Users/RestUser.cs b/src/Discord.Net.Rest/Entities/Users/RestUser.cs index f5becd3ff..131a4ec73 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestUser.cs @@ -21,6 +21,8 @@ namespace Discord.Rest public ushort DiscriminatorValue { get; private set; } /// public string AvatarId { get; private set; } + /// + public UserProperties? PublicFlags { get; private set; } /// public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); @@ -65,6 +67,8 @@ namespace Discord.Rest IsBot = model.Bot.Value; if (model.Username.IsSpecified) Username = model.Username.Value; + if (model.PublicFlags.IsSpecified) + PublicFlags = model.PublicFlags.Value; } /// diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs index 7d3c2d23b..4e6d4b3f8 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs @@ -26,6 +26,8 @@ namespace Discord.WebSocket public abstract string AvatarId { get; internal set; } /// public abstract bool IsWebhook { get; } + /// + public UserProperties? PublicFlags { get; private set; } internal abstract SocketGlobalUser GlobalUser { get; } internal abstract SocketPresence Presence { get; set; } @@ -83,6 +85,11 @@ namespace Discord.WebSocket Username = model.Username.Value; hasChanges = true; } + if (model.PublicFlags.IsSpecified && model.PublicFlags.Value != PublicFlags) + { + PublicFlags = model.PublicFlags.Value; + hasChanges = true; + } return hasChanges; } From 225550dc5ac64cec1a38e5cfc1699bd0db0813ee Mon Sep 17 00:00:00 2001 From: Paulo Date: Wed, 23 Dec 2020 12:47:20 -0300 Subject: [PATCH 06/21] feature: Add MessageFlags and AllowedMentions to message modify (#1724) * feature: Add MessageFlags and AllowedMentions to Modify * Change exception message --- .../Entities/Messages/IMessage.cs | 11 ++++++ .../Entities/Messages/MessageFlags.cs | 36 +++++++++++++++++++ .../Entities/Messages/MessageProperties.cs | 12 +++++++ .../API/Common/MessageFlags.cs | 10 ------ .../API/Rest/ModifyMessageParams.cs | 6 +++- .../Entities/Messages/MessageHelper.cs | 33 ++++++++++++++--- .../Entities/Messages/RestMessage.cs | 5 +++ .../Entities/Messages/RestUserMessage.cs | 8 ++--- .../Entities/Messages/SocketMessage.cs | 6 ++++ .../Entities/Messages/SocketUserMessage.cs | 8 ++--- 10 files changed, 108 insertions(+), 27 deletions(-) create mode 100644 src/Discord.Net.Core/Entities/Messages/MessageFlags.cs delete mode 100644 src/Discord.Net.Rest/API/Common/MessageFlags.cs diff --git a/src/Discord.Net.Core/Entities/Messages/IMessage.cs b/src/Discord.Net.Core/Entities/Messages/IMessage.cs index 1f3f5b945..80b1ffa68 100644 --- a/src/Discord.Net.Core/Entities/Messages/IMessage.cs +++ b/src/Discord.Net.Core/Entities/Messages/IMessage.cs @@ -164,6 +164,17 @@ namespace Discord /// IReadOnlyDictionary Reactions { get; } + /// + /// Gets the flags related to this message. + /// + /// + /// This value is determined by bitwise OR-ing values together. + /// + /// + /// A message's flags, if any is associated. + /// + MessageFlags? Flags { get; } + /// /// Adds a reaction to this message. /// diff --git a/src/Discord.Net.Core/Entities/Messages/MessageFlags.cs b/src/Discord.Net.Core/Entities/Messages/MessageFlags.cs new file mode 100644 index 000000000..52d0f0e9e --- /dev/null +++ b/src/Discord.Net.Core/Entities/Messages/MessageFlags.cs @@ -0,0 +1,36 @@ +using System; + +namespace Discord +{ + [Flags] + public enum MessageFlags + { + /// + /// Default value for flags, when none are given to a message. + /// + None = 0, + /// + /// Flag given to messages that have been published to subscribed + /// channels (via Channel Following). + /// + Crossposted = 1 << 0, + /// + /// Flag given to messages that originated from a message in another + /// channel (via Channel Following). + /// + IsCrosspost = 1 << 1, + /// + /// Flag given to messages that do not display any embeds. + /// + SuppressEmbeds = 1 << 2, + /// + /// Flag given to messages that the source message for this crosspost + /// has been deleted (via Channel Following). + /// + SourceMessageDeleted = 1 << 3, + /// + /// Flag given to messages that came from the urgent message system. + /// + Urgent = 1 << 4, + } +} diff --git a/src/Discord.Net.Core/Entities/Messages/MessageProperties.cs b/src/Discord.Net.Core/Entities/Messages/MessageProperties.cs index b632d6a18..9504e04cb 100644 --- a/src/Discord.Net.Core/Entities/Messages/MessageProperties.cs +++ b/src/Discord.Net.Core/Entities/Messages/MessageProperties.cs @@ -21,5 +21,17 @@ namespace Discord /// Gets or sets the embed the message should display. /// public Optional Embed { get; set; } + /// + /// Gets or sets the flags of the message. + /// + /// + /// Only can be set/unset and you need to be + /// the author of the message. + /// + public Optional Flags { get; set; } + /// + /// Gets or sets the allowed mentions of the message. + /// + public Optional AllowedMentions { get; set; } } } diff --git a/src/Discord.Net.Rest/API/Common/MessageFlags.cs b/src/Discord.Net.Rest/API/Common/MessageFlags.cs deleted file mode 100644 index ebe4e80ca..000000000 --- a/src/Discord.Net.Rest/API/Common/MessageFlags.cs +++ /dev/null @@ -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, - } -} diff --git a/src/Discord.Net.Rest/API/Rest/ModifyMessageParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyMessageParams.cs index fdff4de15..3752df3a2 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyMessageParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyMessageParams.cs @@ -1,4 +1,4 @@ -#pragma warning disable CS1591 +#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest @@ -10,5 +10,9 @@ namespace Discord.API.Rest public Optional Content { get; set; } [JsonProperty("embed")] public Optional Embed { get; set; } + [JsonProperty("flags")] + public Optional Flags { get; set; } + [JsonProperty("allowed_mentions")] + public Optional AllowedMentions { get; set; } } } diff --git a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs index b86a5dbf3..e22ae71cd 100644 --- a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs +++ b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs @@ -27,21 +27,46 @@ namespace Discord.Rest public static async Task ModifyAsync(IMessage msg, BaseDiscordClient client, Action func, RequestOptions options) { - if (msg.Author.Id != client.CurrentUser.Id) - throw new InvalidOperationException("Only the author of a message may modify the message."); - var args = new MessageProperties(); func(args); + if (msg.Author.Id != client.CurrentUser.Id && (args.Content.IsSpecified || args.Embed.IsSpecified || args.AllowedMentions.IsSpecified)) + throw new InvalidOperationException("Only the author of a message may modify the message content, embed, or allowed mentions."); + bool hasText = args.Content.IsSpecified ? !string.IsNullOrEmpty(args.Content.Value) : !string.IsNullOrEmpty(msg.Content); bool hasEmbed = args.Embed.IsSpecified ? args.Embed.Value != null : msg.Embeds.Any(); if (!hasText && !hasEmbed) Preconditions.NotNullOrEmpty(args.Content.IsSpecified ? args.Content.Value : string.Empty, nameof(args.Content)); + if (args.AllowedMentions.IsSpecified) + { + AllowedMentions allowedMentions = args.AllowedMentions.Value; + 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."); + + // check that user flag and user Id list are exclusive, same with role flag and role Id list + if (allowedMentions != null && allowedMentions.AllowedTypes.HasValue) + { + if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Users) && + allowedMentions.UserIds != null && allowedMentions.UserIds.Count > 0) + { + throw new ArgumentException("The Users flag is mutually exclusive with the list of User Ids.", nameof(allowedMentions)); + } + + if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Roles) && + allowedMentions.RoleIds != null && allowedMentions.RoleIds.Count > 0) + { + throw new ArgumentException("The Roles flag is mutually exclusive with the list of Role Ids.", nameof(allowedMentions)); + } + } + } + var apiArgs = new API.Rest.ModifyMessageParams { Content = args.Content, - Embed = args.Embed.IsSpecified ? args.Embed.Value.ToModel() : Optional.Create() + Embed = args.Embed.IsSpecified ? args.Embed.Value.ToModel() : Optional.Create(), + Flags = args.Flags.IsSpecified ? args.Flags.Value : Optional.Create(), + AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value.ToModel() : Optional.Create(), }; return await client.ApiClient.ModifyMessageAsync(msg.Channel.Id, msg.Id, apiArgs, options).ConfigureAwait(false); } diff --git a/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs b/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs index 0169c9b8b..b2a745980 100644 --- a/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs +++ b/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs @@ -67,6 +67,8 @@ namespace Discord.Rest public MessageApplication Application { get; private set; } /// public MessageReference Reference { get; private set; } + /// + public MessageFlags? Flags { get; private set; } internal RestMessage(BaseDiscordClient discord, ulong id, IMessageChannel channel, IUser author, MessageSource source) : base(discord, id) @@ -124,6 +126,9 @@ namespace Discord.Rest }; } + if (model.Flags.IsSpecified) + Flags = model.Flags.Value; + if (model.Reactions.IsSpecified) { var value = model.Reactions.Value; diff --git a/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs b/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs index 2c76a4253..cf025aea1 100644 --- a/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs +++ b/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs @@ -13,7 +13,7 @@ namespace Discord.Rest [DebuggerDisplay(@"{DebuggerDisplay,nq}")] public class RestUserMessage : RestMessage, IUserMessage { - private bool _isMentioningEveryone, _isTTS, _isPinned, _isSuppressed; + private bool _isMentioningEveryone, _isTTS, _isPinned; private long? _editedTimestampTicks; private IUserMessage _referencedMessage; private ImmutableArray _attachments = ImmutableArray.Create(); @@ -27,7 +27,7 @@ namespace Discord.Rest /// public override bool IsPinned => _isPinned; /// - public override bool IsSuppressed => _isSuppressed; + public override bool IsSuppressed => Flags.HasValue && Flags.Value.HasFlag(MessageFlags.SuppressEmbeds); /// public override DateTimeOffset? EditedTimestamp => DateTimeUtils.FromTicks(_editedTimestampTicks); /// @@ -70,10 +70,6 @@ namespace Discord.Rest _editedTimestampTicks = model.EditedTimestamp.Value?.UtcTicks; if (model.MentionEveryone.IsSpecified) _isMentioningEveryone = model.MentionEveryone.Value; - if (model.Flags.IsSpecified) - { - _isSuppressed = model.Flags.Value.HasFlag(API.MessageFlags.Suppressed); - } if (model.RoleMentions.IsSpecified) _roleMentionIds = model.RoleMentions.Value.ToImmutableArray(); diff --git a/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs b/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs index 98fd4af07..2ca53cbb9 100644 --- a/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs +++ b/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs @@ -58,6 +58,9 @@ namespace Discord.WebSocket /// public MessageReference Reference { get; private set; } + /// + public MessageFlags? Flags { get; private set; } + /// /// Returns all attachments included in this message. /// @@ -156,6 +159,9 @@ namespace Discord.WebSocket MessageId = model.Reference.Value.MessageId }; } + + if (model.Flags.IsSpecified) + Flags = model.Flags.Value; } /// diff --git a/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs b/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs index bea0f45eb..859b1b80a 100644 --- a/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs +++ b/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs @@ -15,7 +15,7 @@ namespace Discord.WebSocket [DebuggerDisplay(@"{DebuggerDisplay,nq}")] public class SocketUserMessage : SocketMessage, IUserMessage { - private bool _isMentioningEveryone, _isTTS, _isPinned, _isSuppressed; + private bool _isMentioningEveryone, _isTTS, _isPinned; private long? _editedTimestampTicks; private IUserMessage _referencedMessage; private ImmutableArray _attachments = ImmutableArray.Create(); @@ -29,7 +29,7 @@ namespace Discord.WebSocket /// public override bool IsPinned => _isPinned; /// - public override bool IsSuppressed => _isSuppressed; + public override bool IsSuppressed => Flags.HasValue && Flags.Value.HasFlag(MessageFlags.SuppressEmbeds); /// public override DateTimeOffset? EditedTimestamp => DateTimeUtils.FromTicks(_editedTimestampTicks); /// @@ -74,10 +74,6 @@ namespace Discord.WebSocket _editedTimestampTicks = model.EditedTimestamp.Value?.UtcTicks; if (model.MentionEveryone.IsSpecified) _isMentioningEveryone = model.MentionEveryone.Value; - if (model.Flags.IsSpecified) - { - _isSuppressed = model.Flags.Value.HasFlag(API.MessageFlags.Suppressed); - } if (model.RoleMentions.IsSpecified) _roleMentions = model.RoleMentions.Value.Select(x => guild.GetRole(x)).ToImmutableArray(); From 8b25c9bbfb88818f0a3eda6ca04ba3c06a4fec43 Mon Sep 17 00:00:00 2001 From: quinchs <49576606+quinchs@users.noreply.github.com> Date: Wed, 23 Dec 2020 11:47:54 -0400 Subject: [PATCH 07/21] feature: Add GuildUser IsPending property (#1731) * Implemented Pending property * Implemented changes --- src/Discord.Net.Core/Entities/Users/IGuildUser.cs | 5 +++++ src/Discord.Net.Rest/API/Common/GuildMember.cs | 2 ++ src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs | 4 ++++ src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs | 2 ++ src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs | 4 ++++ .../Entities/Users/SocketWebhookUser.cs | 2 ++ 6 files changed, 19 insertions(+) diff --git a/src/Discord.Net.Core/Entities/Users/IGuildUser.cs b/src/Discord.Net.Core/Entities/Users/IGuildUser.cs index 0e4004c46..582e9e7a7 100644 --- a/src/Discord.Net.Core/Entities/Users/IGuildUser.cs +++ b/src/Discord.Net.Core/Entities/Users/IGuildUser.cs @@ -68,6 +68,11 @@ namespace Discord /// IReadOnlyCollection RoleIds { get; } + /// + /// Whether the user has passed the guild's Membership Screening requirements. + /// + bool? IsPending { get; } + /// /// Gets the level permissions granted to this user to a given channel. /// diff --git a/src/Discord.Net.Rest/API/Common/GuildMember.cs b/src/Discord.Net.Rest/API/Common/GuildMember.cs index 940eb925a..fc2092d6c 100644 --- a/src/Discord.Net.Rest/API/Common/GuildMember.cs +++ b/src/Discord.Net.Rest/API/Common/GuildMember.cs @@ -18,6 +18,8 @@ namespace Discord.API public Optional Deaf { get; set; } [JsonProperty("mute")] public Optional Mute { get; set; } + [JsonProperty("pending")] + public Optional Pending { get; set; } [JsonProperty("premium_since")] public Optional PremiumSince { get; set; } } diff --git a/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs b/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs index d6a8c2eda..4a6bc1025 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs @@ -29,6 +29,8 @@ namespace Discord.Rest public DateTimeOffset? PremiumSince => DateTimeUtils.FromTicks(_premiumSinceTicks); /// public ulong GuildId => Guild.Id; + /// + public bool? IsPending { get; private set; } /// /// Resolving permissions requires the parent guild to be downloaded. @@ -73,6 +75,8 @@ namespace Discord.Rest UpdateRoles(model.Roles.Value); if (model.PremiumSince.IsSpecified) _premiumSinceTicks = model.PremiumSince.Value?.UtcTicks; + if (model.Pending.IsSpecified) + IsPending = model.Pending.Value; } private void UpdateRoles(ulong[] roleIds) { diff --git a/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs b/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs index 8462cb8d4..a06916c9b 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs @@ -52,6 +52,8 @@ namespace Discord.Rest /// string IGuildUser.Nickname => null; /// + bool? IGuildUser.IsPending => null; + /// GuildPermissions IGuildUser.GuildPermissions => GuildPermissions.Webhook; /// diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs index a506a5d7f..c0a681d9d 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs @@ -57,6 +57,8 @@ namespace Discord.WebSocket /// public bool IsStreaming => VoiceState?.IsStreaming ?? false; /// + public bool? IsPending { get; private set; } + /// public DateTimeOffset? JoinedAt => DateTimeUtils.FromTicks(_joinedAtTicks); /// /// Returns a collection of roles that the user possesses. @@ -142,6 +144,8 @@ namespace Discord.WebSocket UpdateRoles(model.Roles.Value); if (model.PremiumSince.IsSpecified) _premiumSinceTicks = model.PremiumSince.Value?.UtcTicks; + if (model.Pending.IsSpecified) + IsPending = model.Pending.Value; } internal void Update(ClientState state, PresenceModel model, bool updatePresence) { diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs index d400e1ae7..5103aa8b3 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs @@ -65,6 +65,8 @@ namespace Discord.WebSocket /// DateTimeOffset? IGuildUser.PremiumSince => null; /// + bool? IGuildUser.IsPending => null; + /// GuildPermissions IGuildUser.GuildPermissions => GuildPermissions.Webhook; /// From 20957016653e2dba1a7a1007f2c684b7c02a6ee8 Mon Sep 17 00:00:00 2001 From: Paulo Date: Thu, 21 Jan 2021 18:08:46 -0300 Subject: [PATCH 08/21] fix: Missing MessageReference when sending files --- src/Discord.Net.Rest/API/Rest/UploadFileParams.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs b/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs index a7d19b4ef..dd442a6de 100644 --- a/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs +++ b/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs @@ -49,6 +49,8 @@ namespace Discord.API.Rest payload["allowed_mentions"] = AllowedMentions.Value; if (IsSpoiler) payload["hasSpoiler"] = IsSpoiler.ToString(); + if (MessageReference.IsSpecified) + payload["message_reference"] = MessageReference.Value; var json = new StringBuilder(); using (var text = new StringWriter(json)) From 6bb54577ab15c192cc678fb37150c1e313d0a81a Mon Sep 17 00:00:00 2001 From: Paulo Date: Thu, 28 Jan 2021 19:13:18 -0300 Subject: [PATCH 09/21] meta: 2.3.0 --- CHANGELOG.md | 91 ++++++++++++++++++++++++++++++ Discord.Net.targets | 2 +- src/Discord.Net/Discord.Net.nuspec | 32 +++++------ 3 files changed, 108 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 886754052..7f4041a7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,96 @@ # Changelog +## [2.3.0] - 2021-01-28 +### Added +- #1491 Add INVITE_CREATE and INVITE_DELETE events (1ab670b) +- #1520 Support reading multiple activities (421a0c1) +- #1521 Allow for inherited commands in modules (a51cdf6) +- #1526 Add Direction.Around to GetMessagesAsync (f2130f8) +- #1537 Implement gateway ratelimit (ec673e1) +- #1544 Add MESSAGE_REACTION_REMOVE_EMOJI and RemoveAllReactionsForEmoteAsync (a89f076) +- #1549 Add GetUsersAsync to SocketGuild (30b5a83) +- #1566 Support Gateway Intents (d5d10d3) +- #1573 Add missing properties to Guild and deprecate GuildEmbed (ec212b1) +- #1581 Add includeRoleIds to PruneUsersAsync (a80e5ff) +- #1588 Add GetStreams to AudioClient (1e012ac) +- #1596 Add missing channel properties (2d80037) +- #1604 Add missing application properties (including Teams) (10fcde0) +- #1619 Add "View Guild Insights" to GuildPermission (2592264) +- #1637 Added CultureInvariant RegexOption to WebhookUrlRegex (e3925a7) +- #1659 Add inline replies (e3850e1) +- #1688 Send presence on Identify payload (25d5d36) +- #1721 Add role tags (6a62c47) +- #1722 Add user public flags (c683b29) +- #1724 Add MessageFlags and AllowedMentions to message modify (225550d) +- #1731 Add GuildUser IsPending property (8b25c9b) +- #1690 Add max bitrate value to SocketGuild (aacfea0) + +### Fixed +- #1244 Missing AddReactions permission for DM channels. (e40ca4a) +- #1469 unsupported property causes an exception (468f826) +- #1525 AllowedMentions and AllowedMentionTypes (3325031) +- #1531 Add AllowedMentions to SendFileAsync (ab32607) +- #1532 GuildEmbed.ChannelId as nullable per API documentation (971d519) +- #1546 Different ratelimits for the same route (implement discord buckets) (2f6c017) +- #1548 Incomplete Ready, DownloadUsersAsync, and optimize AlwaysDownloadUsers (dc8c959) +- #1555 InvalidOperationException at MESSAGE_CREATE (bd4672a) +- #1557 Sending 2 requests instead of 1 to create a Guild role. (5430cc8) +- #1571 Not using the new domain name. (df8a0f7) +- #1578 Trim token before passing it to the authorization header (42ba372) +- #1580 Stop TaskCanceledException from bubbling up (b8fa464) +- #1599 Invite audit log without inviter (b95b95b) +- #1602 Add AllowedMentions to webhooks (bd4516b) +- #1603 Cancel reconnection when 4014 (f396cd9) +- #1608 Voice overwrites and CategoryId remarks (43c8fc0) +- #1614 Check error 404 and return null for GetBanAsync (ae9fff6) +- #1621 Parse mentions from message payload (366ca9a) +- #1622 Do not update overwrite cache locally (3860da0) +- #1623 Invoke UserUpdated from GuildMemberUpdated if needed (3085e88) +- #1624 Handle null PreferredLocale in rare cases (c1d04b4) +- #1639 Invite and InviteMetadata properties (dd2e524) +- #1642 Add missing permissions (4b389f3) +- #1647 handicap member downloading for verified bots (fa5ef5e) +- #1652 Update README.MD to reflect new discord domain (03b831e) +- #1667 Audio stream dispose (a2af985) +- #1671 Crosspost throwing InvalidOperationException (9134443) +- #1672 Team is nullable, not optional (be60d81) +- #1681 Emoji url encode (04389a4) +- #1683 SocketGuild.HasAllMembers is false if a user left a guild (47f571e) +- #1686 Revert PremiumSubscriptionCount type (97e71cd) +- #1695 Possible NullReferenceException when receiving InvalidSession (5213916) +- #1702 Rollback Activities to Game (9d7cb39) +- #1727 Move and fix internal AllowedMentions object (4a7f8fe) +- limit request members batch size (084db25) +- UserMentions throwing NullRef (5ed01a3) +- Wrong author for SocketUserMessage.ReferencedMessage (1e9b252) +- Discord sends null when there's no team (05a1f0a) +- IMessage.Embeds docs remarks (a4d32d3) +- Missing MessageReference when sending files (2095701) + +### Misc +- #1545 MutualGuilds optimization (323a677) +- #1551 Update webhook regex to support discord.com (7585789) +- #1556 Add SearchUsersAsync (57880de) +- #1561 Minor refactor to switch expression (42826df) +- #1576 Updating comments for privileged intents (c42bfa6) +- #1678 Change ratelimit messages (47ed806) +- #1714 Update summary of SocketVoiceChannel.Users (e385c40) +- #1720 VoiceRegions and related changes (5934c79) +- Add updated libraries for LastModified (d761846) +- Add alternative documentation link (accd351) +- Temporarily disable StyleCops until all the fixes are impl'd (36de7b2) +- Remove redundant CreateGuildRoleParams (3df0539) +- Add minor tweaks to DiscordSocketConfig docs strings (2cd1880) +- Fix MaxWaitBetweenGuildAvailablesBeforeReady docs string (e31cdc7) +- Missing summary tag for GatewayIntents (3a10018) +- Add new method of role ID copy (857ef77) +- Resolve inheritdocs for IAttachment (9ea3291) +- Mark null as a specific langword in summary (13a41f8) +- Cleanup GatewayReconnectException docs (833ee42) +- Update Docfx.Plugins.LastModified to v1.2.4 (28a6f97) +- Update framework version for tests to Core 3.1 to comply with LTS (4988a07) +- Move bulk deletes remarks from to (62539f0) + ## [2.2.0] - 2020-04-16 ### Added - #1247 Implement Client Status Support (9da11b4) diff --git a/Discord.Net.targets b/Discord.Net.targets index 9502e91dd..503035b0c 100644 --- a/Discord.Net.targets +++ b/Discord.Net.targets @@ -1,7 +1,7 @@ 2.3.0 - dev + latest Discord.Net Contributors discord;discordapp diff --git a/src/Discord.Net/Discord.Net.nuspec b/src/Discord.Net/Discord.Net.nuspec index 5c5ea4072..c675f2fc5 100644 --- a/src/Discord.Net/Discord.Net.nuspec +++ b/src/Discord.Net/Discord.Net.nuspec @@ -2,7 +2,7 @@ Discord.Net - 2.3.0-dev$suffix$ + 2.3.0$suffix$ Discord.Net Discord.Net Contributors foxbot @@ -14,25 +14,25 @@ https://github.com/RogueException/Discord.Net/raw/dev/docs/marketing/logo/PackageLogo.png - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + From 83e88f4fb961bb78d5446e87e31fff4470f616dc Mon Sep 17 00:00:00 2001 From: Paulo Date: Sat, 30 Jan 2021 23:40:33 -0300 Subject: [PATCH 10/21] meta: Bump version to 2.3.1-dev --- Discord.Net.targets | 4 ++-- src/Discord.Net/Discord.Net.nuspec | 32 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Discord.Net.targets b/Discord.Net.targets index 503035b0c..a7e2c8a51 100644 --- a/Discord.Net.targets +++ b/Discord.Net.targets @@ -1,7 +1,7 @@ - 2.3.0 - + 2.3.1 + dev latest Discord.Net Contributors discord;discordapp diff --git a/src/Discord.Net/Discord.Net.nuspec b/src/Discord.Net/Discord.Net.nuspec index c675f2fc5..494e3ea43 100644 --- a/src/Discord.Net/Discord.Net.nuspec +++ b/src/Discord.Net/Discord.Net.nuspec @@ -2,7 +2,7 @@ Discord.Net - 2.3.0$suffix$ + 2.3.1-dev$suffix$ Discord.Net Discord.Net Contributors foxbot @@ -14,25 +14,25 @@ https://github.com/RogueException/Discord.Net/raw/dev/docs/marketing/logo/PackageLogo.png - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + From 73e5cc2fbcc7c974706165f5cb0703770a0be727 Mon Sep 17 00:00:00 2001 From: Yeba <31899118+yebafan@users.noreply.github.com> Date: Sun, 31 Jan 2021 07:13:09 +0100 Subject: [PATCH 11/21] fix: Deadlock in DiscordShardedClient when Ready is never received (#1761) * fixed a deadlock in DiscordShardedClient during a failed Identify due to InvalidSession * fixed log * Don't wait ready before releasing semaphore Co-authored-by: Paulo --- src/Discord.Net.WebSocket/DiscordSocketClient.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index d4c96ab26..b43db5d98 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -245,15 +245,15 @@ namespace Discord.WebSocket await _gatewayLogger.DebugAsync("Identifying").ConfigureAwait(false); await ApiClient.SendIdentifyAsync(shardID: ShardId, totalShards: TotalShards, guildSubscriptions: _guildSubscriptions, gatewayIntents: _gatewayIntents, presence: BuildCurrentStatus()).ConfigureAwait(false); } - - //Wait for READY - await _connection.WaitAsync().ConfigureAwait(false); } finally { if (locked) _shardedClient.ReleaseIdentifyLock(); } + + //Wait for READY + await _connection.WaitAsync().ConfigureAwait(false); } private async Task OnDisconnectingAsync(Exception ex) { @@ -632,7 +632,7 @@ namespace Discord.WebSocket } else if (_connection.CancelToken.IsCancellationRequested) return; - + if (BaseConfig.AlwaysDownloadUsers) _ = DownloadUsersAsync(Guilds.Where(x => x.IsAvailable && !x.HasAllMembers)); From 0fc713a8977d2474adf03dc83a46d02ffcd295e8 Mon Sep 17 00:00:00 2001 From: Antonio Zdravkov Nikolov Date: Wed, 10 Feb 2021 02:04:32 +0200 Subject: [PATCH 12/21] fix: Private methods aren't added as commands (#1773) Fix breaking change introduced by #1521 --- src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs b/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs index 28037b0fa..7a752090e 100644 --- a/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs +++ b/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs @@ -136,7 +136,7 @@ namespace Discord.Commands builder.Name = typeInfo.Name; // Get all methods (including from inherited members), that are valid commands - var validCommands = typeInfo.GetMethods().Where(IsValidCommandDefinition); + var validCommands = typeInfo.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where(IsValidCommandDefinition); foreach (var method in validCommands) { From 6ac5ea1cbb8fe0e517af9b534bd128fefd212829 Mon Sep 17 00:00:00 2001 From: NeKz Date: Wed, 10 Mar 2021 18:50:48 +0100 Subject: [PATCH 13/21] fix: Add ChannelType property to ChannelInfo audit log (#1786) --- .../Entities/AuditLogs/DataTypes/ChannelInfo.cs | 10 +++++++++- .../AuditLogs/DataTypes/ChannelUpdateAuditLogData.cs | 7 +++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelInfo.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelInfo.cs index 0284b63f5..f50d9eeb3 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelInfo.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelInfo.cs @@ -5,13 +5,14 @@ namespace Discord.Rest /// public struct ChannelInfo { - internal ChannelInfo(string name, string topic, int? rateLimit, bool? nsfw, int? bitrate) + internal ChannelInfo(string name, string topic, int? rateLimit, bool? nsfw, int? bitrate, ChannelType? type) { Name = name; Topic = topic; SlowModeInterval = rateLimit; IsNsfw = nsfw; Bitrate = bitrate; + ChannelType = type; } /// @@ -53,5 +54,12 @@ namespace Discord.Rest /// null if this is not mentioned in this entry. /// public int? Bitrate { get; } + /// + /// Gets the type of this channel. + /// + /// + /// The channel type of this channel; null if not applicable. + /// + public ChannelType? ChannelType { get; } } } diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelUpdateAuditLogData.cs index fa5233145..b2294f183 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelUpdateAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelUpdateAuditLogData.cs @@ -26,6 +26,7 @@ namespace Discord.Rest var rateLimitPerUserModel = changes.FirstOrDefault(x => x.ChangedProperty == "rate_limit_per_user"); var nsfwModel = changes.FirstOrDefault(x => x.ChangedProperty == "nsfw"); var bitrateModel = changes.FirstOrDefault(x => x.ChangedProperty == "bitrate"); + var typeModel = changes.FirstOrDefault(x => x.ChangedProperty == "type"); string oldName = nameModel?.OldValue?.ToObject(discord.ApiClient.Serializer), newName = nameModel?.NewValue?.ToObject(discord.ApiClient.Serializer); @@ -37,9 +38,11 @@ namespace Discord.Rest newNsfw = nsfwModel?.NewValue?.ToObject(discord.ApiClient.Serializer); int? oldBitrate = bitrateModel?.OldValue?.ToObject(discord.ApiClient.Serializer), newBitrate = bitrateModel?.NewValue?.ToObject(discord.ApiClient.Serializer); + ChannelType? oldType = typeModel?.OldValue?.ToObject(discord.ApiClient.Serializer), + newType = typeModel?.NewValue?.ToObject(discord.ApiClient.Serializer); - var before = new ChannelInfo(oldName, oldTopic, oldRateLimitPerUser, oldNsfw, oldBitrate); - var after = new ChannelInfo(newName, newTopic, newRateLimitPerUser, newNsfw, newBitrate); + var before = new ChannelInfo(oldName, oldTopic, oldRateLimitPerUser, oldNsfw, oldBitrate, oldType); + var after = new ChannelInfo(newName, newTopic, newRateLimitPerUser, newNsfw, newBitrate, newType); return new ChannelUpdateAuditLogData(entry.TargetId.Value, before, after); } From f794163ffa4922f484981a936694e6dd80a1451c Mon Sep 17 00:00:00 2001 From: NeKz Date: Wed, 10 Mar 2021 20:07:19 +0100 Subject: [PATCH 14/21] fix: NullReferenceException in pin/unpin audit logs (#1780) --- .../AuditLogs/DataTypes/MessagePinAuditLogData.cs | 14 ++++++++++---- .../DataTypes/MessageUnpinAuditLogData.cs | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs index 020171152..be66ac846 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs @@ -19,8 +19,14 @@ namespace Discord.Rest internal static MessagePinAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry) { - var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId); - return new MessagePinAuditLogData(entry.Options.MessageId.Value, entry.Options.ChannelId.Value, RestUser.Create(discord, userInfo)); + RestUser user = null; + if (entry.TargetId.HasValue) + { + var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId); + user = RestUser.Create(discord, userInfo); + } + + return new MessagePinAuditLogData(entry.Options.MessageId.Value, entry.Options.ChannelId.Value, user); } /// @@ -38,10 +44,10 @@ namespace Discord.Rest /// public ulong ChannelId { get; } /// - /// Gets the user of the message that was pinned. + /// Gets the user of the message that was pinned if available. /// /// - /// A user object representing the user that created the pinned message. + /// A user object representing the user that created the pinned message or . /// public IUser Target { get; } } diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs index 1b3ff96f3..b4fa389cc 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs @@ -19,8 +19,14 @@ namespace Discord.Rest internal static MessageUnpinAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry) { - var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId); - return new MessageUnpinAuditLogData(entry.Options.MessageId.Value, entry.Options.ChannelId.Value, RestUser.Create(discord, userInfo)); + RestUser user = null; + if (entry.TargetId.HasValue) + { + var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId); + user = RestUser.Create(discord, userInfo); + } + + return new MessageUnpinAuditLogData(entry.Options.MessageId.Value, entry.Options.ChannelId.Value, user); } /// @@ -38,10 +44,10 @@ namespace Discord.Rest /// public ulong ChannelId { get; } /// - /// Gets the user of the message that was unpinned. + /// Gets the user of the message that was unpinned if available. /// /// - /// A user object representing the user that created the unpinned message. + /// A user object representing the user that created the unpinned message or . /// public IUser Target { get; } } From 51b7afe2a6daaa07de24e96bb6c7abee7dd8bc10 Mon Sep 17 00:00:00 2001 From: Paulo Date: Wed, 10 Mar 2021 16:07:31 -0300 Subject: [PATCH 15/21] misc: Add remark regarding CustomStatus as the activity (#1774) * Throw exception with CustomStatus * Add remark instead of exception * Change wording --- src/Discord.Net.WebSocket/BaseSocketClient.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Discord.Net.WebSocket/BaseSocketClient.cs b/src/Discord.Net.WebSocket/BaseSocketClient.cs index 425889613..36e6c02a9 100644 --- a/src/Discord.Net.WebSocket/BaseSocketClient.cs +++ b/src/Discord.Net.WebSocket/BaseSocketClient.cs @@ -209,6 +209,12 @@ namespace Discord.WebSocket /// The name of the game. /// If streaming, the URL of the stream. Must be a valid Twitch URL. /// The type of the game. + /// + /// + /// Bot accounts cannot set as their activity + /// type and it will have no effect. + /// + /// /// /// A task that represents the asynchronous set operation. /// @@ -222,6 +228,10 @@ namespace Discord.WebSocket /// Discord will only accept setting of name and the type of activity. /// /// + /// Bot accounts cannot set as their activity + /// type and it will have no effect. + /// + /// /// Rich Presence cannot be set via this method or client. Rich Presence is strictly limited to RPC /// clients only. /// From d2518db9a8826dd60ca34ec29775c154825f6150 Mon Sep 17 00:00:00 2001 From: Alex Gravely Date: Wed, 10 Mar 2021 14:22:00 -0500 Subject: [PATCH 16/21] fix: Update Webhook ChannelId from model change (#1791) --- src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs | 6 ++++-- .../Entities/Webhooks/RestInternalWebhook.cs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs b/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs index 1fdc95a63..9baddf003 100644 --- a/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs +++ b/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs @@ -11,11 +11,11 @@ namespace Discord.Rest internal IGuild Guild { get; private set; } internal ITextChannel Channel { get; private set; } - /// - public ulong ChannelId { get; } /// public string Token { get; } + /// + public ulong ChannelId { get; private set; } /// public string Name { get; private set; } /// @@ -56,6 +56,8 @@ namespace Discord.Rest internal void Update(Model model) { + if (ChannelId != model.ChannelId) + ChannelId = model.ChannelId; if (model.Avatar.IsSpecified) AvatarId = model.Avatar.Value; if (model.Creator.IsSpecified) diff --git a/src/Discord.Net.Webhook/Entities/Webhooks/RestInternalWebhook.cs b/src/Discord.Net.Webhook/Entities/Webhooks/RestInternalWebhook.cs index 60cb89ee2..bbb160fcd 100644 --- a/src/Discord.Net.Webhook/Entities/Webhooks/RestInternalWebhook.cs +++ b/src/Discord.Net.Webhook/Entities/Webhooks/RestInternalWebhook.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.Threading.Tasks; using Model = Discord.API.Webhook; @@ -11,9 +11,9 @@ namespace Discord.Webhook private DiscordWebhookClient _client; public ulong Id { get; } - public ulong ChannelId { get; } public string Token { get; } + public ulong ChannelId { get; private set; } public string Name { get; private set; } public string AvatarId { get; private set; } public ulong? GuildId { get; private set; } @@ -36,6 +36,8 @@ namespace Discord.Webhook internal void Update(Model model) { + if (ChannelId != model.ChannelId) + ChannelId = model.ChannelId; if (model.Avatar.IsSpecified) AvatarId = model.Avatar.Value; if (model.GuildId.IsSpecified) From d41aeee4fef3ecdefa04a4230dd78fba87999017 Mon Sep 17 00:00:00 2001 From: Paulo Date: Wed, 10 Mar 2021 16:50:14 -0300 Subject: [PATCH 17/21] fix: Audit log UserId can be null (#1794) --- src/Discord.Net.Rest/API/Common/AuditLogEntry.cs | 2 +- src/Discord.Net.Rest/Entities/AuditLogs/RestAuditLogEntry.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net.Rest/API/Common/AuditLogEntry.cs b/src/Discord.Net.Rest/API/Common/AuditLogEntry.cs index 80d9a9e97..7458a19cb 100644 --- a/src/Discord.Net.Rest/API/Common/AuditLogEntry.cs +++ b/src/Discord.Net.Rest/API/Common/AuditLogEntry.cs @@ -7,7 +7,7 @@ namespace Discord.API [JsonProperty("target_id")] public ulong? TargetId { get; set; } [JsonProperty("user_id")] - public ulong UserId { get; set; } + public ulong? UserId { get; set; } [JsonProperty("changes")] public AuditLogChange[] Changes { get; set; } diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/RestAuditLogEntry.cs b/src/Discord.Net.Rest/Entities/AuditLogs/RestAuditLogEntry.cs index d604077f4..2176eab71 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/RestAuditLogEntry.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/RestAuditLogEntry.cs @@ -22,7 +22,7 @@ namespace Discord.Rest internal static RestAuditLogEntry Create(BaseDiscordClient discord, Model fullLog, EntryModel model) { - var userInfo = fullLog.Users.FirstOrDefault(x => x.Id == model.UserId); + var userInfo = model.UserId != null ? fullLog.Users.FirstOrDefault(x => x.Id == model.UserId) : null; IUser user = null; if (userInfo != null) user = RestUser.Create(discord, userInfo); From 1b64d19c845cb7c612a1c52288c8b44cff605105 Mon Sep 17 00:00:00 2001 From: Paulo Date: Wed, 10 Mar 2021 16:59:38 -0300 Subject: [PATCH 18/21] meta: 2.3.1 (#1795) --- CHANGELOG.md | 12 +++++++++++ Discord.Net.targets | 2 +- src/Discord.Net/Discord.Net.nuspec | 32 +++++++++++++++--------------- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f4041a7a..5988f90c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [2.3.1] - 2021-03-10 +### Fixed +- #1761 Deadlock in DiscordShardedClient when Ready is never received (73e5cc2) +- #1773 Private methods aren't added as commands (0fc713a) +- #1780 NullReferenceException in pin/unpin audit logs (f794163) +- #1786 Add ChannelType property to ChannelInfo audit log (6ac5ea1) +- #1791 Update Webhook ChannelId from model change (d2518db) +- #1794 Audit log UserId can be null (d41aeee) + +### Misc +- #1774 Add remark regarding CustomStatus as the activity (51b7afe) + ## [2.3.0] - 2021-01-28 ### Added - #1491 Add INVITE_CREATE and INVITE_DELETE events (1ab670b) diff --git a/Discord.Net.targets b/Discord.Net.targets index a7e2c8a51..82e0d21fa 100644 --- a/Discord.Net.targets +++ b/Discord.Net.targets @@ -1,7 +1,7 @@ 2.3.1 - dev + latest Discord.Net Contributors discord;discordapp diff --git a/src/Discord.Net/Discord.Net.nuspec b/src/Discord.Net/Discord.Net.nuspec index 494e3ea43..db3f29ca7 100644 --- a/src/Discord.Net/Discord.Net.nuspec +++ b/src/Discord.Net/Discord.Net.nuspec @@ -2,7 +2,7 @@ Discord.Net - 2.3.1-dev$suffix$ + 2.3.1$suffix$ Discord.Net Discord.Net Contributors foxbot @@ -14,25 +14,25 @@ https://github.com/RogueException/Discord.Net/raw/dev/docs/marketing/logo/PackageLogo.png - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + From 452f2dca7cd803a160f5a5b5d17de5ffa9b8a579 Mon Sep 17 00:00:00 2001 From: Paulo Date: Wed, 28 Apr 2021 09:53:14 -0300 Subject: [PATCH 19/21] Remove foxbot.me docs link --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 34a633f72..32e1515af 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,6 @@ An unofficial .NET API Wrapper for the Discord client (https://discord.com). ## Documentation -- [Stable](https://discord.foxbot.me/) - - Hosted by @foxbot - [Nightly](https://docs.stillu.cc/) - [Latest CI repo](https://github.com/discord-net/docs-static) From 86dc89e821fb78b1ec4c3de24d50cc607fbe21af Mon Sep 17 00:00:00 2001 From: PoofImaFox <16710818+PoofImaFox@users.noreply.github.com> Date: Wed, 28 Apr 2021 08:55:57 -0400 Subject: [PATCH 20/21] Fix error in example. (#1807) --- samples/03_sharded_client/Modules/PublicModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/03_sharded_client/Modules/PublicModule.cs b/samples/03_sharded_client/Modules/PublicModule.cs index 60e57563a..fad2ba98c 100644 --- a/samples/03_sharded_client/Modules/PublicModule.cs +++ b/samples/03_sharded_client/Modules/PublicModule.cs @@ -9,7 +9,7 @@ namespace _03_sharded_client.Modules [Command("info")] public async Task InfoAsync() { - var msg = $@"Hi {Context.User}! There are currently {Context.Client.Shards} shards! + var msg = $@"Hi {Context.User}! There are currently {Context.Client.Shards.Count} shards! This guild is being served by shard number {Context.Client.GetShardFor(Context.Guild).ShardId}"; await ReplyAsync(msg); } From c21cf48be31df80a285862f79143f884322a29f6 Mon Sep 17 00:00:00 2001 From: Paulo Date: Wed, 28 Apr 2021 10:03:30 -0300 Subject: [PATCH 21/21] meta: Bump version to 2.4.0-dev (#1827) --- Discord.Net.targets | 4 ++-- src/Discord.Net/Discord.Net.nuspec | 32 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Discord.Net.targets b/Discord.Net.targets index 82e0d21fa..7a48cf2a7 100644 --- a/Discord.Net.targets +++ b/Discord.Net.targets @@ -1,7 +1,7 @@ - 2.3.1 - + 2.4.0 + dev latest Discord.Net Contributors discord;discordapp diff --git a/src/Discord.Net/Discord.Net.nuspec b/src/Discord.Net/Discord.Net.nuspec index db3f29ca7..b0fe17439 100644 --- a/src/Discord.Net/Discord.Net.nuspec +++ b/src/Discord.Net/Discord.Net.nuspec @@ -2,7 +2,7 @@ Discord.Net - 2.3.1$suffix$ + 2.4.0$suffix$ Discord.Net Discord.Net Contributors foxbot @@ -14,25 +14,25 @@ https://github.com/RogueException/Discord.Net/raw/dev/docs/marketing/logo/PackageLogo.png - - - - - + + + + + - - - - - + + + + + - - - - - + + + + +