Discord bot running, but will not connect to server

后端 未结 1 2047
余生分开走
余生分开走 2021-01-23 14:28

I\'ve been trying to swap over my code from the 0.9.6 Discord.NET API to the new 1.0.1 API, and it\'s basically calling for a complete restructure to my code. But I\'ve been hav

相关标签:
1条回答
  • 2021-01-23 14:57

    The first thing you might want to do is add some logging to your bot. As your code might be correct, but discord could be rejecting your connection for any amount of reason.

    After await client.StartAsync(); add

    client.Log += (msg) => {return Console.WriteLine(${msg.ToString()}");};`
    

    This will output the message your receive from your client to the console.

    Now you also need to configure which message should be send to this event. This can be done when creating your DiscordClient(). So instead of client = new DiscordSocketClient(); You could use

    client = new DiscordSocketClient(
        new DiscordSocketConfig()
        {
             LogLevel = LogSeverity.Verbose
        }
     );
    

    Verbose should give you all the information you need. However you could also use LogSeverity.Debug instead, which is the highest available logging, and therefore would give you all messages.

    Now that you have some feedback in your console, go and see what concrete errors you are having.

    Also I would recommend first completing the your first bot part of the linked tutorial, instead of stepping into the commands directly. Once you got this working, you can continue onwards

    0 讨论(0)
提交回复
热议问题