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 (Exception) { } } try { 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.Client.SendMessageToChannel(e.Channel, e.Command.Description); 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.Client.SendMessageToChannel(e.Channel, "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) { } 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; }