Coder Social home page Coder Social logo

hrkings / discordnetbottemplate Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 0.0 26 KB

A fully dockerized and ready to run Discord bot template written in C# using .NET 6 and Discord.NET

C# 96.87% Dockerfile 3.13%
discord discord-bot discord-bot-template discord-bot-boilerplate bot dotnet dotnet-core dotnet-5 csharp boilerplate

discordnetbottemplate's Introduction

๐Ÿ‘‹ Hey there! I'm HRKings, Welcome to my GitHub ๐Ÿง‘โ€๐Ÿ’ป


๐Ÿ–ฅ๏ธ I am working as a Solutions Architect

๐ŸŒฑ Iโ€™m currently learning a bit of everything, knowledge is key

๐Ÿ”ญ Iโ€™m currently working on templates and guides for a better Developer Experience

๐Ÿค” Interested in everything technology related, games and Pokemon

๐Ÿ’ฌ Let's chat! I'm active on many communities

โค๏ธ Open Source


Trophies


๐ŸŒŽ Where you can find me ๐Ÿ“ฌ

Reddit Twitter Dev.to StackOverflow ORCID


๐Ÿš€ Languages, technologies, services and tools that I use ๐Ÿ’ป

๐Ÿง‘โ€๐Ÿ’ป Languages

TypeScript C# Java Shell Go Lua Rust C++ Python

๐Ÿ“š Databases

Supabase Redis MariaDB PostgreSQL Oracle MongoDB MicrosoftSQLServer

๐Ÿ› ๏ธ Tools

VSCode SASS NGinx Kubernetes Node.JS Docker DataGrip Jenkins Insomnia Rider

๐Ÿงฐ Frameworks

Flutter .NET Vue.JS Express.JS

โ˜๏ธ Cloud

Heroku AWS Vercel

๐Ÿงญ Misc

Latex Markdown Mocha ESLint Swagger Jira Electron Storybook

๐Ÿ–ฅ๏ธ OS

Arch Linux|EndeavourOS KDE

discordnetbottemplate's People

Contributors

hrkings avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

discordnetbottemplate's Issues

entity framework

i would like to add the database with entity framework but i never worked that way in dotnet6. Would you help me?

I tried:

Startup.cs

using System;
using System.Threading;
using System.Threading.Tasks;
using ArmarioBot.Services;
using ContaCentral.Infrastructure.Data.Context;
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using Microsoft.Extensions.DependencyInjection;

namespace ArmarioBot;

public class Startup
{
    private DiscordSocketClient _client;

    public static void ConfigureServices(IServiceCollection services)
        => services.AddDbContext<MySQLContext>();

    public async Task Initialize()
    {
        await using var services = ConfigureServices();
        _client = services.GetRequiredService<DiscordSocketClient>();

        
            
        _client.Ready += OnReady;
        _client.Log += LogAsync;
        services.GetRequiredService<CommandService>().Log += LogAsync;


        await _client.LoginAsync(TokenType.Bot, "OTQ4MjIzNTg3MjY4MDQ2ODQ5.Yh4sCA.lw-93lz1eglJSARR8Ey-zV1K2kc");
        await _client.StartAsync();

        await services.GetRequiredService<CommandHandlingService>().InitializeAsync();

        await Task.Delay(Timeout.Infinite);
    }

    private Task OnReady()
    {
        Console.WriteLine($"Connected to these servers as '{_client.CurrentUser.Username}': ");
        foreach (var guild in _client.Guilds)
            Console.WriteLine($"- {guild.Name}");

        _client.SetGameAsync("I'm alive!", type: ActivityType.CustomStatus);
        Console.WriteLine($"Activity set to '{_client.Activity.Name}'");

        return Task.CompletedTask;
    }

    private static Task LogAsync(LogMessage log)
    {
        Console.WriteLine(log.ToString());

        return Task.CompletedTask;
    }

    private static ServiceProvider ConfigureServices()
    {
        return new ServiceCollection()
            .AddSingleton<DiscordSocketClient>()
            .AddSingleton<CommandService>()
            .AddSingleton<CommandHandlingService>()
            .BuildServiceProvider();
    }

}

Program.cs


namespace ArmarioBot;

public static class Program
{
    private static void Main()
    {
        new Startup().Initialize().GetAwaiter().GetResult();
    }
}

MySqlContext.cs

using ArmarioBot.Domain.Model;
using System;
using Microsoft.EntityFrameworkCore;

namespace ContaCentral.Infrastructure.Data.Context
{
    public class MySQLContext : DbContext
    {
        public MySQLContext(DbContextOptions<MySQLContext> options) : base(options)
        {
        }
        
        public DbSet<User> User { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
        }
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.