Skip to content

Defxult/discord.cs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

discord.cs

An in development Discord API library written in C#.

Discord

Join the official Discord server for discord.cs! Get support, updates/announcements, and contribute to development.

NuGet

Discord.cs is on NuGet. In the early stages of development, any help testing the library is appreciated!

Basic Usage

// 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);