【发布时间】:2018-06-03 02:16:08
【问题描述】:
错误:“UserBanned”没有重载匹配委托“Func”
我知道我被禁止的用户消息缺少一个参数,并且我知道我必须在该参数的括号中添加一些内容,但我完全不知道我应该输入什么。我已经寻找了一两个小时,也许答案就在我脸上,但我不知道,但我仍然不知道该怎么办。我想我应该在括号中添加一个变量,但我不确定是什么。
public async Task RunBotAsync()
{
_client = new DiscordSocketClient(new DiscordSocketConfig
{
LogLevel = LogSeverity.Verbose
});
_commands = new CommandService();
_services = new ServiceCollection()
.AddSingleton(_client)
.AddSingleton(_commands)
.BuildServiceProvider();
string botToken = "Token";
//event subscriptions
_client.Log += Log;
_client.UserJoined += UserJoined;
_client.UserLeft += UserLeft;
_client.UserBanned += UserBanned; //<- Error Line
await RegisterCommandsAsync();
await _client.LoginAsync(TokenType.Bot, botToken);
await _client.StartAsync();
await Task.Delay(-1);
}
private async Task UserBanned(SocketGuildUser user, IGuild bloop)
{
var guild = user.Guild;
var announcements = _client.GetChannel(390418472783577088) as SocketTextChannel;
await announcements.SendMessageAsync($"{user.Mention} was banned from the server.");
}
【问题讨论】:
-
为什么您的帖子中没有包含确切的错误消息?为什么你还没有确定是哪条线路造成的?这些细节就在你面前的屏幕上。它们也会对我们有用。
-
这样更好吗?
标签: c# discord discord.net