Rabergsel.DSharpPlus.SettingsManager 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Rabergsel.DSharpPlus.SettingsManager --version 1.0.0                
NuGet\Install-Package Rabergsel.DSharpPlus.SettingsManager -Version 1.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="Rabergsel.DSharpPlus.SettingsManager" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Rabergsel.DSharpPlus.SettingsManager --version 1.0.0                
#r "nuget: Rabergsel.DSharpPlus.SettingsManager, 1.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.
// Install Rabergsel.DSharpPlus.SettingsManager as a Cake Addin
#addin nuget:?package=Rabergsel.DSharpPlus.SettingsManager&version=1.0.0

// Install Rabergsel.DSharpPlus.SettingsManager as a Cake Tool
#tool nuget:?package=Rabergsel.DSharpPlus.SettingsManager&version=1.0.0                

Rabergsel.DSharpPlus.SettingsManager

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;
using DSharpPlus.SettingsManager;

namespace MyFirstBot
{
    class Program
    {
        static async Task Main(string[] args)
        {
            // Initialize Discord client
            DiscordClient? discord = new DiscordClient(new DiscordConfiguration()
            {
                Token = File.ReadAllText("token.txt"),
                TokenType = TokenType.Bot,
                Intents = DiscordIntents.All
            });

            // Initialize SettingsManager
            SettingsManager? settings = new SettingsManager
            {
                DebugLevel = 3
            };
            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) =>
            {
                if (settings.GetSettingValueAsBoolean(e.Guild.Id, "ReactToPing", false))
                {
                    return;
                }

                if (e.Message.Content.ToLower().StartsWith("ping"))
                {
                    await e.Message.RespondAsync("pong!");
                }
            };

            // Connect to Discord
            await discord.ConnectAsync();
            await Task.Delay(-1);
        }
    }
}

How it Works

  1. Initialize a Discord client with your bot token and configuration.
  2. Initialize a SettingsManager instance and configure default settings.
  3. Add the SettingsManager extension to your Discord client.
  4. Handle the MessageCreated event to customize bot behavior based on settings.
  5. Connect your bot to Discord and start processing messages.

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 Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.2.0 71 7/16/2024
1.1.0 150 4/12/2024
1.0.2 123 3/31/2024
1.0.1 127 3/30/2024
1.0.0 129 3/30/2024