Remora.Discord.Gateway 13.0.0

Prefix Reserved
dotnet add package Remora.Discord.Gateway --version 13.0.0
                    
NuGet\Install-Package Remora.Discord.Gateway -Version 13.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Remora.Discord.Gateway" Version="13.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Remora.Discord.Gateway" Version="13.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Remora.Discord.Gateway" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Remora.Discord.Gateway --version 13.0.0
                    
#r "nuget: Remora.Discord.Gateway, 13.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Remora.Discord.Gateway&version=13.0.0
                    
Install Remora.Discord.Gateway as a Cake Addin
#tool nuget:?package=Remora.Discord.Gateway&version=13.0.0
                    
Install Remora.Discord.Gateway as a Cake Tool

Remora.Discord.Gateway

This package provides a fully-featured implementation of a Discord gateway client, complete with resume capabilities and user-facing events.

Structure

The package consists of two main parts - the client itself, and the event dispatch system. The latter will be familiar to users of the mediator pattern, wherein an intermediate type handles communication between separate objects; in Remora.Discord.Gateway's case, all incoming Discord events are dispatched and executed concurrently with each other, and the user may register responders to handle these events.

Provided you yourself do not inject services with a shared mutable state, all responders are thread-safe and do not require additional synchronization through semaphores or mutexes.

The client is a singleton service by design.

Usage

First and foremost, the gateway client must be registered with your dependency injection container.

services.AddDiscordGateway(serviceProvider => GetTokenFromSomewhere(serviceProvider));

Two things to note:

  • You are not required to call any other methods from dependency libraries (such as Remora.Discord.API) - this call takes care of all transitive dependencies itself.
  • You must, at this point, provide a way to access your bot's token in plain text. This access only happens after the container is constructed, and an API instance is requested, so you have access to the built container.

After this point, you may inject the gateway client into your own services. In order to connect and start dispatching events, you must call RunAsync somewhere, and subsequently either await the task directly or store it for later use. This task represents the entire lifetime of the gateway client, and will run until you explicitly request its termination via the cancellation token passed to this method.

If you wish to explicitly send a gateway command (for example, to update presence information), you may do so via the SubmitCommand method on the client. Note that no validations are performed on this command, so you can cause unexpected termination of your session if the data is malformed or inappropriate for the current state of the client.

Responders - the types which react to and handle incoming events - are created by declaring a class that implements one or more instances of the IResponder<T> interface, and then registering these types with the service container.

public class MyResponder : IResponder<IMessageCreate>
{
    public async Task<Result> RespondAsync
    (
        IMessageCreate gatewayEvent,
        CancellationToken ct = default
    )
    {
        // ...
    }
}

...

services.AddResponder<MyResponder>();

There are no restrictions placed on how long an individual responder may run, but you should strive to keep it short in order to avoid thread pool exhaustion.

Responders have no guarantees related to sequential execution, but you are able to sort them into one of three "groups", which do run sequentially to one another.

services.AddResponder<MyResponder>(ResponderGroup.Early); // executes before...
services.AddResponder<MyResponder>(ResponderGroup.Normal); // executes before...
services.AddResponder<MyResponder>(ResponderGroup.Late);

This is useful in cases where two responders to the same event depend on each other in some way.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on Remora.Discord.Gateway:

Package Downloads
Remora.Discord.Commands

Glue code for using Remora.Commands with Remora.Discord

Remora.Discord.Hosting

Implementation of a hosted Discord gateway service for the .NET Generic Host

Remora.Discord.Interactivity

Framework for using Discord's interaction-driven message components

Remora.Discord.Extensions

Utilities and components which extend upon Remora.Discord's base resources

Remora.Discord.Caching

