public BasicRequestCommand( Criteria<FrontControllerRequest> request_criteria, ApplicationCommand application_command) { this.request_specification = request_criteria; this.application_command = application_command; }
public async Task StartAsync(CancellationToken cancellationToken) { _logger.LogDebug("Test guild: '{Id}'", _settings.Value.TestGuildId); _handlers = _gateway.AddEventHandler(Event.GuildCreate, async(Guild guild) => { var sb = new StringBuilder(); sb.AppendLine($"New guild '{guild.Name}'"); sb.AppendLine("Channel list"); foreach (var channel in guild.Channels) { sb.AppendLine($"\t'{channel.Name}', type '{channel.Type}'"); } var members = await _api.GetAsync <GuildMember[]>($"/guilds/{guild.Id}/members?limit=500", cancellationToken); sb.AppendLine("User list"); if (members is not null) { foreach (var member in members) { var user = member.User; if (user is not null) { sb.AppendLine($"\t'{user.Username}#{user.Discriminator}', joined at '{member.JoinedAt}'"); } else { sb.AppendLine($"\tUNKNOWN USER, joined at '{member.JoinedAt}'"); } } } else { sb.AppendLine("\t-"); } _logger.LogInformation(sb.ToString()); if (guild.Id != _settings.Value.TestGuildId) { return; } // This is the test guild, add a command! var helloWorldCommand = new ApplicationCommand { Name = "hello", Description = "My first slash command!", Type = ApplicationCommandType.ChatInput }; }); }
public async Task <ApplicationCommand?> RegisterCommandAsync(ApplicationCommand command, ulong guildId, CancellationToken cancellationToken) { var result = await _api.PostAsync <ApplicationCommand, ApplicationCommand>($"/applications/{_gateway.ApplicationId}/guilds/{guildId}/commands", command, cancellationToken); if (result is not null) { _logger.LogInformation("Added application command '{Command}'", result.Name); } else { _logger.LogError("Failed trying to add command '{Command}'", command.Name); } return(result); }
private void InitializePrperty() { BookCollection = new ObservableCollection <BookModel>(); BookCollectionBelongingToSelectedCustomer = new ObservableCollection <BookModel>(); CustomerCollection = new ObservableCollection <CustomerModel>(); CustomerCollectionHavingBook = new ObservableCollection <CustomerModel>(); AllOrderData = new List <CheckOutModel>(); CheckOut = new ApplicationCommand(CheckOutBook); CheckIn = new ApplicationCommand(CheckInBook); GetBooks(); GetAllCustomer(); GetAllOrders(); GetAllCustomerHavingBook(); }
public static void SetCommand(MyViewModel vm, Expression <Func <MyViewModel, ICommand> > commandSelector, Action action) { var me = commandSelector.Body as MemberExpression; if (me == null) { throw new ArgumentException("Invalid command selector!"); } var newCommand = new ApplicationCommand(action); newCommand.commandName = me.Member.Name; vm.GetType() .GetProperty(newCommand.commandName) .SetValue(vm, newCommand, null); }
public Settings() { InitializeComponent(); DataContext = this; Sensitivity = SCORE_SENSITIVITY; BatchSize = IMAGE_BATCH_SIZE; ResizeFactor = RESIZE_IMAGES_FACTOR; RedFlagAlertsCountry = RED_FLAGS_COUNTRY_CODE; FlyingAltitude = 400; AverageFlyingSpeed = 27; CameraAngle = 90; CmdOk = new ApplicationCommand(CmdOk_Execute); CmdCancel = new ApplicationCommand(CmdCancel_Execute); CmdSubscription = new ApplicationCommand(CmdSubscription_Execute); }
public ApplicationCommandShould() { _autoMocker = new AutoMocker(); _autoFixture = new Fixture(); _subject = _autoMocker.CreateInstance <ApplicationCommand>(); var data = new[] { _autoFixture.Build <AccidentStatistic>() .With(x => x.DateAsString, new DateTime(2017, 03, 03).ToString("yyyy-MM-ddTHH:mm:ssZ")) .Create() }; _pagingAccidentResponse = CreatePagedAccidentStatistic(data, 1, 1); _transportForLondonClientMock = _autoMocker.GetMock <ITransportForLondonClient>(); _transportForLondonClientMock.Setup(x => x.GetAccidentStatistics( It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <Severity>(), It.IsAny <SortOptions <AccidentStatistic> >(), It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync(() => _pagingAccidentResponse); _loggerMock = _autoMocker.GetMock <ILogger>(); _loggerMock.Setup(x => x.Debug(It.IsAny <string>())); _loggerMock.Setup(x => x.Information(It.IsAny <string>())); }
private async Task NewCommandInternalAsync(Uri url, ApplicationCommand command, CancellationToken cancellationToken) { using var stream = new MemoryStream(); await JsonSerializer.SerializeAsync(stream, command, cancellationToken : cancellationToken); stream.Seek(0, SeekOrigin.Begin); var content = new StreamContent(stream); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); using var req = new HttpRequestMessage(HttpMethod.Post, url) { Content = content, }; await SendAsync(req, cancellationToken); _logger.LogInformation("Command updated successfully"); }
SlashCommand? GetCommand(CommandNode cmdNode) { var command = new ApplicationCommand(); command.Name = cmdNode.Name; command.Description = "top level"; var options = new List<ApplicationCommandOption>(); foreach (var node in cmdNode.GetChildNodes()) { options.Add(GetOption(node)); } command.Options = options.ToArray(); var meta = cmdNode.Meta as CommandMetaData; var t = new SlashCommand(command, meta?.guild_id, meta); //t._applicationCommand = command; return t; }
public DefaultRequestCommand(Predicate<Request> request_specification, ApplicationCommand application_command) { this.request_specification = request_specification; this.application_command = application_command; }
public void Execute(GameConnection sender, ApplicationCommand command) { game.Execute(players[sender], (GameCommand)command); }
public DefaultCommand(Predicate<Request> criteria,ApplicationCommand command) { this.criteria = criteria; this.application_command = command; }
public PasteCommand(Editor editor, ApplicationCommand app, string regexText) : base(editor, app) { RegexText = regexText; }
public PasteCommand(Editor editor, ApplicationCommand app) : base(editor, app) { }
public DefaultRequestCommand(RequestCommandSpecification request_command_specification, ApplicationCommand application_command) { this.request_command_specification = request_command_specification; this.application_command = application_command; }
public UndoCommand(Editor editor, ApplicationCommand app) : base(editor, app) { }
public DefaultWebCommand(RequestCriteria criteria, ApplicationCommand command) { this.criteria = criteria; this.command = command; }
public Task NewCommandAsync(string applicationId, ApplicationCommand command, CancellationToken cancellationToken) { var url = new Uri($"https://discord.com/api/v8/applications/{applicationId}/commands"); return(NewCommandInternalAsync(url, command, cancellationToken)); }
public void Execute(ApplicationCommand command) { GameCommand game_command = (GameCommand)command; switch (game_command.type) { case "Message": { gui.ShowStringMessage(command.body); break; } case "Booster": { string[] ids = game_command.body.Split(','); List <Card> tmp = new List <Card>(); foreach (string id in ids) { Card card = allcards.Find(crd => crd.Id.ToString() == id); if (card == null) { throw new Exception("CARD NOT FOUND: " + id.ToString()); } tmp.Add(card); } gui.ShowBooster(tmp); break; } case "PlayCard": { if (current_playmode != null) { // !!! // тоже костыль, надо сразу научить игру просить то, что надо GameCommand response = new GameCommand("PlayMode", current_playmode); Send(response); } else { throw new Exception("Empty card play mode"); } break; } case "CurrentGold": { gui.DisplayGold(command.body); break; } case "Board": { string[] ids = game_command.body.Split(','); List <Card> tmp = new List <Card>(); foreach (string id in ids) { tmp.Add(allcards.Find(card => card.Id.ToString() == id)); } gui.DisplayBoard(tmp); break; } case "Wonder": { Wonder wonder = allwonders.Find(wnd => wnd.Id == Convert.ToInt32(command.body)); gui.DisplayWonder(wonder); break; } case "NewTier": { gui.DisplayNewTier(); break; } case "GameState": { int gold = (int)game_command.Data["Gold"]; gui.DisplayGameState(gold); break; } } }
protected Command(Editor editor, ApplicationCommand app) { Editor = editor; App = app; }
internal MediaKeyPressedEventArgs(ApplicationCommand command) { Command = command; }
public RequestCommand create_command(Criteria<FrontControllerRequest> criteria, ApplicationCommand application_command) { return new BasicRequestCommand(criteria, application_command); }
public DefaultRequestCommand(RequestCriteria criteria, ApplicationCommand application_command) { this.criteria = criteria; this.application_command = application_command; }
public DefaultWebCommand(RequestCriteria request_criteria, ApplicationCommand application_command) { this.request_criteria = request_criteria; this.application_command = application_command; }