HelperLib 1.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package HelperLib --version 1.2.0
                    
NuGet\Install-Package HelperLib -Version 1.2.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="HelperLib" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HelperLib" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="HelperLib" />
                    
Project file
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 HelperLib --version 1.2.0
                    
#r "nuget: HelperLib, 1.2.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.
#:package HelperLib@1.2.0
                    
#: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=HelperLib&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=HelperLib&version=1.2.0
                    
Install as a Cake Tool

HelperLib

HelperLib is a small utility library with helpers commonly used when building Discord bots with Discord.NET (targeting .NET 9). It provides convenience wrappers and utilities to simplify common tasks, such as parsing mentions, sending embeds/images, interacting with guild entities, and handling basic reliability for the Discord client.

Features

  • IonicHelper — Common static helpers for working with a running DiscordSocketClient (guild/channel/role lookups, guild user enumeration, role checks, cancellation token management, and simple reconnect handling).
  • Services.ReliabilityService — Encapsulates a reconnect/reset strategy for DiscordSocketClient with configurable timeout behavior.
  • Util.MentionUtils — Create and parse Discord mentions for users, channels, and roles.
  • Util.Extensions — Extension helpers for sending Embed/EmbedBuilder and sending images from URLs.
  • Preconditions.RequireRoleAttribute — Command precondition attribute for Discord.Commands that restrict usage to a given role ID.
  • Models.GuildUsersResult — Lightweight result type for guild user enumeration.

Quick start

  1. Add the project or compiled DLL to your bot solution (project reference or NuGet if you publish it).
  2. Create and start a DiscordSocketClient using IonicHelper or use ReliabilityService to attach reconnect behavior.

Example (simple start using IonicHelper):

var token = "YOUR_BOT_TOKEN";
var helper = new IonicHelper(token, defaultGuildId: 123456789012345678);
await helper.RunAsync(new DiscordSocketConfig(), message => { Console.WriteLine(message); return Task.CompletedTask; });

Example usages:

  • Parse a user mention:
if (MentionUtils.TryParseUser("<@!123456>", out var userId)) { /* use userId */ }
  • Send an embed using extension methods:
await textChannel.SendEmbedAsync(new EmbedBuilder().WithTitle("Hello").Build());
  • Require a role on a command:
[RequireRole(123456789012345678)]
public async Task MyCommand() { ... }

Notes

  • This library is intended as a convenience layer over Discord.NET and expects a DiscordSocketClient to be available at runtime when using IonicHelper static helpers.
  • The reconnect logic is intentionally simple: on repeated failures, the process will exit (FailFast/Environment.Exit) so that orchestration systems can restart the bot.

Contributing

PRs and bug reports are welcome. Keep changes focused and add tests or usage examples when possible.

License

MIT

Product Compatible and additional computed target framework versions.
.NET 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.

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.3.0 492 4/12/2026
1.2.0 351 3/28/2026
1.1.3 173 3/28/2026
1.1.2 363 7/7/2024
1.1.1 229 5/2/2024
1.1.0 208 5/2/2024
1.0.11 276 4/15/2024
1.0.10 265 4/11/2024
1.0.9 387 7/22/2023
1.0.8 249 7/22/2023
1.0.7 264 7/20/2023
1.0.6 263 7/16/2023
1.0.5 555 7/29/2022
1.0.4 538 7/29/2022
1.0.3 627 1/17/2022
1.0.2 564 1/17/2022
1.0.1 479 12/26/2021
1.0.0 473 12/25/2021