public async Task BeginRaid(string templateKey) { var softResTemplate = await _softResRaidTemplateRepository.FindAsync(templateKey); if (softResTemplate == null) { await ReplyAsync("No template by that name has been configured."); } var raid = await _softResClient.CreateRaid(opt => opt.ForFaction(softResTemplate.Faction) .ForInstance(softResTemplate.Instance) .TotalReserves(softResTemplate.ReserveAmounts)); var softResEntity = _mapper.Map <RaidModel, SoftResEvent>(raid); await _softResEventRepository.PostAsync(softResEntity); var embedBuilder = new EmbedBuilder().WithTitle($"Raid Event - {DateTime.Now.ToString("M")}") .AddField("Soft Res Sheet", $"[SoftRes.It](https://softres.it/raid/{raid.RaidId})", true) .AddField("Test", "Test", true) .AddField("Test", "Test", true) .WithTimestamp(DateTimeOffset.Now); var message = await ReplyAsync("", false, embedBuilder.Build()); var userDM = await Context.User.GetOrCreateDMChannelAsync(); await userDM.SendMessageAsync($"Soft Reserve Raid created successfully. Token = {raid.Token}"); var raidEntity = new Raid() { SoftResEventId = raid.RaidId, StartTime = DateTime.UtcNow, Channel = await _channelService.AddOrGetChannel(Context), MessageId = message.Id }; await _raidRepository.PostAsync(raidEntity); await _raidRepository.SaveAllChangesAsync(); }
public async Task TestRaidMonitor(string raidKey) { var raid = await _softClient.Query(raidKey); var embed = await _raidMonitorMessageFactory.CreateRaidMonitorEmbed(raid); var message = await ReplyAsync("", false, embed); var softResRaidEntity = await _softResEventRepository.FindAsync(raidKey) ?? new SoftResEvent(); _mapper.Map <RaidModel, SoftResEvent>(raid, softResRaidEntity); var raidMonitor = new SoftResRaidMonitor() { CreatedAt = DateTime.UtcNow, RemoveAt = DateTime.UtcNow + TimeSpan.FromMinutes(15), Id = message.Id, RaidChannel = await _channelService.AddOrGetChannel(Context), SoftResEvent = softResRaidEntity }; await _raidMonitorRepository.PostAsync(raidMonitor); await _raidMonitorRepository.SaveAllChangesAsync(); }