Class DiscordSocketClientExtensions
- Namespace
- Nyra.DiscordNet
- Assembly
- Nyra.DiscordNet.dll
Entry points for enabling and accessing Nyra on Discord.Net clients.
public static class DiscordSocketClientExtensions
- Inheritance
-
DiscordSocketClientExtensions
- Inherited Members
Methods
GetNyra(DiscordShardedClient)
Gets the Nyra extension of the sharded client, or null when Nyra is not enabled.
public static NyraExtension? GetNyra(this DiscordShardedClient client)
Parameters
clientDiscordShardedClientThe sharded client to read the extension of.
Returns
- NyraExtension
The extension of the sharded client, null when Nyra is not enabled.
GetNyra(DiscordSocketClient)
Gets the Nyra extension of the client, or null when Nyra is not enabled.
public static NyraExtension? GetNyra(this DiscordSocketClient client)
Parameters
clientDiscordSocketClientThe client to read the extension of.
Returns
- NyraExtension
The extension of the client, null when Nyra is not enabled.
UseNyra(DiscordShardedClient, ILogger?)
Enables Nyra on every shard.
public static NyraExtension UseNyra(this DiscordShardedClient client, ILogger? logger = null)
Parameters
clientDiscordShardedClientThe sharded client to enable Nyra on, one extension covering every shard.
loggerILoggerThe logger to write the library's messages through.
Returns
- NyraExtension
The enabled extension, the existing one when Nyra is already on. The logger of the first enabling is the one the extension keeps for its lifetime, the logger of a later call is ignored unless the earlier extension was disposed.
Remarks
Discord.Net offers no native Microsoft.Extensions.Logging, pass a logger to receive the library's log messages through it.
Voice connections need the guilds and guild voice states intents, see the remarks of the single-client UseNyra(DiscordSocketClient, ILogger?) for the failure modes and why Nyra cannot verify them at runtime.
Do not also enable Nyra on an inner shard of the same sharded client. The shard forwards its events to the sharded client, so both bridges receive them and the two extensions race the same joins with no cross-extension guard.
UseNyra(DiscordSocketClient, ILogger?)
Enables Nyra on the client.
public static NyraExtension UseNyra(this DiscordSocketClient client, ILogger? logger = null)
Parameters
clientDiscordSocketClientThe client to enable Nyra on.
loggerILoggerThe logger to write the library's messages through.
Returns
- NyraExtension
The enabled extension, the existing one when Nyra is already on. The logger of the first enabling is the one the extension keeps for its lifetime, the logger of a later call is ignored unless the earlier extension was disposed.
Remarks
Discord.Net offers no native Microsoft.Extensions.Logging, pass a logger to receive the library's log messages through it. Without one the bridge stays mute by design.
Voice connections need the guilds and guild voice states intents. Without guilds the join fails fast on a channel it cannot resolve (guilds arrive as unavailable shells) and a kick leaves a zombie no guild delete reports. Without voice states Discord.Net itself rejects the join with a missing-intent error the moment the connect is attempted.
Discord.Net exposes no way to read the configured intents at runtime, so Nyra cannot warn about a missing one the way the DSharpPlus adapter does, verify them in the DiscordSocketConfig.
A client re-logged-in as another account needs the extension disposed and enabled again, the bridge keeps the first account's id and only reports the switch through a logger.