yawaflua.Discord.Net
1.0.6
dotnet add package yawaflua.Discord.Net --version 1.0.6
NuGet\Install-Package yawaflua.Discord.Net -Version 1.0.6
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="yawaflua.Discord.Net" Version="1.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="yawaflua.Discord.Net" Version="1.0.6" />
<PackageReference Include="yawaflua.Discord.Net" />
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 yawaflua.Discord.Net --version 1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: yawaflua.Discord.Net, 1.0.6"
#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.
#:package yawaflua.Discord.Net@1.0.6
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=yawaflua.Discord.Net&version=1.0.6
#tool nuget:?package=yawaflua.Discord.Net&version=1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
yawaflua.Discord.Net
yawaflua.Discord.Net is a library for integrating Discord OAuth2 into your .NET applications. It provides a simple and easy-to-use interface for authenticating users with Discord, retrieving user information, and managing sessions.
Features
- OAuth2 Authentication: Easily authenticate users with Discord using OAuth2.
- User Information: Retrieve user information such as username, avatar, and guilds.
- Session Management: Create and manage sessions for authenticated users.
- Dependency Injection: Seamlessly integrate with your .NET application's dependency injection system.
Usage
// Configure configuration to DI
builder.Services.AddSingleton<DiscordConfig>(
new DiscordConfig
{
ClientId = "your-client-id",
ClientSecret = "shhhhh!",
RedirectUri = "https://example.com/Login",
Scopes = new ScopesBuilder(OAuthScope.Identify, OAuthScope.Guilds),
Token = "MyVeryCool.BotToken.For.Discord" // Optional, for bot interactions
});
builder.Services.AddSingleton<IDiscord, DiscordOAuth>();
// And use it in you very cool controller or smth
public class MyController (IDiscord discord) : ControllerBase
{
public async Task<IActionResult> Login()
{
var url = discord.GetAuthorizationUrl("state");
return Redirect(url);
}
public async Task<IActionResult> Callback()
{
if (discord.TryGetCode(HttpContext, out var code))
{
var token = await discord.GetTokenAsync(code);
var user = await discord.GetUserAsync(token);
var session = discord.CreateSession();
var guilds = await session.GetGuildsAsync();
// Do something with the user and guilds, like storing them in a database or session
// ...
return Ok();
}
return BadRequest("Invalid code");
}
}
Feedback
yawaflua.Discord.Net
is a library still in development, and your feedback or support is very welcome. If you have any issues, suggestions, or questions, please open an issue on the GitHub repository
This library is released under the Apache 2.0.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
-
net9.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.