当我尝试编码我的Discord Bot时,此错误会出现:
错误:"/users/jadenlee/projects/apexbot/apexbot/mybot.cs(19,19(:错误CS1501:方法'Connect'没有超载'连接'取1个参数(CS1501((cs1501((apexbot((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);
}
}
}
您应该使用两个参数的方法
await discord.Connect("MzAzMzQyMzAyNjUzMzE3MTIx.C9X34w.loaFfJMxb1N2o7Aoqf0H4xVMnGo",TokenType.Bot);