public async Task ExecuteCommandAsync(SocketSlashCommand command, IServiceScopeFactory scopeFactory)
        {
            await command.RespondAsync(embed : CommandHelper.WaitResponceBuilder.Build());

            using var scope = scopeFactory.CreateScope();

            var destinyInfocards = scope.ServiceProvider.GetRequiredService <IDestinyInfocards>();

            var infocard = await destinyInfocards.GetLostSectorsInfocardAsync();

            var builder = InfocardHelper.ParseInfocard(infocard);

            await command.ModifyOriginalResponseAsync(x => x.Embed = builder.Build());
        }
        public async Task SendResetNotificationAsync()
        {
            _logger.LogInformation($"{DateTime.Now} Servitor reset notification");

            using var scope = _scopeFactory.CreateScope();

            var destinyInfocards = scope.ServiceProvider.GetRequiredService <IDestinyInfocards>();

            List <Task <Embed> > tasks = new();

            var currDate = DateTime.UtcNow;

            if (currDate.DayOfWeek == DayOfWeek.Tuesday)
            {
                tasks.Add(Task.Run(async() =>
                {
                    var infocard = await destinyInfocards.GetEververseInfocardAsync();

                    return(InfocardHelper.ParseInfocard(infocard).Build());
                }));
            }

            tasks.Add(Task.Run(async() =>
            {
                var infocard = await destinyInfocards.GetLostSectorsInfocardAsync();

                return(InfocardHelper.ParseInfocard(infocard).Build());
            }));

            tasks.Add(Task.Run(async() =>
            {
                var infocard = await destinyInfocards.GetResourcesInfocardAsync();

                return(InfocardHelper.ParseInfocard(infocard).Build());
            }));

            var embeds = await Task.WhenAll(tasks);

            foreach (var channeldID in _mainChannelIDs)
            {
                var channel = _client.GetChannel(channeldID) as IMessageChannel;

                await channel.SendMessageAsync(embeds : embeds);
            }
        }
예제 #3
0
        public async Task ExecuteCommandAsync(SocketSlashCommand command, IServiceScopeFactory scopeFactory)
        {
            await command.RespondAsync(embed : CommandHelper.WaitResponceBuilder.Build());

            var option = command.Data.Options.FirstOrDefault();

            using var scope = scopeFactory.CreateScope();

            var destinyInfocards = scope.ServiceProvider.GetRequiredService <IDestinyInfocards>();

            var infocard = option is null ?
                           await destinyInfocards.GetEververseInfocardAsync() :
                           await destinyInfocards.GetEververseInfocardAsync((int)(long)option.Value);

            var builder = InfocardHelper.ParseInfocard(infocard);

            await command.ModifyOriginalResponseAsync(x => x.Embed = builder.Build());
        }