i am trying to make a discord bot and i am getting errors using c#

Koi Moses 1 Reputation point
2022-12-03T09:52:02.803+00:00

this is my code
using System;
using DSharpPlus;

namespace DiscordBot
{
class Program
{

static void Main()
{
MainAsync().GetAwaiter().GetResult();
}
static async Task MainAsync()
{
var discord = new DiscordClient(new DiscordConfiguration()
{
Token = "MTA0ODUxOTY0MTcyNDYxNjc0NA.GXGNNI.QU_O6qd1mwLksiBTx9jOO8tV3XieEj6w_1sOiE",
TokenType = TokenType.Bot,
Intents = DiscordIntents.AllUnprivileged,
});

        new DiscordConfiguration()  
        {  
            MinimumLogLevel = Microsoft.Extensions.Logging.LogLevel.Debug,  
        };  
      
          
      
      
      
      
      
    await discord.ConnectAsync();  
    await Task.Delay(-1);  
    }  

}
^ right there is where i keep getting errors i keep getting error cs1513

Developer technologies | C#
{count} votes

1 answer

Sort by: Most helpful
  1. AgaveJoe 30,126 Reputation points
    2022-12-03T12:40:21.69+00:00

    The error message states the code is missing an ending bracket to close the namespace. It also looks like you are missing using statements at the top of the file.

    namespace DiscordBot  
    {  
        class Program  
        {  
            public static object TokenType { get; private set; }  
      
            static void Main()  
            {  
                MainAsync().GetAwaiter().GetResult();  
            }  
            static async Task MainAsync()  
            {  
                var discord = new DiscordClient(new DiscordConfiguration()  
                {  
                    Token = "MTA0ODUxOTY0MTcyNDYxNjc0NA.GXGNNI.QU_O6qd1mwLksiBTx9jOO8tV3XieEj6w_1sOiE",  
                    TokenType = TokenType.Bot,  
                    Intents = DiscordIntents.AllUnprivileged,  
                });  
      
                new DiscordConfiguration()  
                {  
                    MinimumLogLevel = Microsoft.Extensions.Logging.LogLevel.Debug,  
                };  
      
                await discord.ConnectAsync();  
                await Task.Delay(-1);  
            }  
        }  
    }  
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.