【问题标题】:Error in APEXBox: Error CS1501: No overload for method 'Connect' takes 1 argumentsAPEXBox 中的错误:错误 CS1501:方法“连接”没有重载需要 1 个参数
【发布时间】:2017-09-12 19:20:26
【问题描述】:

当我尝试编写我的 Discord 机器人时,出现了这个错误:

错误:“/Users/jadenlee/Projects/APEXBot/APEXBot/MyBot.cs(19,19):错误 CS1501:方法 'Connect' 没有重载需要 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);
        }
    }
}

【问题讨论】:

  • 您好,欢迎来到 SO。首先,错误消息是完全描述性的:DiscordClient 上没有采用 String 参数的方法。您需要检查 API 支持哪些方法。其次,请仔细阅读this discussion在你的问题中使用ASAP之类的词。

标签: c# discord discord.net


【解决方案1】:

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

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

【讨论】:

  • 这行得通,但现在它说System.Exception has been thrown You must send data by web socket after web socket is opened!
  • 旁边还有Record Overflow
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-04
  • 1970-01-01
  • 1970-01-01
  • 2023-03-05
相关资源
最近更新 更多