From 05120f04280344277f7f4ff4766017938e7507fc Mon Sep 17 00:00:00 2001
From: Cenk Ergen <57065323+Cenngo@users.noreply.github.com>
Date: Mon, 1 Aug 2022 14:19:34 +0300
Subject: [PATCH 01/13] Add AutoServiceScopes to IF docs
---
docs/guides/int_framework/intro.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/guides/int_framework/intro.md b/docs/guides/int_framework/intro.md
index 54e9086a1..23be5b544 100644
--- a/docs/guides/int_framework/intro.md
+++ b/docs/guides/int_framework/intro.md
@@ -279,8 +279,8 @@ Meaning, the constructor parameters and public settable properties of a module w
For more information on dependency injection, read the [DependencyInjection] guides.
> [!NOTE]
-> On every command execution, module dependencies are resolved using a new service scope which allows you to utilize scoped service instances, just like in Asp.Net.
-> Including the precondition checks, every module method is executed using the same service scope and service scopes are disposed right after the `AfterExecute` method returns.
+> On every command execution, if the 'AutoServiceScopes' option is enabled in the config , module dependencies are resolved using a new service scope which allows you to utilize scoped service instances, just like in Asp.Net.
+> Including the precondition checks, every module method is executed using the same service scope and service scopes are disposed right after the `AfterExecute` method returns. This doesn't apply to methods other than `ExecuteAsync()`.
## Module Groups
From e0d68d47d48b4022c362e7e8bd293fbe0e0d6fd6 Mon Sep 17 00:00:00 2001
From: Wojciech Berdowski <10144015+wberdowski@users.noreply.github.com>
Date: Mon, 1 Aug 2022 13:20:48 +0200
Subject: [PATCH 02/13] Add note about voice binaries on linux
Makes voice section about precompiled binaries more visible.
---
docs/guides/voice/sending-voice.md | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/docs/guides/voice/sending-voice.md b/docs/guides/voice/sending-voice.md
index 555adbca2..36184e3a3 100644
--- a/docs/guides/voice/sending-voice.md
+++ b/docs/guides/voice/sending-voice.md
@@ -17,11 +17,9 @@ bot. (When developing on .NET Framework, this would be `bin/debug`,
when developing on .NET Core, this is where you execute `dotnet run`
from; typically the same directory as your csproj).
-For Windows Users, precompiled binaries are available for your
-convienence [here](https://github.com/discord-net/Discord.Net/tree/dev/voice-natives).
+**For Windows users, precompiled binaries are available for your convienence [here](https://github.com/discord-net/Discord.Net/tree/dev/voice-natives).**
-For Linux Users, you will need to compile [Sodium] and [Opus] from
-source, or install them from your package manager.
+**For Linux users, you will need to compile [Sodium] and [Opus] from source, or install them from your package manager.**
[Sodium]: https://download.libsodium.org/libsodium/releases/
[Opus]: http://downloads.xiph.org/releases/opus/
From ee6e0adf7cd5873c2ca886ec85556d3e8d5656fc Mon Sep 17 00:00:00 2001
From: Misha133 <61027276+Misha-133@users.noreply.github.com>
Date: Mon, 1 Aug 2022 14:23:43 +0300
Subject: [PATCH 03/13] Add RequiredInput to example modal (#2348) - Misha-133
---
docs/guides/int_framework/samples/intro/modal.cs | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/docs/guides/int_framework/samples/intro/modal.cs b/docs/guides/int_framework/samples/intro/modal.cs
index 65cc81abf..8a6ba9d8a 100644
--- a/docs/guides/int_framework/samples/intro/modal.cs
+++ b/docs/guides/int_framework/samples/intro/modal.cs
@@ -12,7 +12,9 @@ public class FoodModal : IModal
[ModalTextInput("food_name", placeholder: "Pizza", maxLength: 20)]
public string Food { get; set; }
- // Additional paremeters can be specified to further customize the input.
+ // Additional paremeters can be specified to further customize the input.
+ // Parameters can be optional
+ [RequiredInput(false)]
[InputLabel("Why??")]
[ModalTextInput("food_reason", TextInputStyle.Paragraph, "Kuz it's tasty", maxLength: 500)]
public string Reason { get; set; }
@@ -22,10 +24,15 @@ public class FoodModal : IModal
[ModalInteraction("food_menu")]
public async Task ModalResponse(FoodModal modal)
{
+ // Check if "Why??" field is populated
+ string reason = string.IsNullOrWhiteSpace(modal.Reason)
+ ? "."
+ : $" because {modal.Reason}";
+
// Build the message to send.
string message = "hey @everyone, I just learned " +
$"{Context.User.Mention}'s favorite food is " +
- $"{modal.Food} because {modal.Reason}.";
+ $"{modal.Food}{reason}";
// Specify the AllowedMentions so we don't actually ping everyone.
AllowedMentions mentions = new();
From 06ed99512256125c0d32666906feedc2a323a6da Mon Sep 17 00:00:00 2001
From: misticos <21005901+IvMisticos@users.noreply.github.com>
Date: Mon, 1 Aug 2022 13:37:41 +0200
Subject: [PATCH 04/13] docs: Add ServerStarter.Host to deployment.md (#2385)
---
docs/guides/deployment/deployment.md | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/docs/guides/deployment/deployment.md b/docs/guides/deployment/deployment.md
index 0491e841d..4313e85b4 100644
--- a/docs/guides/deployment/deployment.md
+++ b/docs/guides/deployment/deployment.md
@@ -47,6 +47,12 @@ enough. Here is a list of recommended VPS provider.
* Location(s):
* Europe: Lithuania
* Based in: Europe
+* [ServerStarter.Host](https://serverstarter.host/clients/store/discord-bots)
+ * Description: Bot hosting with a panel for quick deployment and
+ no Linux knowledge required.
+ * Location(s):
+ * America: United States
+ * Based in: United States
## .NET Core Deployment
@@ -100,4 +106,4 @@ Windows 10 x64 based machine:
* `dotnet publish -c Release -r win10-x64`
[.NET Core application deployment]: https://docs.microsoft.com/en-us/dotnet/core/deploying/
-[Runtime ID]: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
\ No newline at end of file
+[Runtime ID]: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
From cf25acdbc10941003046ef097e996b82acd00e4b Mon Sep 17 00:00:00 2001
From: Misha133 <61027276+Misha-133@users.noreply.github.com>
Date: Mon, 1 Aug 2022 14:39:11 +0300
Subject: [PATCH 05/13] docs: Add IgnoreGroupNames clarification to IF docs
(#2374)
---
docs/guides/int_framework/intro.md | 5 +++++
docs/guides/int_framework/samples/intro/groupmodule.cs | 7 ++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/docs/guides/int_framework/intro.md b/docs/guides/int_framework/intro.md
index 23be5b544..5d3253a6f 100644
--- a/docs/guides/int_framework/intro.md
+++ b/docs/guides/int_framework/intro.md
@@ -291,6 +291,11 @@ By nesting commands inside a module that is tagged with [GroupAttribute] you can
> Although creating nested module stuctures are allowed,
> you are not permitted to use more than 2 [GroupAttribute]'s in module hierarchy.
+> [!NOTE]
+> To not use the command group's name as a prefix for component or modal interaction's custom id set `ignoreGroupNames` parameter to `true` in classes with [GroupAttribute]
+>
+> However, you have to be careful to prevent overlapping ids of buttons and modals
+
[!code-csharp[Command Group Example](samples/intro/groupmodule.cs)]
## Executing Commands
diff --git a/docs/guides/int_framework/samples/intro/groupmodule.cs b/docs/guides/int_framework/samples/intro/groupmodule.cs
index f0d992aff..a07b2e4d8 100644
--- a/docs/guides/int_framework/samples/intro/groupmodule.cs
+++ b/docs/guides/int_framework/samples/intro/groupmodule.cs
@@ -16,6 +16,11 @@ public class CommandGroupModule : InteractionModuleBase await RespondAsync(input);
+ => await RespondAsync(input, components: new ComponentBuilder().WithButton("Echo", $"echoButton_{input}").Build());
+
+ // Component interaction with ignoreGroupNames set to true
+ [ComponentInteraction("echoButton_*", true)]
+ public async Task EchoButton(string input)
+ => await RespondAsync(input);
}
}
\ No newline at end of file
From 246282dda3a0b093041b2512c64bb5bbd2f9cb3c Mon Sep 17 00:00:00 2001
From: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>
Date: Mon, 1 Aug 2022 17:01:01 +0200
Subject: [PATCH 06/13] docs: Improve IF cmd execution docs (#2405)
Adds samples and better explains workflow.
---
docs/guides/int_framework/intro.md | 15 ++++++++++++++-
docs/guides/int_framework/samples/intro/event.cs | 14 ++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
create mode 100644 docs/guides/int_framework/samples/intro/event.cs
diff --git a/docs/guides/int_framework/intro.md b/docs/guides/int_framework/intro.md
index 5d3253a6f..b51aa8088 100644
--- a/docs/guides/int_framework/intro.md
+++ b/docs/guides/int_framework/intro.md
@@ -308,8 +308,19 @@ Any of the following socket events can be used to execute commands:
- [AutocompleteExecuted]
- [UserCommandExecuted]
- [MessageCommandExecuted]
+- [ModalExecuted]
-Commands can be either executed on the gateway thread or on a seperate thread from the thread pool. This behaviour can be configured by changing the *RunMode* property of `InteractionServiceConfig` or by setting the *runMode* parameter of a command attribute.
+These events will trigger for the specific type of interaction they inherit their name from. The [InteractionCreated] event will trigger for all.
+An example of executing a command from an event can be seen here:
+
+[!code-csharp[Command Event Example](samples/intro/event.cs)]
+
+Commands can be either executed on the gateway thread or on a seperate thread from the thread pool.
+This behaviour can be configured by changing the `RunMode` property of `InteractionServiceConfig` or by setting the *runMode* parameter of a command attribute.
+
+> [!WARNING]
+> In the example above, no form of post-execution is presented.
+> Please carefully read the [Post Execution Documentation] for the best approach in resolving the result based on your `RunMode`.
You can also configure the way [InteractionService] executes the commands.
By default, commands are executed using `ConstructorInfo.Invoke()` to create module instances and
@@ -364,6 +375,7 @@ delegate can be used to create HTTP responses from a deserialized json object st
[AutocompleteHandlers]: xref:Guides.IntFw.AutoCompletion
[DependencyInjection]: xref:Guides.TextCommands.DI
+[Post Execution Docuemntation]: xref:Guides.IntFw.PostExecution
[GroupAttribute]: xref:Discord.Interactions.GroupAttribute
[InteractionService]: xref:Discord.Interactions.InteractionService
@@ -376,6 +388,7 @@ delegate can be used to create HTTP responses from a deserialized json object st
[AutocompleteExecuted]: xref:Discord.WebSocket.BaseSocketClient
[UserCommandExecuted]: xref:Discord.WebSocket.BaseSocketClient
[MessageCommandExecuted]: xref:Discord.WebSocket.BaseSocketClient
+[ModalExecuted]: xref:Discord.WebSocket.BaseSocketClient
[DiscordSocketClient]: xref:Discord.WebSocket.DiscordSocketClient
[DiscordRestClient]: xref:Discord.Rest.DiscordRestClient
[SocketInteractionContext]: xref:Discord.Interactions.SocketInteractionContext
diff --git a/docs/guides/int_framework/samples/intro/event.cs b/docs/guides/int_framework/samples/intro/event.cs
new file mode 100644
index 000000000..0c9f032b9
--- /dev/null
+++ b/docs/guides/int_framework/samples/intro/event.cs
@@ -0,0 +1,14 @@
+// Theres multiple ways to subscribe to the event, depending on your application. Please use the approach fit to your type of client.
+// DiscordSocketClient:
+_socketClient.InteractionCreated += async (x) =>
+{
+ var ctx = new SocketInteractionContext(_socketClient, x);
+ await _interactionService.ExecuteCommandAsync(ctx, _serviceProvider);
+}
+
+// DiscordShardedClient:
+_shardedClient.InteractionCreated += async (x) =>
+{
+ var ctx = new ShardedInteractionContext(_shardedClient, x);
+ await _interactionService.ExecuteCommandAsync(ctx, _serviceProvider);
+}
From 010e8e828ff87212ebe8c2539cdc59c3949fa8ca Mon Sep 17 00:00:00 2001
From: CottageDwellingCat
<80918250+CottageDwellingCat@users.noreply.github.com>
Date: Mon, 1 Aug 2022 10:38:10 -0500
Subject: [PATCH 07/13] feat: Support the WEBHOOKS_UPDATED event (#2384)
Co-authored-by: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>
---
.../API/Gateway/WebhooksUpdatedEvent.cs | 13 ++++++
.../BaseSocketClient.Events.cs | 41 +++++++++++++------
.../DiscordShardedClient.cs | 2 +
.../DiscordSocketClient.cs | 20 +++++++--
4 files changed, 60 insertions(+), 16 deletions(-)
create mode 100644 src/Discord.Net.WebSocket/API/Gateway/WebhooksUpdatedEvent.cs
diff --git a/src/Discord.Net.WebSocket/API/Gateway/WebhooksUpdatedEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/WebhooksUpdatedEvent.cs
new file mode 100644
index 000000000..5555dc842
--- /dev/null
+++ b/src/Discord.Net.WebSocket/API/Gateway/WebhooksUpdatedEvent.cs
@@ -0,0 +1,13 @@
+using Newtonsoft.Json;
+
+namespace Discord.API.Gateway
+{
+ internal class WebhooksUpdatedEvent
+ {
+ [JsonProperty("guild_id")]
+ public ulong GuildId { get; set; }
+
+ [JsonProperty("channel_id")]
+ public ulong ChannelId { get; set; }
+ }
+}
diff --git a/src/Discord.Net.WebSocket/BaseSocketClient.Events.cs b/src/Discord.Net.WebSocket/BaseSocketClient.Events.cs
index c47591418..21b61c35c 100644
--- a/src/Discord.Net.WebSocket/BaseSocketClient.Events.cs
+++ b/src/Discord.Net.WebSocket/BaseSocketClient.Events.cs
@@ -106,7 +106,7 @@ namespace Discord.WebSocket
///
///
/// This event is fired when a message is deleted. The event handler must return a
- /// and accept a and
+ /// and accept a and
/// as its parameters.
///
///
@@ -117,11 +117,11 @@ namespace Discord.WebSocket
///
/// If caching is enabled via , the
/// entity will contain the deleted message; otherwise, in event
- /// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
+ /// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
/// .
///
///
- /// The source channel of the removed message will be passed into the
+ /// The source channel of the removed message will be passed into the
/// parameter.
///
///
@@ -143,7 +143,7 @@ namespace Discord.WebSocket
///
///
/// This event is fired when multiple messages are bulk deleted. The event handler must return a
- /// and accept an and
+ /// and accept an and
/// as its parameters.
///
///
@@ -154,11 +154,11 @@ namespace Discord.WebSocket
///
/// If caching is enabled via , the
/// entity will contain the deleted message; otherwise, in event
- /// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
+ /// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
/// .
///
///
- /// The source channel of the removed message will be passed into the
+ /// The source channel of the removed message will be passed into the
/// parameter.
///
///
@@ -178,14 +178,14 @@ namespace Discord.WebSocket
///
/// If caching is enabled via , the
/// entity will contain the original message; otherwise, in event
- /// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
+ /// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
/// .
///
///
/// The updated message will be passed into the parameter.
///
///
- /// The source channel of the updated message will be passed into the
+ /// The source channel of the updated message will be passed into the
/// parameter.
///
///
@@ -199,24 +199,24 @@ namespace Discord.WebSocket
///
///
/// This event is fired when a reaction is added to a user message. The event handler must return a
- /// and accept a , an
+ /// and accept a , an
/// , and a as its parameter.
///
///
/// If caching is enabled via , the
/// entity will contain the original message; otherwise, in event
- /// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
+ /// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
/// .
///
///
- /// The source channel of the reaction addition will be passed into the
+ /// The source channel of the reaction addition will be passed into the
/// parameter.
///
///
/// The reaction that was added will be passed into the parameter.
///
///
- /// When fetching the reaction from this event, a user may not be provided under
+ /// When fetching the reaction from this event, a user may not be provided under
/// . Please see the documentation of the property for more
/// information.
///
@@ -367,7 +367,7 @@ namespace Discord.WebSocket
}
internal readonly AsyncEvent, SocketGuildEvent, Task>> _guildScheduledEventUpdated = new AsyncEvent, SocketGuildEvent, Task>>();
-
+
///
/// Fired when a guild event is cancelled.
///
@@ -877,5 +877,20 @@ namespace Discord.WebSocket
}
internal readonly AsyncEvent> _guildStickerDeleted = new AsyncEvent>();
#endregion
+
+ #region Webhooks
+
+ ///
+ /// Fired when a webhook is modified, moved, or deleted. If the webhook was
+ /// moved the channel represents the destination channel, not the source.
+ ///
+ public event Func WebhooksUpdated
+ {
+ add { _webhooksUpdated.Add(value); }
+ remove { _webhooksUpdated.Remove(value); }
+ }
+ internal readonly AsyncEvent> _webhooksUpdated = new AsyncEvent>();
+
+ #endregion
}
}
diff --git a/src/Discord.Net.WebSocket/DiscordShardedClient.cs b/src/Discord.Net.WebSocket/DiscordShardedClient.cs
index 3a14692e0..9fc717762 100644
--- a/src/Discord.Net.WebSocket/DiscordShardedClient.cs
+++ b/src/Discord.Net.WebSocket/DiscordShardedClient.cs
@@ -496,6 +496,8 @@ namespace Discord.WebSocket
client.GuildScheduledEventStarted += (arg) => _guildScheduledEventStarted.InvokeAsync(arg);
client.GuildScheduledEventUserAdd += (arg1, arg2) => _guildScheduledEventUserAdd.InvokeAsync(arg1, arg2);
client.GuildScheduledEventUserRemove += (arg1, arg2) => _guildScheduledEventUserRemove.InvokeAsync(arg1, arg2);
+
+ client.WebhooksUpdated += (arg1, arg2) => _webhooksUpdated.InvokeAsync(arg1, arg2);
}
#endregion
diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs
index 5743d9abd..b87b52ffb 100644
--- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs
+++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs
@@ -2839,6 +2839,23 @@ namespace Discord.WebSocket
#endregion
+ #region Webhooks
+
+ case "WEBHOOKS_UPDATE":
+ {
+ var data = (payload as JToken).ToObject(_serializer);
+ type = "WEBHOOKS_UPDATE";
+ await _gatewayLogger.DebugAsync("Received Dispatch (WEBHOOKS_UPDATE)").ConfigureAwait(false);
+
+ var guild = State.GetGuild(data.GuildId);
+ var channel = State.GetChannel(data.ChanelId);
+
+ await TimedInvokeAsync(_webhooksUpdated, nameof(WebhooksUpdated), guild, channel);
+ }
+ break;
+
+ #endregion
+
#region Ignored (User only)
case "CHANNEL_PINS_ACK":
await _gatewayLogger.DebugAsync("Ignored Dispatch (CHANNEL_PINS_ACK)").ConfigureAwait(false);
@@ -2858,9 +2875,6 @@ namespace Discord.WebSocket
case "USER_SETTINGS_UPDATE":
await _gatewayLogger.DebugAsync("Ignored Dispatch (USER_SETTINGS_UPDATE)").ConfigureAwait(false);
break;
- case "WEBHOOKS_UPDATE":
- await _gatewayLogger.DebugAsync("Ignored Dispatch (WEBHOOKS_UPDATE)").ConfigureAwait(false);
- break;
#endregion
#region Others
From a663f61a8600a8b6ef88c0af75b0467f538cd4fb Mon Sep 17 00:00:00 2001
From: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>
Date: Mon, 1 Aug 2022 17:41:25 +0200
Subject: [PATCH 08/13] fix: Webhookupdated data naming
---
src/Discord.Net.WebSocket/DiscordSocketClient.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs
index b87b52ffb..3c5621304 100644
--- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs
+++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs
@@ -2848,7 +2848,7 @@ namespace Discord.WebSocket
await _gatewayLogger.DebugAsync("Received Dispatch (WEBHOOKS_UPDATE)").ConfigureAwait(false);
var guild = State.GetGuild(data.GuildId);
- var channel = State.GetChannel(data.ChanelId);
+ var channel = State.GetChannel(data.ChannelId);
await TimedInvokeAsync(_webhooksUpdated, nameof(WebhooksUpdated), guild, channel);
}
From cfd2662963ad0a6d77a587795d2fab3f13b053ab Mon Sep 17 00:00:00 2001
From: zaanposni
Date: Mon, 1 Aug 2022 17:43:11 +0200
Subject: [PATCH 09/13] docs: ChannelUpdated event xml comment (#2366)
---
src/Discord.Net.WebSocket/BaseSocketClient.Events.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Discord.Net.WebSocket/BaseSocketClient.Events.cs b/src/Discord.Net.WebSocket/BaseSocketClient.Events.cs
index 21b61c35c..fb2110399 100644
--- a/src/Discord.Net.WebSocket/BaseSocketClient.Events.cs
+++ b/src/Discord.Net.WebSocket/BaseSocketClient.Events.cs
@@ -55,7 +55,7 @@ namespace Discord.WebSocket
/// Fired when a channel is updated.
///
///
- /// This event is fired when a generic channel has been destroyed. The event handler must return a
+ /// This event is fired when a generic channel has been updated. The event handler must return a
/// and accept 2 as its parameters.
///
///
From 902326d1f368aa880c035472b33fcfd62d6c39d3 Mon Sep 17 00:00:00 2001
From: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>
Date: Mon, 1 Aug 2022 18:53:22 +0200
Subject: [PATCH 10/13] fix: Range of issues presented by analyzer (#2404)
---
.../BuildOverrides.cs | 2 +-
.../Entities/Guilds/GuildFeature.cs | 86 +++++++++----------
.../SlashCommands/NullableConverter.cs | 5 +-
src/Discord.Net.Rest/DiscordRestApiClient.cs | 2 +-
.../DataTypes/ThreadUpdateAuditLogData.cs | 2 +-
.../Entities/Guilds/GuildHelper.cs | 2 +-
.../Entities/Interactions/RestInteraction.cs | 2 +-
.../Entities/Guilds/SocketGuild.cs | 9 +-
.../SocketBaseCommand/SocketResolvableData.cs | 4 +-
9 files changed, 56 insertions(+), 58 deletions(-)
diff --git a/experiment/Discord.Net.BuildOverrides/BuildOverrides.cs b/experiment/Discord.Net.BuildOverrides/BuildOverrides.cs
index 54b56cc60..54bc362ec 100644
--- a/experiment/Discord.Net.BuildOverrides/BuildOverrides.cs
+++ b/experiment/Discord.Net.BuildOverrides/BuildOverrides.cs
@@ -251,7 +251,7 @@ namespace Discord
private static Assembly _overrideDomain_Resolving(AssemblyLoadContext arg1, AssemblyName arg2)
{
// resolve the override id
- var v = _loadedOverrides.FirstOrDefault(x => x.Value.Any(x => x.Assembly.FullName == arg1.Assemblies.FirstOrDefault().FullName));
+ var v = _loadedOverrides.FirstOrDefault(x => x.Value.Any(x => x.Assembly.FullName == arg1.Assemblies.First().FullName));
return GetDependencyAsync(v.Key.Id, $"{arg2}").GetAwaiter().GetResult();
}
diff --git a/src/Discord.Net.Core/Entities/Guilds/GuildFeature.cs b/src/Discord.Net.Core/Entities/Guilds/GuildFeature.cs
index cb57b2726..52a70a6f5 100644
--- a/src/Discord.Net.Core/Entities/Guilds/GuildFeature.cs
+++ b/src/Discord.Net.Core/Entities/Guilds/GuildFeature.cs
@@ -12,174 +12,174 @@ namespace Discord
///
/// The guild has no features.
///
- None = 0,
+ None = 0L,
///
/// The guild has access to animated banners.
///
- AnimatedBanner = 1 << 0,
+ AnimatedBanner = 1L << 0,
///
/// The guild has access to set an animated guild icon.
///
- AnimatedIcon = 1 << 1,
+ AnimatedIcon = 1L << 1,
///
/// The guild has access to set a guild banner image.
///
- Banner = 1 << 2,
+ Banner = 1L << 2,
///
/// The guild has access to channel banners.
///
- ChannelBanner = 1 << 3,
+ ChannelBanner = 1L << 3,
///
/// The guild has access to use commerce features (i.e. create store channels).
///
- Commerce = 1 << 4,
+ Commerce = 1L << 4,
///
/// The guild can enable welcome screen, Membership Screening, stage channels and discovery, and receives community updates.
///
- Community = 1 << 5,
+ Community = 1L << 5,
///
/// The guild is able to be discovered in the directory.
///
- Discoverable = 1 << 6,
+ Discoverable = 1L << 6,
///
/// The guild has discoverable disabled.
///
- DiscoverableDisabled = 1 << 7,
+ DiscoverableDisabled = 1L << 7,
///
/// The guild has enabled discoverable before.
///
- EnabledDiscoverableBefore = 1 << 8,
+ EnabledDiscoverableBefore = 1L << 8,
///
/// The guild is able to be featured in the directory.
///
- Featureable = 1 << 9,
+ Featureable = 1L << 9,
///
/// The guild has a force relay.
///
- ForceRelay = 1 << 10,
+ ForceRelay = 1L << 10,
///
/// The guild has a directory entry.
///
- HasDirectoryEntry = 1 << 11,
+ HasDirectoryEntry = 1L << 11,
///
/// The guild is a hub.
///
- Hub = 1 << 12,
+ Hub = 1L << 12,
///
/// You shouldn't be here...
///
- InternalEmployeeOnly = 1 << 13,
+ InternalEmployeeOnly = 1L << 13,
///
/// The guild has access to set an invite splash background.
///
- InviteSplash = 1 << 14,
+ InviteSplash = 1L << 14,
///
/// The guild is linked to a hub.
///
- LinkedToHub = 1 << 15,
+ LinkedToHub = 1L << 15,
///
/// The guild has member profiles.
///
- MemberProfiles = 1 << 16,
+ MemberProfiles = 1L << 16,
///
/// The guild has enabled Membership Screening.
///
- MemberVerificationGateEnabled = 1 << 17,
+ MemberVerificationGateEnabled = 1L << 17,
///
/// The guild has enabled monetization.
///
- MonetizationEnabled = 1 << 18,
+ MonetizationEnabled = 1L << 18,
///
/// The guild has more emojis.
///
- MoreEmoji = 1 << 19,
+ MoreEmoji = 1L << 19,
///
/// The guild has increased custom sticker slots.
///
- MoreStickers = 1 << 20,
+ MoreStickers = 1L << 20,
///
/// The guild has access to create news channels.
///
- News = 1 << 21,
+ News = 1L << 21,
///
/// The guild has new thread permissions.
///
- NewThreadPermissions = 1 << 22,
+ NewThreadPermissions = 1L << 22,
///
/// The guild is partnered.
///
- Partnered = 1 << 23,
+ Partnered = 1L << 23,
///
/// The guild has a premium tier three override; guilds made by Discord usually have this.
///
- PremiumTier3Override = 1 << 24,
+ PremiumTier3Override = 1L << 24,
///
/// The guild can be previewed before joining via Membership Screening or the directory.
///
- PreviewEnabled = 1 << 25,
+ PreviewEnabled = 1L << 25,
///
/// The guild has access to create private threads.
///
- PrivateThreads = 1 << 26,
+ PrivateThreads = 1L << 26,
///
/// The guild has relay enabled.
///
- RelayEnabled = 1 << 27,
+ RelayEnabled = 1L << 27,
///
/// The guild is able to set role icons.
///
- RoleIcons = 1 << 28,
+ RoleIcons = 1L << 28,
///
/// The guild has role subscriptions available for purchase.
///
- RoleSubscriptionsAvailableForPurchase = 1 << 29,
+ RoleSubscriptionsAvailableForPurchase = 1L << 29,
///
/// The guild has role subscriptions enabled.
///
- RoleSubscriptionsEnabled = 1 << 30,
+ RoleSubscriptionsEnabled = 1L << 30,
///
/// The guild has access to the seven day archive time for threads.
///
- SevenDayThreadArchive = 1 << 31,
+ SevenDayThreadArchive = 1L << 31,
///
/// The guild has text in voice enabled.
///
- TextInVoiceEnabled = 1 << 32,
+ TextInVoiceEnabled = 1L << 32,
///
/// The guild has threads enabled.
///
- ThreadsEnabled = 1 << 33,
+ ThreadsEnabled = 1L << 33,
///
/// The guild has testing threads enabled.
///
- ThreadsEnabledTesting = 1 << 34,
+ ThreadsEnabledTesting = 1L << 34,
///
/// The guild has the default thread auto archive.
///
- ThreadsDefaultAutoArchiveDuration = 1 << 35,
+ ThreadsDefaultAutoArchiveDuration = 1L << 35,
///
/// The guild has access to the three day archive time for threads.
///
- ThreeDayThreadArchive = 1 << 36,
+ ThreeDayThreadArchive = 1L << 36,
///
/// The guild has enabled ticketed events.
///
- TicketedEventsEnabled = 1 << 37,
+ TicketedEventsEnabled = 1L << 37,
///
/// The guild has access to set a vanity URL.
///
- VanityUrl = 1 << 38,
+ VanityUrl = 1L << 38,
///
/// The guild is verified.
///
- Verified = 1 << 39,
+ Verified = 1L << 39,
///
/// The guild has access to set 384kbps bitrate in voice (previously VIP voice servers).
///
- VIPRegions = 1 << 40,
+ VIPRegions = 1L << 40,
///
/// The guild has enabled the welcome screen.
///
- WelcomeScreenEnabled = 1 << 41,
+ WelcomeScreenEnabled = 1L << 41,
}
}
diff --git a/src/Discord.Net.Interactions/TypeConverters/SlashCommands/NullableConverter.cs b/src/Discord.Net.Interactions/TypeConverters/SlashCommands/NullableConverter.cs
index 874171175..d85b376d1 100644
--- a/src/Discord.Net.Interactions/TypeConverters/SlashCommands/NullableConverter.cs
+++ b/src/Discord.Net.Interactions/TypeConverters/SlashCommands/NullableConverter.cs
@@ -9,10 +9,11 @@ namespace Discord.Interactions
public NullableConverter(InteractionService interactionService, IServiceProvider services)
{
- var type = Nullable.GetUnderlyingType(typeof(T));
+ var nullableType = typeof(T);
+ var type = Nullable.GetUnderlyingType(nullableType);
if (type is null)
- throw new ArgumentException($"No type {nameof(TypeConverter)} is defined for this {type.FullName}", "type");
+ throw new ArgumentException($"No type {nameof(TypeConverter)} is defined for this {nullableType.FullName}", nameof(type));
_typeConverter = interactionService.GetTypeConverter(type, services);
}
diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs
index e179675ba..c5b075103 100644
--- a/src/Discord.Net.Rest/DiscordRestApiClient.cs
+++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs
@@ -1756,7 +1756,7 @@ namespace Discord.API
if (args.TargetType.Value == TargetUserType.Stream)
Preconditions.GreaterThan(args.TargetUserId, 0, nameof(args.TargetUserId));
if (args.TargetType.Value == TargetUserType.EmbeddedApplication)
- Preconditions.GreaterThan(args.TargetApplicationId, 0, nameof(args.TargetUserId));
+ Preconditions.GreaterThan(args.TargetApplicationId, 0, nameof(args.TargetApplicationId));
}
options = RequestOptions.CreateOrClone(options);
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadUpdateAuditLogData.cs
index 2b9b95418..8eb03114d 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadUpdateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ThreadUpdateAuditLogData.cs
@@ -15,7 +15,7 @@ namespace Discord.Rest
Thread = thread;
ThreadType = type;
Before = before;
- After = After;
+ After = after;
}
internal static ThreadUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
diff --git a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
index 8bab35937..20140994f 100644
--- a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
@@ -428,7 +428,7 @@ namespace Discord.Rest
var ids = args.Roles.Value.Select(r => r.Id);
if (args.RoleIds.IsSpecified)
- args.RoleIds.Value.Concat(ids);
+ args.RoleIds = Optional.Create(args.RoleIds.Value.Concat(ids));
else
args.RoleIds = Optional.Create(ids);
}
diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestInteraction.cs b/src/Discord.Net.Rest/Entities/Interactions/RestInteraction.cs
index 43d13f521..ba2de12a9 100644
--- a/src/Discord.Net.Rest/Entities/Interactions/RestInteraction.cs
+++ b/src/Discord.Net.Rest/Entities/Interactions/RestInteraction.cs
@@ -426,7 +426,7 @@ namespace Discord.Rest
AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options)
=> await FollowupWithFileAsync(fileStream, fileName, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false);
///
- async Task IDiscordInteraction.FollowupWithFileAsync(string filePath, string text, string fileName, Embed[] embeds, bool isTTS, bool ephemeral,
+ async Task IDiscordInteraction.FollowupWithFileAsync(string filePath, string fileName, string text, Embed[] embeds, bool isTTS, bool ephemeral,
AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options)
=> await FollowupWithFileAsync(filePath, text, fileName, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false);
///
diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
index 9ce2f507a..cf01857e3 100644
--- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
+++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
@@ -532,13 +532,10 @@ namespace Discord.WebSocket
Features = model.Features;
var roles = new ConcurrentDictionary(ConcurrentHashSet.DefaultConcurrencyLevel, (int)(model.Roles.Length * 1.05));
- if (model.Roles != null)
+ for (int i = 0; i < model.Roles.Length; i++)
{
- for (int i = 0; i < model.Roles.Length; i++)
- {
- var role = SocketRole.Create(this, state, model.Roles[i]);
- roles.TryAdd(role.Id, role);
- }
+ var role = SocketRole.Create(this, state, model.Roles[i]);
+ roles.TryAdd(role.Id, role);
}
_roles = roles;
diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketResolvableData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketResolvableData.cs
index a629fd069..98a7daefc 100644
--- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketResolvableData.cs
+++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketResolvableData.cs
@@ -39,7 +39,7 @@ namespace Discord.WebSocket
{
foreach (var channel in resolved.Channels.Value)
{
- SocketChannel socketChannel = guild != null
+ var socketChannel = guild != null
? guild.GetChannel(channel.Value.Id)
: discord.GetChannel(channel.Value.Id);
@@ -69,7 +69,7 @@ namespace Discord.WebSocket
}
}
- if (resolved.Roles.IsSpecified)
+ if (resolved.Roles.IsSpecified && guild != null)
{
foreach (var role in resolved.Roles.Value)
{
From 519deda6e75eaccd9a03106b7c50ea0f54e95e99 Mon Sep 17 00:00:00 2001
From: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>
Date: Mon, 1 Aug 2022 21:46:27 +0200
Subject: [PATCH 11/13] fix: Sharding sample inaccurate (#2408)
---
.../Services/InteractionHandlingService.cs | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/samples/ShardedClient/Services/InteractionHandlingService.cs b/samples/ShardedClient/Services/InteractionHandlingService.cs
index 3c41d7f33..fc2af8150 100644
--- a/samples/ShardedClient/Services/InteractionHandlingService.cs
+++ b/samples/ShardedClient/Services/InteractionHandlingService.cs
@@ -22,6 +22,7 @@ namespace ShardedClient.Services
_service.Log += LogAsync;
_client.InteractionCreated += OnInteractionAsync;
+ _client.ShardReady += ReadyAsync;
// For examples on how to handle post execution,
// see the InteractionFramework samples.
}
@@ -30,11 +31,6 @@ namespace ShardedClient.Services
public async Task InitializeAsync()
{
await _service.AddModulesAsync(typeof(InteractionHandlingService).Assembly, _provider);
-#if DEBUG
- await _service.RegisterCommandsToGuildAsync(1 /* implement */);
-#else
- await _service.RegisterCommandsGloballyAsync();
-#endif
}
private async Task OnInteractionAsync(SocketInteraction interaction)
@@ -53,5 +49,14 @@ namespace ShardedClient.Services
return Task.CompletedTask;
}
+
+ private async Task ReadyAsync(DiscordSocketClient _)
+ {
+#if DEBUG
+ await _service.RegisterCommandsToGuildAsync(1 /* implement */);
+#else
+ await _service.RegisterCommandsGloballyAsync();
+#endif
+ }
}
}
From bf493ea04007fcf186bdb3d80e3b6993c25d9eef Mon Sep 17 00:00:00 2001
From: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>
Date: Mon, 1 Aug 2022 21:47:53 +0200
Subject: [PATCH 12/13] feat: Labs deprecation & readme expansion (#2406)
---
CONTRIBUTING.md | 3 +-
README.md | 83 ++++++++++++++--------
docs/faq/basics/client-basics.md | 2 +-
docs/guides/getting_started/installing.md | 20 ++++--
docs/guides/getting_started/labs.md | 30 --------
docs/guides/getting_started/terminology.md | 12 ++--
docs/guides/toc.yml | 3 -
docs/guides/v2_v3_guide/v2_to_v3_guide.md | 2 +-
8 files changed, 78 insertions(+), 77 deletions(-)
delete mode 100644 docs/guides/getting_started/labs.md
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 840650cf8..1455267f9 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -7,8 +7,7 @@ following guidelines when possible:
## Development Cycle
We prefer all changes to the library to be discussed beforehand,
-either in a GitHub issue, or in a discussion in our Discord channel
-with library regulars or other contributors.
+either in a GitHub issue, or in a discussion in our [Discord server](https://discord.gg/dnet)
Issues that are tagged as "up for grabs" are free to be picked up by
any member of the community.
diff --git a/README.md b/README.md
index e85216dbf..7b98a5f41 100644
--- a/README.md
+++ b/README.md
@@ -19,11 +19,11 @@
Discord.Net is an unofficial .NET API Wrapper for the Discord client (https://discord.com).
-## Documentation
+## 📄 Documentation
-- [Nightly](https://discordnet.dev)
+- https://discordnet.dev
-## Installation
+## 📥 Installation
### Stable (NuGet)
@@ -33,55 +33,78 @@ Our stable builds available from NuGet through the Discord.Net metapackage:
The individual components may also be installed from NuGet:
-- [Discord.Net.Commands](https://www.nuget.org/packages/Discord.Net.Commands/)
-- [Discord.Net.Rest](https://www.nuget.org/packages/Discord.Net.Rest/)
-- [Discord.Net.WebSocket](https://www.nuget.org/packages/Discord.Net.WebSocket/)
-- [Discord.Net.Webhook](https://www.nuget.org/packages/Discord.Net.Webhook/)
+- _Webhooks_
+ - [Discord.Net.Webhook](https://www.nuget.org/packages/Discord.Net.Webhook/)
-### Unstable (MyGet)
+- _Text-Command & Interaction services._
+ - [Discord.Net.Commands](https://www.nuget.org/packages/Discord.Net.Commands/)
+ - [Discord.Net.Interactions](https://www.nuget.org/packages/Discord.Net.Interactions/)
-Nightly builds are available through our MyGet feed (`https://www.myget.org/F/discord-net/api/v3/index.json`).
+- _Complete API coverage._
+ - [Discord.Net.WebSocket](https://www.nuget.org/packages/Discord.Net.WebSocket/)
+ - [Discord.Net.Rest](https://www.nuget.org/packages/Discord.Net.Rest/)
-### Unstable (Labs)
+- _The API core. Implements only entities and barebones functionality._
+ - [Discord.Net.Core](https://www.nuget.org/packages/Discord.Net.Core/)
-Labs builds are available on nuget (`https://www.nuget.org/packages/Discord.Net.Labs/`) and myget (`https://www.myget.org/F/discord-net-labs/api/v3/index.json`).
+### Unstable
-## Compiling
+Nightly builds are available through our MyGet feed (`https://www.myget.org/F/discord-net/api/v3/index.json`).
+These builds target the dev branch.
-In order to compile Discord.Net, you require the following:
+## 🛑 Known Issues
-### Using Visual Studio
+### WebSockets (Win7 and earlier)
-- [Visual Studio 2017](https://www.microsoft.com/net/core#windowsvs2017)
-- [.NET Core SDK](https://www.microsoft.com/net/download/core)
+.NET Core 1.1 does not support WebSockets on Win7 and earlier.
+This issue has been fixed since the release of .NET Core 2.1.
+It is recommended to target .NET Core 2.1 or above for your project if you wish to run your bot on legacy platforms;
+alternatively, you may choose to install the
+[Discord.Net.Providers.WS4Net](https://www.nuget.org/packages/Discord.Net.Providers.WS4Net/) package.
-The .NET Core workload must be selected during Visual Studio installation.
+### TLS on .NET Framework.
-### Using Command Line
+Discord supports only TLS1.2+ on all their websites including the API since 07/19/2022.
+.NET Framework does not support this protocol by default.
+If you depend on .NET Framework, it is suggested to upgrade your project to `net6-windows`.
+This framework supports most of the windows-only features introduced by fx, and resolves startup errors from the TLS protocol mismatch.
-- [.NET Core SDK](https://www.microsoft.com/net/download/core)
+## 🗃️ Versioning Guarantees
-## Known Issues
+This library generally abides by [Semantic Versioning](https://semver.org). Packages are published in `MAJOR.MINOR.PATCH` version format.
-### WebSockets (Win7 and earlier)
+### Patch component
-.NET Core 1.1 does not support WebSockets on Win7 and earlier. This issue has been fixed since the release of .NET Core 2.1. It is recommended to target .NET Core 2.1 or above for your project if you wish to run your bot on legacy platforms; alternatively, you may choose to install the [Discord.Net.Providers.WS4Net](https://www.nuget.org/packages/Discord.Net.Providers.WS4Net/) package.
+An increment of the **PATCH** component always indicates that an internal-only change was made, generally a bugfix. These changes will not affect the public-facing API in any way, and are always guaranteed to be forward- and backwards-compatible with your codebase, any pre-compiled dependencies of your codebase.
-## Versioning Guarantees
+### Minor component
-This library generally abides by [Semantic Versioning](https://semver.org). Packages are published in MAJOR.MINOR.PATCH version format.
+An increment of the **MINOR** component indicates that some addition was made to the library,
+and this addition is not backwards-compatible with prior versions.
+However, Discord.Net **does not guarantee forward-compatibility** on minor additions.
+In other words, we permit a limited set of breaking changes on a minor version bump.
-An increment of the PATCH component always indicates that an internal-only change was made, generally a bugfix. These changes will not affect the public-facing API in any way, and are always guaranteed to be forward- and backwards-compatible with your codebase, any pre-compiled dependencies of your codebase.
+Due to the nature of the Discord API, we will oftentimes need to add a property to an entity to support the latest API changes.
+Discord.Net provides interfaces as a method of consuming entities; and as such, introducing a new field to an entity is technically a breaking change.
+Major version bumps generally indicate some major change to the library,
+and as such we are hesitant to bump the major version for every minor addition to the library.
+To compromise, we have decided that interfaces should be treated as **consumable only**,
+and your applications should typically not be implementing interfaces.
-An increment of the MINOR component indicates that some addition was made to the library, and this addition is not backwards-compatible with prior versions. However, Discord.Net **does not guarantee forward-compatibility** on minor additions. In other words, we permit a limited set of breaking changes on a minor version bump.
+> For applications where interfaces are implemented, such as in test mocks, we apologize for this inconsistency with SemVer.
-Due to the nature of the Discord API, we will oftentimes need to add a property to an entity to support the latest API changes. Discord.Net provides interfaces as a method of consuming entities; and as such, introducing a new field to an entity is technically a breaking change. Major version bumps generally indicate some major change to the library, and as such we are hesitant to bump the major version for every minor addition to the library. To compromise, we have decided that interfaces should be treated as **consumable only**, and your applications should typically not be implementing interfaces. (For applications where interfaces are implemented, such as in test mocks, we apologize for this inconsistency with SemVer).
+While we will never break the API (outside of interface changes) on minor builds,
+we will occasionally need to break the ABI, by introducing parameters to a method to match changes upstream with Discord.
+As such, a minor version increment may require you to recompile your code, and dependencies,
+such as addons, may also need to be recompiled and republished on the newer version.
+When a binary breaking change is made, the change will be noted in the release notes.
-Furthermore, while we will never break the API (outside of interface changes) on minor builds, we will occasionally need to break the ABI, by introducing parameters to a method to match changes upstream with Discord. As such, a minor version increment may require you to recompile your code, and dependencies, such as addons, may also need to be recompiled and republished on the newer version. When a binary breaking change is made, the change will be noted in the release notes.
+### Major component
-An increment of the MAJOR component indicates that breaking changes have been made to the library; consumers should check the release notes to determine what changes need to be made.
+An increment of the **MAJOR** component indicates that breaking changes have been made to the library;
+consumers should check the release notes to determine what changes need to be made.
-## Branches
+## 📚 Branches
### Release/X.X
diff --git a/docs/faq/basics/client-basics.md b/docs/faq/basics/client-basics.md
index ade33c35d..3f21dd165 100644
--- a/docs/faq/basics/client-basics.md
+++ b/docs/faq/basics/client-basics.md
@@ -36,7 +36,7 @@ _client = new DiscordSocketClient(config);
This includes intents that receive messages such as: `GatewayIntents.GuildMessages, GatewayIntents.DirectMessages`
- GuildMembers: An intent disabled by default, as you need to enable it in the [developer portal].
- GuildPresences: Also disabled by default, this intent together with `GuildMembers` are the only intents not included in `AllUnprivileged`.
-- All: All intents, it is ill adviced to use this without care, as it *can* cause a memory leak from presence.
+- All: All intents, it is ill advised to use this without care, as it _can_ cause a memory leak from presence.
The library will give responsive warnings if you specify unnecessary intents.
diff --git a/docs/guides/getting_started/installing.md b/docs/guides/getting_started/installing.md
index 0dde72380..d07787b67 100644
--- a/docs/guides/getting_started/installing.md
+++ b/docs/guides/getting_started/installing.md
@@ -30,17 +30,25 @@ other limitations, you may also consider targeting [.NET Framework]
[.net framework]: https://docs.microsoft.com/en-us/dotnet/framework/get-started/
[additional steps]: #installing-on-net-standard-11
-## Installing with NuGet
+## Installing
Release builds of Discord.Net will be published to the
[official NuGet feed].
-Development builds of Discord.Net, as well as add-ons, will be
-published to our [MyGet feed]. See
-@Guides.GettingStarted.Installation.Nightlies to learn more.
+### Experimental/Development
-[official nuget feed]: https://nuget.org
-[myget feed]: https://www.myget.org/feed/Packages/discord-net
+Development builds of Discord.Net will be
+published to our [MyGet feed]. The MyGet feed can be used to run the latest dev branch builds.
+It is not advised to use MyGet packages in a production environment, as changes may be made that negatively affect certain library functions.
+
+### Labs
+
+This exterior branch of Discord.Net has been deprecated and is no longer supported.
+If you have used Discord.Net-Labs in the past, you are advised to update to the latest version of Discord.Net.
+All features in Labs are implemented in the main repository.
+
+[official NuGet feed]: https://nuget.org
+[MyGet feed]: https://www.myget.org/feed/Packages/discord-net
### [Using Visual Studio](#tab/vs-install)
diff --git a/docs/guides/getting_started/labs.md b/docs/guides/getting_started/labs.md
deleted file mode 100644
index e52014312..000000000
--- a/docs/guides/getting_started/labs.md
+++ /dev/null
@@ -1,30 +0,0 @@
----
-uid: Guides.GettingStarted.Installation.Labs
-title: Installing Labs builds
----
-
-# Installing Discord.NET Labs
-
-Discord.NET Labs is the experimental repository that introduces new features & chips away at all bugs until ready for merging into Discord.NET.
-Are you looking to test or play with new features?
-
-> [!IMPORTANT]
-> It is very ill advised to use Discord.NET Labs in a production environment normally,
-> considering it can include bugs that have not been discovered yet, as features are freshly added.
-> However if approached correctly, will work as a pre-release to Discord.NET.
-> Make sure to report any bugs at the Labs [repository] or on [Discord]
-
-[Discord]: https://discord.gg/dnet
-[repository]: https://github.com/Discord-Net-Labs/Discord.Net-Labs
-
-## Installation:
-
-[NuGet] - This only includes releases, on which features are ready to test.
-
-> [!NOTE]
-> Installing NuGet packages is covered fully at [Installing Discord NET](xref:Guides.GettingStarted.Installation)
-
-[MyGet] - Available for current builds and unreleased features.
-
-[NuGet]: https://www.nuget.org/packages/Discord.Net.Labs/
-[MyGet]: https://www.myget.org/feed/Packages/discord-net-labs
diff --git a/docs/guides/getting_started/terminology.md b/docs/guides/getting_started/terminology.md
index 0f24edd6f..facf1c790 100644
--- a/docs/guides/getting_started/terminology.md
+++ b/docs/guides/getting_started/terminology.md
@@ -8,18 +8,22 @@ title: Terminology
## Preface
Most terms for objects remain the same between 0.9 and 1.0 and above.
-The major difference is that the ``Server`` is now called ``Guild``
+The major difference is that the `Server` is now called `Guild`
to stay in line with Discord internally.
## Implementation Specific Entities
Discord.Net is split into a core library and two different
implementations - `Discord.Net.Core`, `Discord.Net.Rest`, and
-`Discord.Net.WebSockets`.
+`Discord.Net.WebSocket`.
-As a bot developer, you will only need to use `Discord.Net.WebSockets`,
+You will typically only need to use `Discord.Net.WebSocket`,
but you should be aware of the differences between them.
+> [!TIP]
+> If you are looking to implement Rest based interactions, or handle calls over REST in any other way,
+> `Discord.Net.Rest` is the resource most applicable to you.
+
`Discord.Net.Core` provides a set of interfaces that models Discord's
API. These interfaces are consistent throughout all implementations of
Discord.Net, and if you are writing an implementation-agnostic library
@@ -33,4 +37,4 @@ implementation are prefixed with `Rest` (e.g., `RestChannel`).
`Discord.Net.WebSocket` provides a set of concrete classes that are
used primarily with Discord's WebSocket API or entities that are kept
in cache. When developing bots, you will be using this implementation.
-All entities are prefixed with `Socket` (e.g., `SocketChannel`).
\ No newline at end of file
+All entities are prefixed with `Socket` (e.g., `SocketChannel`).
diff --git a/docs/guides/toc.yml b/docs/guides/toc.yml
index f122ea6ba..45f3983af 100644
--- a/docs/guides/toc.yml
+++ b/docs/guides/toc.yml
@@ -6,9 +6,6 @@
items:
- name: Installation
topicUid: Guides.GettingStarted.Installation
- items:
- - name: Nightly builds
- topicUid: Guides.GettingStarted.Installation.Labs
- name: Your First Bot
topicUid: Guides.GettingStarted.FirstBot
- name: Terminology
diff --git a/docs/guides/v2_v3_guide/v2_to_v3_guide.md b/docs/guides/v2_v3_guide/v2_to_v3_guide.md
index 6b4fa5282..a837f44d2 100644
--- a/docs/guides/v2_v3_guide/v2_to_v3_guide.md
+++ b/docs/guides/v2_v3_guide/v2_to_v3_guide.md
@@ -38,7 +38,7 @@ _client = new DiscordSocketClient(config);
This includes intents that receive messages such as: `GatewayIntents.GuildMessages, GatewayIntents.DirectMessages`
- GuildMembers: An intent disabled by default, as you need to enable it in the [developer portal].
- GuildPresences: Also disabled by default, this intent together with `GuildMembers` are the only intents not included in `AllUnprivileged`.
-- All: All intents, it is ill adviced to use this without care, as it _can_ cause a memory leak from presence.
+- All: All intents, it is ill advised to use this without care, as it _can_ cause a memory leak from presence.
The library will give responsive warnings if you specify unnecessary intents.
> [!NOTE]
From 503fa755a011c2fa52ccc76bce74ad712c949aff Mon Sep 17 00:00:00 2001
From: SKProCH <29896317+SKProCH@users.noreply.github.com>
Date: Tue, 2 Aug 2022 12:19:31 +0300
Subject: [PATCH 13/13] feat: Add async callbacks for IModuleBase (#2370)
---
.../Builders/ModuleClassBuilder.cs | 2 ++
src/Discord.Net.Commands/IModuleBase.cs | 13 +++++++++++++
src/Discord.Net.Commands/ModuleBase.cs | 12 ++++++++++++
3 files changed, 27 insertions(+)
diff --git a/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs b/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs
index 22c58f5c7..f98c81abd 100644
--- a/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs
+++ b/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs
@@ -206,6 +206,7 @@ namespace Discord.Commands
try
{
+ await instance.BeforeExecuteAsync(cmd).ConfigureAwait(false);
instance.BeforeExecute(cmd);
var task = method.Invoke(instance, args) as Task ?? Task.Delay(0);
@@ -221,6 +222,7 @@ namespace Discord.Commands
}
finally
{
+ await instance.AfterExecuteAsync(cmd).ConfigureAwait(false);
instance.AfterExecute(cmd);
(instance as IDisposable)?.Dispose();
}
diff --git a/src/Discord.Net.Commands/IModuleBase.cs b/src/Discord.Net.Commands/IModuleBase.cs
index 8b021f4de..7a953b47b 100644
--- a/src/Discord.Net.Commands/IModuleBase.cs
+++ b/src/Discord.Net.Commands/IModuleBase.cs
@@ -1,4 +1,5 @@
using Discord.Commands.Builders;
+using System.Threading.Tasks;
namespace Discord.Commands
{
@@ -13,12 +14,24 @@ namespace Discord.Commands
/// The context to set.
void SetContext(ICommandContext context);
+ ///
+ /// Executed asynchronously before a command is run in this module base.
+ ///
+ /// The command thats about to run.
+ Task BeforeExecuteAsync(CommandInfo command);
+
///
/// Executed before a command is run in this module base.
///
/// The command thats about to run.
void BeforeExecute(CommandInfo command);
+ ///
+ /// Executed asynchronously after a command is run in this module base.
+ ///
+ /// The command thats about to run.
+ Task AfterExecuteAsync(CommandInfo command);
+
///
/// Executed after a command is ran in this module base.
///
diff --git a/src/Discord.Net.Commands/ModuleBase.cs b/src/Discord.Net.Commands/ModuleBase.cs
index 5008cca35..b2d6ba119 100644
--- a/src/Discord.Net.Commands/ModuleBase.cs
+++ b/src/Discord.Net.Commands/ModuleBase.cs
@@ -46,6 +46,11 @@ namespace Discord.Commands
return await Context.Channel.SendMessageAsync(message, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds).ConfigureAwait(false);
}
///
+ /// The method to execute asynchronously before executing the command.
+ ///
+ /// The of the command to be executed.
+ protected virtual Task BeforeExecuteAsync(CommandInfo command) => Task.CompletedTask;
+ ///
/// The method to execute before executing the command.
///
/// The of the command to be executed.
@@ -53,6 +58,11 @@ namespace Discord.Commands
{
}
///
+ /// The method to execute asynchronously after executing the command.
+ ///
+ /// The of the command to be executed.
+ protected virtual Task AfterExecuteAsync(CommandInfo command) => Task.CompletedTask;
+ ///
/// The method to execute after executing the command.
///
/// The of the command to be executed.
@@ -76,7 +86,9 @@ namespace Discord.Commands
var newValue = context as T;
Context = newValue ?? throw new InvalidOperationException($"Invalid context type. Expected {typeof(T).Name}, got {context.GetType().Name}.");
}
+ Task IModuleBase.BeforeExecuteAsync(CommandInfo command) => BeforeExecuteAsync(command);
void IModuleBase.BeforeExecute(CommandInfo command) => BeforeExecute(command);
+ Task IModuleBase.AfterExecuteAsync(CommandInfo command) => AfterExecuteAsync(command);
void IModuleBase.AfterExecute(CommandInfo command) => AfterExecute(command);
void IModuleBase.OnModuleBuilding(CommandService commandService, ModuleBuilder builder) => OnModuleBuilding(commandService, builder);
#endregion