Skip to content

DenVot/MeDsCore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MeDsCore. Discord Bot Client

MeDsCore is an async Discord Bot API library. me.ds module uses this library to interact with Discord

Quick start

  1. Create a Service Worker project template
  2. Add in your appsettings.json the following JSON property
"DsToken": "<YOUR_BEAUTIFUL_TOKEN>"
  1. Replace code in the Program.cs by this
using MeDsCore;
using MeDsCore.WebSocket.Gateway;

IHost host = Host.CreateDefaultBuilder(args)
    .ConfigureLogging(x =>
    {
        x.ClearProviders();
        x.AddMeDsBotLogger();
        x.SetMinimumLevel(LogLevel.Trace);
    })
    .ConfigureServices((context, services) =>
    {
        services.AddHostedService<BotWorker>()            
            .AddSingleton<DiscordClient>()
            .AddSingleton(new DiscordClientConfiguration(context.Configuration["DsToken"])
            {
                Intents = GatewayIntents.GuildsIntent |
                    GatewayIntents.GuildPresencesIntent |
                    GatewayIntents.GuildMessagesIntent
            });
    })
    .Build();

await host.RunAsync();
  1. Create a class named BotWorker
using System.Reflection;
using MeDsCore;

namespace MeDsBot.Workers;

public class BotWorker : BackgroundService
{
    private readonly DiscordClient _discordClient;

    public BotWorker(DiscordClient discordClient)
    {
        _discordClient = discordClient;       
    }

    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {   
        await _discordClient.StartAsync();
        await Task.Delay(-1, stoppingToken);
    }
}

Result:

image

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages