Simple Discord .NET

Discord bots in plain C#

Write a method, add an attribute, and your bot has a new command. No dependencies, no reflection, and easy enough for your first bot.

dotnet add package SimpleDiscordDotNet
v1.11.0 .NET 10+ Native AOT Apache 2.0
Program.cs
using SimpleDiscordNet;
using SimpleDiscordNet.Commands;

var bot = DiscordBot.NewBuilder()
    .WithToken(File.ReadAllText("token.txt").Trim())
    .WithIntents(DiscordIntents.Guilds)
    .Build();

await bot.StartAsync();
await Task.Delay(Timeout.Infinite);

public sealed class MyCommands
{
    [SlashCommand("hello", "Say hello")]
    public string Hello(string name) => $"Hello, {name}!";
}

Less code for everyday things

The things every bot needs are one attribute or one line.

Limit who can use a command

[Cooldown(30)]
[RequireRole("Moderator")]
[RequireBotPermissions(PermissionFlags.BanMembers)]
[SlashCommand("ban", "Ban a member")]
public async Task<string> BanAsync(DiscordMember member)
{
    await member.BanAsync();
    return $"Banned {member.User.Username}.";
}

Make a pop-up form from a class

[Modal("Send feedback")]
public sealed class FeedbackForm
{
    [ModalText("Your feedback", Paragraph = true)]
    public string Text { get; set; } = "";
}

[ModalHandler]
public string OnFeedback(FeedbackForm form)
    => $"Thanks! You said: {form.Text}";

Ask a question, right in your command

[SlashCommand("reset", "Reset your score")]
public async Task<string> ResetAsync(InteractionContext ctx)
{
    bool sure = await ctx.ConfirmAsync("Are you sure?");
    return sure ? "Score reset." : "Nothing changed.";
}

React to what happens on Discord

[OnMemberJoined]
public async Task WelcomeAsync(MemberEvent e)
{
    await e.User.SendDMAsync($"Welcome to {e.Guild.Name}!");
}

See examples of every feature

What's included

Everything runs on the .NET base libraries alone.

Commands

Slash commands, context menus, autocomplete, and enums as choice lists.

Buttons and forms

Buttons, select menus, pop-up forms, confirmations and pagination.

Rich messages

Embeds, polls, threads, forum posts, file uploads and layout messages.

Moderation

Bans, kicks, timeouts, bulk bans, audit logs and permission checks.

Native AOT

Source generators find your handlers, so nothing relies on reflection.

Fits your app

Constructor injection, live collections for UI binding, and rate limit monitoring.

New in 1.11.0

The biggest release yet, with more attributes and a long list of reliability fixes.

  • Checks and cooldowns as attributes
  • Enum options, and replying by returning a value
  • Forms defined as classes
  • Polls, threads, forum posts and layout messages
  • Confirmations and pagination built in
  • Event attributes such as [OnMemberJoined]
  • Services in handlers, and a generated help command
  • Stronger reconnects, rate limits and sharding

Read the release notes and upgrade steps

Documentation

New to Discord bots? Start with the Beginner's Guide.