APEXBox出错:错误CS1501:方法'Connect'没有重载需要1个参数

时间:2017-04-17 07:16:35

标签: c# discord discord.net

当我尝试编码我的Discord bot时,会出现此错误:

  

错误:“/ Users /jadenlee / Project / APEXBot / APEXBot / MyBot.cs(19,19):错误CS1501:方法”连接“没有重载需要1个参数(CS1501)(APEXBot)”

这是我现在的代码。

using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Discord;
using Discord.Commands;

namespace APEXBot
{
    class MyBot
    {
        DiscordClient discord;

        public MyBot()
        {
            discord = new DiscordClient(x =>
            {
                x.LogLevel = LogSeverity.Info;
                x.LogHandler = Log;
            });

            discord.ExecuteAndWait(async () =>
            {
                //    Error here
                await discord.Connect("MzAzMzQyMzAyNjUzMzE3MTIx.C9X34w.loaFfJMxb1N2o7Aoqf0H4xVMnGo");
            });
        }

        private void Log(object sender, LogMessageEventArgs e)
        {
            Console.WriteLine(e.Message);
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您应该使用带有两个参数的方法

await discord.Connect("MzAzMzQyMzAyNjUzMzE3MTIx.C9X34w.loaFfJMxb1N2o7Aoqf0H4xVMnGo",TokenType.Bot);