A Discord library made in .NET for interactions using webhooks.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Color-Chan.Discord is a powerful Discord library made to communicate with the Discord API.
To get a local copy up and running follow these simple steps.
Color-Chan.Discord is available on NuGet.
Install-Package Color-Chan.Discord
OR
dotnet add package Color-Chan.Discord
The induvidial components are also available on NuGet:
git clone https://github.com/Color-Chan/Color-Chan.Discord.git
cd Color-Chan.Discord
dotnet build
Create a new ASP.NET project and add the following to Program.cs and Startup.cs.
You will have to replace Assembly.GetExecutingAssembly()
with the assembly where your commands will be located.
public static async Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
// Register all the commands in an Assembly.
await host.RegisterSlashCommandsAsync(Assembly.GetExecutingAssembly(), config).ConfigureAwait(false); // <-----
// Run the WebHost, and start accepting requests.
await host.RunAsync().ConfigureAwait(false);
}
You will need to add your bot token, public key and application id, these can be found at discordapp.com.
public void ConfigureServices(IServiceCollection services)
{
// Configure Color-Chan.Discord
var config = new ColorChanConfigurations
{
SlashCommandConfigs = slashOptions =>
{
slashOptions.EnableAutoSync = true; // <---
}
};
// Replace the arguments with the data of your bot.
// Note: It is not recommended to hardcode them in, loading them from an environment variable or from a json file is better.
services.AddColorChanDiscord("TOKEN", "PUBLIC_KEY", 999999999999999, config); // <---
services.AddControllers();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
// This is needed to validate incoming interaction requests.
app.UseColorChanDiscord(); // <---
app.UseRouting();
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
}
After this you can start to create your own commands! Here is a simple example on how you can do that.
public class PongCommands : SlashCommandModule
{
/// <summary>
/// A simple Ping Pong command.
/// </summary>
[SlashCommand("ping", "Ping Pong!")]
public Task<Result<IDiscordInteractionResponse>> PongAsync()
{
// Return the response to Discord.
return FromSuccess("Pong!");
}
}
For more examples, please refer to the Samples folder
The interaction end point is located at https://YOUR_DOMAIN.COM/api/v1/discord/interaction
.
You will need to add this URL to you application.
See the milestones for a list of proposed features.
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the MIT License. See LICENSE
for more information.
Color-Chan.Discord uses Semantic Versioning 2.0.0 for its versioning.
The versioning will be using the following format: MAJOR.MINOR.PATCH.