An in development Discord API library written in C#.
Join the official Discord server for discord.cs! Get support, updates/announcements, and contribute to development.
Discord.cs is on NuGet. In the early stages of development, any help testing the library is appreciated!
// The following simply brings your bot online and responds to a message.
using Discord;
using Discord.Models;
// Set your bot token.
Environment.SetEnvironmentVariable("DISCORD_BOT_TOKEN", "<token>");
var bot = new Bot(Intents.Default);
// Listen for messages.
bot.Events.OnMessageCreate += async (_, message) =>
{
// Don't respond to bot messages (ourselves) to avoid a loop.
if (message.Author.IsBot)
return;
if (message.Content == "hi")
await message.Channel.SendAsync("Hello! 👋")
};
await bot.ConnectAsync();
await Task.Delay(-1);