コード例 #1
0
        async Task ICeaSubCommand.Run(SocketSlashCommand command, DiscordSocketClient client, IReadOnlyDictionary <SlashCommandOptions, string> options, Lazy <List <Team> > lazyTeams)
        {
            // Responding prior to update as update may take longer than 3s which is the maximum timeout for discord command.
            await command.RespondAsync("Refresh Started.", ephemeral : true);

            LeagueManager.ForceUpdate();
        }
コード例 #2
0
        public override async Task HandleCommandAsync(SocketSlashCommand command, DiscordSocketClient client, StorageClient storageClient, Guild guild)
        {
            var    subCommand    = command.Data.Options.Where(o => o.Type.Equals(ApplicationCommandOptionType.SubCommand)).First();
            string configuration = (string)subCommand.Options.Where(o => o.Name.Equals("configuration")).First().Value;

            try
            {
                BracketConfiguration newConfiguration = JsonSerializer.Deserialize <BracketConfiguration>(configuration);
                ConfigurationManager.UpdateInMemoryConfiguration(newConfiguration);
                await command.RespondAsync($"New Configuration Set.\n{configuration}", ephemeral : true);

                LeagueManager.ForceUpdate();
            }
            catch (JsonException)
            {
                await command.RespondAsync("Invalid BracketConfiguration JSON.", ephemeral : true);

                throw;
            }
            catch (Exception e)
            {
                await command.RespondAsync($"Unknown Exception.\n{e}", ephemeral : true);

                throw;
            }
        }