基本上,我为第一个Disord机器人写了代码(可能是错误的)。仅登录的基本版本将无法运行。它给我关于的错误
找不到类型或名称空间名称'DiscordClient
与“ LogMessageEventArgs”重复相同
程序代码:
using Discord;
using Discord.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiscordBot
{
class Program
{
static void Main(string[] args)
{
MyBot bot = MyBot();
}
}
}
MyBot代码:
using Discord;
using Discord.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiscordBot
{
class MyBot
{
DiscordClient discord;
public MyBot()
{
discord = new DiscordClient(x =>
{
x.LogLevel = LogSeverity.Info;
x.LogHandler = Log;
});
discord.ExecuteAndWait(async () =>
{
await discord.Connect("the token");
});
}
private void Log (object sender, LogMessageEventArgs e)
{
Console.WriteLine(e.Message);
}
}
}
相关分类