Exemple #1
0
        public async Task RaidCreate(
            [Summary("Název bosse.")] string bossName,
            [Summary("Místo.")] string location,
            [Summary("Čas (" + TimeService.TimeFormat + ").")] DateTime time)
        {
            time = timeService.EnsureUtc(time);
            if (time < DateTime.UtcNow)
            {
                await ReplyAsync($"Vážně chceš vytvořit raid v minulosti?");

                return;
            }
            if (!timeService.IsToday(time))
            {
                await ReplyAsync($"Raid není dnes.");

                return;
            }

            var raidChannelBinding = raidChannelService.TryGetRaidChannelBinding(Context.Guild.Id, Context.Channel.Id);

            var raidInfo = new RaidInfoDto(RaidType.Normal)
            {
                BossName = bossName,
                Location = location,
                DateTime = time,
            };

            var    roles         = teamService.GuildTeamRoles[Context.Guild.Id].TeamRoles.Values;
            bool   shouldMention = !(configuration.GetGuildOptions(Context.Guild.Id)?.IgnoreMention ?? false);
            string mention       = string.Empty;

            if (shouldMention)
            {
                mention = raidChannelBinding.Mention == null?string.Join(' ', roles.Select(t => t.Mention)) : raidChannelBinding.Mention.Mention;
            }

            var message = await raidChannelBinding.Channel.SendMessageAsync($"{raidService.ToSimpleString(raidInfo)} {mention}", embed : raidService.ToEmbed(raidInfo));

            logger.LogInformation($"New raid has been created '{raidService.ToSimpleString(raidInfo)}'");
            raidInfo.Message = message;
            await Context.Message.AddReactionAsync(Emojis.Check);

            await raidService.SetDefaultReactions(message);

            raidStorageService.AddRaid(Context.Guild.Id, raidChannelBinding.Channel.Id, message.Id, raidInfo);

            await message.ModifyAsync(t =>
            {
                t.Content = string.Empty;
                t.Embed   = raidService.ToEmbed(raidInfo);
            }, retryOptions);
        }