Rabergsel.DSharpPlus.SettingsManager
1.1.0
See the version list below for details.
dotnet add package Rabergsel.DSharpPlus.SettingsManager --version 1.1.0
NuGet\Install-Package Rabergsel.DSharpPlus.SettingsManager -Version 1.1.0
<PackageReference Include="Rabergsel.DSharpPlus.SettingsManager" Version="1.1.0" />
paket add Rabergsel.DSharpPlus.SettingsManager --version 1.1.0
#r "nuget: Rabergsel.DSharpPlus.SettingsManager, 1.1.0"
// Install Rabergsel.DSharpPlus.SettingsManager as a Cake Addin #addin nuget:?package=Rabergsel.DSharpPlus.SettingsManager&version=1.1.0 // Install Rabergsel.DSharpPlus.SettingsManager as a Cake Tool #tool nuget:?package=Rabergsel.DSharpPlus.SettingsManager&version=1.1.0
Rabergsel.DSharpPlus.SettingsManager
Changes from 1.0.2 to 1.1.0
Ported the package to .NET 8 so it is supported by D#+ 5.0 (nightly)
Rabergsel.DSharpPlus.SettingsManager is an extension for DSharpPlus that provides an easy infrastructure for managing settings for Discord Servers and Channels.
Installation
This package is under heavy development and not yet available on NuGet. However, you can clone the repository and build the project locally.
Usage
using DSharpPlus; // Import DSharpPlus library for Discord API
using DSharpPlus.SettingsManager; // Import DSharpPlus.SettingsManager library for managing settings
using System.IO; // Import System.IO for file reading
namespace MyFirstBot
{
class Program
{
static async Task Main(string[] args)
{
// Initialize Discord client
DiscordClient? discord = new DiscordClient(new DiscordConfiguration()
{
// Read bot token from token.txt file
Token = File.ReadAllText("token.txt"),
TokenType = TokenType.Bot, // Set token type as Bot
Intents = DiscordIntents.All // Enable all intents for the bot
});
// Initialize SettingsManager with debug level 3
SettingsManager? settings = new SettingsManager
{
//Level 0 = no logging
//Level 1 = Releveant actions like index finished, errors or crashed
//Level 2 = Actions, like fetching settings
//Level 3 = Tracing
DebugLevel = 1
};
// Add default guild setting for reacting to "ping" message
settings.AddDefaultGuildSetting(new SettingEntity("ReactToPing", false.ToString(), "If set to yes, the bot will react to a \"ping\" message", false));
// Add SettingsManager extension to Discord client
discord.AddExtension(settings);
// Handle message creation event
discord.MessageCreated += async (s, e) =>
{
// Check if guild setting allows reacting to "ping" message
if (!settings.GetSettingValueAsBoolean(e.Guild.Id, "ReactToPing", false))
{
return; // Skip if not allowed
}
// Check if message content starts with "ping"
if (e.Message.Content.ToLower().StartsWith("ping"))
{
// Respond with "pong!"
await e.Message.RespondAsync("pong!");
}
};
// Connect to Discord
await discord.ConnectAsync();
// Keep the application running indefinitely
await Task.Delay(-1);
}
}
}
Note
This package is under heavy development and may undergo frequent changes. It's recommended to keep an eye on updates and consult the documentation for any breaking changes.
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 was computed. 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. |
-
net8.0
- DSharpPlus (>= 4.4.6)
- Microsoft.Extensions.Logging (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.