Caching implementations of Remora.Discord's services

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
13.0.0 6,500 2/13/2025
12.0.2 46,585 5/28/2024
12.0.1 26,304 2/5/2024
12.0.0 47,758 11/14/2023
11.1.0 29,906 7/24/2023
11.0.7 19,288 5/11/2023
11.0.6 2,863 3/20/2023
11.0.5 3,494 1/19/2023
11.0.4 2,857 1/10/2023
11.0.3 3,217 12/28/2022
11.0.2 5,833 12/10/2022
11.0.1 3,560 10/30/2022
11.0.0 20,015 9/2/2022
10.1.7 3,583 8/19/2022
10.1.6 3,441 7/28/2022
10.1.5 3,346 7/26/2022
10.1.4 3,172 7/26/2022
10.1.3 7,138 6/29/2022
10.1.2 3,217 6/27/2022
10.1.1 3,516 6/23/2022
10.1.0 4,164 6/20/2022
10.0.0 3,229 6/19/2022
9.0.0 3,263 6/18/2022
8.1.5 3,284 6/14/2022
8.1.4 3,266 6/8/2022
8.1.3 3,261 6/3/2022
8.1.2 3,254 5/25/2022
8.1.1 3,244 5/23/2022
8.1.0 3,461 5/15/2022
8.0.6 3,350 5/10/2022
8.0.5 5,581 5/3/2022
8.0.4 6,624 4/25/2022
8.0.3 4,023 4/18/2022
8.0.2 2,893 4/2/2022
8.0.1 5,074 4/2/2022
8.0.0 3,493 3/21/2022
7.2.0 3,320 3/17/2022
7.1.0 2,977 3/15/2022
7.0.1 4,439 2/20/2022
7.0.0 3,049 2/19/2022
7.0.0-rc1 1,193 2/14/2022
6.2.10 3,095 2/14/2022
6.2.9 3,297 1/27/2022
6.2.7 5,183 1/11/2022
6.2.6 35,539 1/2/2022
6.2.5 3,188 12/23/2021
6.2.4 1,417 12/21/2021
6.2.3 1,641 12/16/2021
6.2.2 1,511 12/11/2021
6.2.1 1,675 12/5/2021
6.2.0 3,301 11/26/2021
6.1.0 7,213 11/24/2021
6.0.0 2,540 11/20/2021
5.0.4 2,212 11/9/2021
5.0.3 2,016 11/6/2021
5.0.2 2,324 10/30/2021
5.0.1 1,681 10/28/2021
5.0.0 3,917 10/15/2021
4.0.15 2,295 10/7/2021
4.0.13 1,837 10/3/2021
4.0.12 1,647 10/2/2021
4.0.11 1,584 9/30/2021
4.0.10 2,219 9/26/2021
4.0.9 1,662 9/24/2021
4.0.8 1,677 9/23/2021
4.0.7 1,663 9/16/2021
4.0.6 1,743 9/15/2021
4.0.5 1,815 9/8/2021
4.0.4 3,002 9/4/2021
4.0.3 3,356 8/21/2021
4.0.2 1,846 8/18/2021
4.0.1 2,774 8/12/2021
4.0.0 1,483 8/11/2021
3.5.8 2,026 8/11/2021
3.5.7 1,895 8/2/2021
3.5.6 2,132 8/2/2021
3.5.5 2,192 7/31/2021
3.5.4 1,726 7/29/2021
3.5.3 1,657 7/28/2021
3.5.2 1,578 7/28/2021
3.5.1 2,094 7/22/2021
3.5.0 1,727 7/17/2021
3.4.6 1,660 7/14/2021
3.4.5 1,796 7/12/2021
3.4.4 1,697 7/11/2021
3.4.3 1,701 7/5/2021
3.4.2 1,556 7/3/2021
3.4.1 1,567 7/1/2021
3.4.0 1,885 6/14/2021
3.3.1 861 6/10/2021
3.3.1-beta2 1,075 5/30/2021
3.3.1-beta1 1,483 5/28/2021
3.3.0 1,558 5/23/2021
3.2.1 1,733 5/20/2021
3.2.0 2,065 5/4/2021
3.1.14 1,714 4/22/2021
3.1.13 1,689 4/15/2021
3.1.12 1,704 4/10/2021
3.1.11 1,862 4/5/2021
3.1.10 1,762 4/4/2021
3.1.9 2,367 3/28/2021
3.1.8 2,617 3/25/2021
3.1.7 1,476 3/25/2021
3.1.6 2,217 3/16/2021
3.1.5 1,676 3/14/2021
3.1.4 1,643 3/13/2021
3.1.3 1,661 3/11/2021
3.1.2 1,969 3/6/2021
3.1.1 1,754 3/1/2021
3.1.0 1,744 3/1/2021 3.1.0 is deprecated because it has critical bugs.
3.0.7 1,820 2/28/2021
3.0.6 1,533 2/23/2021
3.0.5 2,121 2/22/2021
3.0.4 1,670 2/21/2021
3.0.3 1,369 2/16/2021
3.0.2 1,782 2/13/2021
3.0.1 1,988 2/11/2021
3.0.0 1,689 2/10/2021
2.2.3 1,524 2/6/2021
2.2.2 1,574 2/5/2021
2.2.1 1,506 1/29/2021
2.2.0 1,482 1/27/2021
2.1.1 1,832 1/21/2021
2.1.0 1,697 1/17/2021
2.0.1 1,598 1/10/2021
2.0.0 1,710 1/10/2021
1.1.2 1,651 1/9/2021
1.1.1 1,797 12/31/2020
1.1.0 1,665 12/27/2020
1.0.1 2,218 12/25/2020
1.0.0 1,485 12/25/2020
1.0.0-beta9 1,042 12/10/2020
1.0.0-beta8 1,029 11/26/2020
1.0.0-beta7 988 11/15/2020
1.0.0-beta6 983 11/14/2020
1.0.0-beta5 1,059 11/8/2020
1.0.0-beta4 476 11/8/2020
1.0.0-beta3 420 10/17/2020
1.0.0-beta2 418 10/6/2020
1.0.0-beta11 960 12/23/2020
1.0.0-beta10 1,017 12/18/2020
1.0.0-beta1 425 10/6/2020
1.0.0-alpha1 418 9/27/2020

BREAKING: Update target frameworks.
           BREAKING: Update dependencies.
           BREAKING: Catch-up on all discord features...