Fluxify.AspNetCore.Authentication
0.1.4-preview
dotnet add package Fluxify.AspNetCore.Authentication --version 0.1.4-preview
NuGet\Install-Package Fluxify.AspNetCore.Authentication -Version 0.1.4-preview
<PackageReference Include="Fluxify.AspNetCore.Authentication" Version="0.1.4-preview" />
<PackageVersion Include="Fluxify.AspNetCore.Authentication" Version="0.1.4-preview" />
<PackageReference Include="Fluxify.AspNetCore.Authentication" />
paket add Fluxify.AspNetCore.Authentication --version 0.1.4-preview
#r "nuget: Fluxify.AspNetCore.Authentication, 0.1.4-preview"
#:package Fluxify.AspNetCore.Authentication@0.1.4-preview
#addin nuget:?package=Fluxify.AspNetCore.Authentication&version=0.1.4-preview&prerelease
#tool nuget:?package=Fluxify.AspNetCore.Authentication&version=0.1.4-preview&prerelease
Fluxify
.NET library for building applications that interact with fluxer
Getting Started
See Example.cs for a simple starting point
Building a Bot
Start with the Fluxify.Bot package.
var cfg = new FluxerConfig
{
// for configuring the fluxer instance you can provide the instance option
// InstanceUri = new Uri("https://api.<your-instance>/"),
Credentials = new BotTokenCredentials("...")
};
var bot = new Bot("!", cfg)
// the parameters to the command will be resolved from the configured service provider
// or (still in progress as of 0.1.0-preview) from the command reader
bot.Commands.Command("ping", (CommandContext ctx) => ctx.ReplyAsync("Pong!"));
bot.Commands.Command("hug", async (CommandContext ctx) =>
{
var userMention = ctx.Reader.GetNext<Mentionable.Member>();
var message = new MessageBuilder($"<@{userMention.Id}> you have been hugged!")
.WithEmbed(e => e
.WithImage("https://gifprovider/image.gif")
.Build());
await ctx.Message.Channel.SendMessageAsync(message);
});
// Subscribe to an event.
bot.MessageUpdated += async message =>
{
Console.WriteLine(message.Content);
};
// Some events are not exposed on the Bot class yet. For those you have to check in bot.Gateway.
bot.Gateway.MessageReactionAdd += async (reaction) =>
{
...
};
await bot.RunAsync();
Voice
To connect to a voice channel you need the Fluxify.Voice package.
Here is an example of how to play a file using ffmpeg.
// voice session is per voice channel connection
// -> you'll have to create them per channel - but you can also have multiple sessions per channel
// probably what you want is some form of ConcurrentDictionary<Snowflake, VoiceSession> :)
var voiceSession = new VoiceSession(bot.Gateway);
// <prefix>playFile #Voice
bot.Commands.Command("playFile", async (CommandContext ctx) =>
{
var channel = ctx.Reader.GetNext<Mentionable.Channel>();
if (!ctx.Guild!.Channels.TryGetValue(channel.Id, out var channelValue)
|| channelValue is not GuildVoiceChannel voiceChannel)
{
throw new CommandException("Channel is not a voice channel!");
}
await voiceSession.ConnectAsync(voiceChannel);
// here you can pretty much use everything ffmpeg has to offer
// you could chain the stdout of yt-dlp into ffmpeg using .FromPipeInput(new StreamPipeSource()) :)
// I would recommend retaining the info about what is playing and the task that plays it in some AudioPlayer class
await FFMpegArguments
.FromFileInput("/Users/core/FLOW.mp3")
.OutputToPipe(voiceSession.AudioSourceSink, args => args
.WithAudioSamplingRate()
.ForceFormat(voiceSession.AudioSourceSink.GetFormat())
)
.ProcessAsynchronously();
await voiceSession.DisconnectAsync();
}, Preconditions.RequireGuildContext());
Alternatively you could also get the voice channel from the author if they are in a voice channel.
var voiceChannel = context switch
{
// get voice channel from author
{ Author: GuildUser { VoiceState.VoiceChannel: { } authorChannel } } => authorChannel,
// alternative try getting from parameter
{ Reader: { } reader, Guild.Channels: { } guildChannels }
when guildChannels.TryGetValue(reader.GetNext<Mentionable.Channel>().Id, out var channel)
&& channel is GuildVoiceChannel guildVoiceChannel => guildVoiceChannel,
// we got a parameter but its not a guild voice channel or we couldn't resolve it
_ => throw new CommandException("The mentioned channel is not a voice channel.")
};
Preconditions
var botOwnerPrecondition = new Precondition(
"bot-owner",
"User needs to be the bot owner"
static ctx => ctx.Message.Author.Id == 27842764872883298
? PreconditionResult.Success
: PreconditionResult.Fail("Youre not the bot owner!"));
bot.Module("secret", m =>
{
m.Command("isCool", (CommandContext ctx) => ctx.ReplyAsync("Yes you are cool!"))
}, botOwnerPrecondition)
.Command(
"open-pod-bay-doors",
(CommandContext ctx) => ctx.ReplyAsync("I'm sorry dave I'm afraid I can't do that"),
Preconditions.RequireAuthorPermissions(Permissions.Administrator)
);
Logging (Simple)
Fluxify does not provide any logging by itself. To use logging use any logging package that supports the ILoggerFactory interface.
Example with Microsoft.Extensions.Logging.Console:
var cfg = new FluxerConfig
{
...
LoggerFactory = LoggerFactory.Create(builder => builder.AddConsole())
};
...
Dependency Injection
Configure your IServiceProvider using the Services option. A new service scope will be created per Command execution.
var cfg = new FluxerConfig
{
...
Services = ...
};
Bot Presence
This is configured using the gateway configuration so you will have to pass another configuration to the bot class.
var gatewayConfig = new GatewayConfig
{
// IgnoredGatewayEvents = ...,
DefaultPresence = new PresenceUpdate(
Status: UserStatus.Online,
CustomStatus: new CustomStatus(
Text: "hello world!"))
};
var bot = new Bot(..., gatewayConfig);
// update presence
await bot.Gateway.UpdatePresenceAsync(
status: UserStatus.Online,
customStatus: new CustomStatus(Text: "Hello World Again!"));
...
ASP.NET Core
To use Fluxify with ASP.NET Core register the core providers and RestClient in the dependency injection container.
Additionally you need the Fluxify.AspNetCore.Authentication for the AddFluxer authentication option.
Example setup for a webapp:
builder.Services.AddFluxifyCore(sp => new FluxerConfig
{
CredentialProvider = sp.GetRequiredService<IAccessTokenProvider>().GetAuthenticationTokenAsync
})
builder.Services.AddScoped<RestClient>();
builder.Services
.AddAuthentication(o =>
{
o.DefaultScheme = FluxerAuthenticationDefaults.AuthenticationScheme;
o.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddFluxer(o =>
{
o.ClientId = builder.Configuration["Fluxer:ClientId"]!;
o.ClientSecret = builder.Configuration["Fluxer:ClientSecret"]!;
// o.Scope.Add("guilds") etc..
o.SaveTokens = true;
})
.AddCookie();
Then configure your secret and client id using the user secrets CLI or Visual Studio / Rider.
$ dotnet user-secrets init
$ dotnet user-secrets set "Fluxer:ClientId" "<Client ID here>"
$ dotnet user-secrets set "Fluxer:ClientSecret" "<Client ID here>"
Clear the entries from the history file. You could then just use the RestClient as service using dependency injection.
@page "/"
@using Fluxify.Dto.OAuth2
@using Fluxify.Rest
@using Microsoft.AspNetCore.Authorization
@inject RestClient FluxerClient
@attribute [Authorize]
Welcome @(Me?.User.Username)
@code {
[PersistentState]
public OAuth2MeResponse? Me { get; set; }
protected override async Task OnInitializedAsync()
=> Me = await FluxerClient.OAuth2.MeAsync();
}
Help I cannot find request X
Currently not all REST functionality is exposed via the Entities. This means in cases you need functions not exposed in the higher level entities you should look into Bot.Rest. It currently implements all Guild and User endpoints and almost all Channel endpoints. If something is missing, feel free to create an issue or contribute.
| 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 is compatible. 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. |
-
net10.0
- Fluxify.Core (>= 0.1.4-preview)
-
net8.0
- Fluxify.Core (>= 0.1.4-preview)
-
net9.0
- Fluxify.Core (>= 0.1.4-preview)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.4-preview | 0 | 3/26/2026 |
| 0.1.3-preview | 39 | 3/22/2026 |
| 0.1.2-preview | 33 | 3/21/2026 |
| 0.1.1-preview | 34 | 3/18/2026 |