public async Task <bool> Execute(CommandArguments e) { if (this.OnExecute == null) { return(false); } if ((this.DeleteRequest || (e.CommandOptions != null && e.CommandOptions.DeleteRequest)) && e.Server.Guild.CurrentUser.GuildPermissions.ManageMessages) { try { if (!e.Message.Deleted) { await e.Message.DeleteAsync(); } } catch (HttpException exception) { await e.Server.HandleHttpException(exception, $"Failed to delete the command message in <#{e.Channel.Id}>"); } catch (Exception exception) { await e.Client.LogException(exception, e); } } try { e.Client.Monitoring.Commands.Inc(); await e.Client.LogMessage(LogType.Command, e.Channel, e.Message); if (this.SendTyping) { await e.Channel.TriggerTypingAsync(); } if (!string.IsNullOrWhiteSpace(e.TrimmedMessage) && e.TrimmedMessage == "help") { await e.SendReplySafe(e.Command.ManPage.ToString(e.Server.Config.CommandPrefix + e.CommandId)); return(true); } if (this.Type == CommandType.Standard) { Task task = this.OnExecute(e); /*if( await Task.WhenAny(task, Task.Delay(GlobalConfig.CommandExecutionTimeout)) == task ) //todo * {*/ await task; /*} * else * { * await e.SendReplySafe("Command execution timed out. _(Please wait a moment before trying again.)_"); * throw new TimeoutException(); * }*/ } else { Operation operation = Operation.Create(e); await operation.Execute(); } } catch (HttpException exception) { await e.Server.HandleHttpException(exception, $"This happened in <#{e.Channel.Id}> when executing command `{e.CommandId}`"); } catch (Exception exception) { await e.Client.LogException(exception, e); } return(true); }
private Operation(CommandArguments commandArgs, float memory) { this.CommandArgs = commandArgs; this.AllocatedMemoryStarted = memory; commandArgs.Operation = this; }