Я пытаюсь демигрировать следующий код с 5 на 3.5 и получаю эту ошибку:
CS1513: строка 203: } ожидается
ошибка при ссылке на вторую фигурную скобку этой части
catch //(Exception ex)
{
//DClient.Error(ex); }
из приведенного ниже метода, и я не могу понять, почему он дает это сообщение. это еще не в sln для VS, и я, честно говоря, не уверен, как это сделать, или если бы это даже дало мне правильное «предлагаемое исправление», мне нужно было бы исправить это
public void Invoke(MessageCreateEventArgs e)
{
try
{
if (e == null ||
!e.Message.Content[0].Equals(CommandPrefix))
return;
List<string> parameters = Split(e.Message.Content);
if (parameters == null)
parameters = new List<string>();
string command;
if (parameters.Count == 0)
command = e.Message.Content;
else
command = parameters[0];
command = command.TrimStart(CommandPrefix);
AccessLevel access = DClient.UserManager.GetAccessLevel(e.Author.Id);
//Return when command channel is set, we are outside of it and have accesslevel vip or lower
//Return when we cannot find the command itself
//Return when the command is disabled
if ((e.Guild!= null && access <= AccessLevel.VIP && DClient.Settings.CommandChannelId!= 0 && DClient.Settings.CommandChannelId!= e.Channel.Id) ||
!_commands.TryGetValue(command.ToLower(), out ICommand cmd))
return;
else if (cmd.IsDisabled)
{
e.Channel.SendMessageAsync("Command is currently disabled");
return;
}
switch (cmd.CommandType)
{
case CommandType.None:
break;
case CommandType.Private:
if (e.Guild!= null)
{
e.Channel.SendMessageAsync("You can only use this command in a private chat!");
return;
}
break;
case CommandType.Public:
if (e.Guild == null)
{
e.Channel.SendMessageAsync("You can only use this command in a server chat!");
return;
}
break;
}
if (access < cmd.AccessLevel)
{
e.Channel.SendMessageAsync("You do not have enough permissions to use this command");
return;
}
if (parameters.Count > 0)
parameters.RemoveAt(0);
if (cmd.MinParameters > 0 && parameters.Count < cmd.MinParameters)
{
e.Channel.SendMessageAsync("Not enough parameters");
return;
}
string afterCmd = e.Message.Content;
if (afterCmd.Length > cmd.Command.Length + 1)
afterCmd = afterCmd.Remove(0, cmd.Command.Length + 2);
else
afterCmd = string.Empty;
DiscordMember member = null;
if (e.Guild!= null)
{
try
{
member = e.Guild.GetMemberAsync(e.Author.Id).ConfigureAwait(false).GetAwaiter().GetResult();
}
catch (AggregateException ex)
{
if (!ex.InnerExceptions.Any(t => t is NotFoundException))
throw;
}
}
CommandEventArgs arg = new CommandEventArgs(e.Guild, e.Channel, e.Author, member,
e.Message, access, parameters, afterCmd);
ThreadPool.QueueUserWorkItem( new WaitCallback( SendCallback ), arg );
/* ThreadPool.QueueUserWorkItem(new WaitCallback(o =>
{
try
{
cmd.Invoke(this, arg);
}
catch (Exception ex)
{
if (ex is UnauthorizedException)
{
e.Channel.SendMessageAsync("Internal Error: Unauthorized (This error can happen when the bot tries to send a message to someone via DM but the user has disabled DMs from non friends)");
return;
}
if (Debug)
e.Channel.SendMessageAsync(GetDebugExceptionMessage(ex));
else
e.Channel.SendMessageAsync("Something went wrong executing this command");
}
})); */
}
catch //(Exception ex)
{
//DClient.Error(ex);
}
string GetDebugExceptionMessage(Exception ex)
{
return ("Something went wrong executing this command (L: {0} At: {1}.{2}: {3})", GetLineNumber(ex), (ex.TargetSite.DeclaringType?.FullName?? "unkown", ex.TargetSite.Name, ex.Message, ));
}
}
Решение проблемы
Ответ Джереми Лейкмана решил это
Комментариев нет:
Отправить комментарий