private async Task ProcessAdd(List <string> args) { if (args.Count == 1) { var name = args[0]; var plog = await _plogDbContext.Plogs.Where(p => p.Name.ToLower() == name.ToLower()).FirstOrDefaultAsync(); if (plog == null) { var character = await _bladeAndSoulService.GetBladeAndSoulCharacter(name); if (character == null || character.Clan.ToLower() != "ploggystyle") { _response = $"{name} is not in Ploggystyle."; } else { plog = new ClanMember { RealName = character.AccountName, Name = name, Active = true, Class = character.Class, Created = DateTime.UtcNow, ImageUrl = character.ProfileImageUrl }; _plogDbContext.Add(plog); await _plogDbContext.SaveChangesAsync(); _response = $"{name} has been added to the clan."; } } else { _response = "This plog already exists!"; if (plog.DiscordId.HasValue && plog.DiscordId.Value != _event.Message.Author.Id) { _response += $" <@{plog.DiscordId}> has claimed this character."; } } } else { _response = "Incorrect command format: !plog add [name]"; } await _messageService.SendMessage(_event.Message.ChannelId, new OutgoingMessage { Content = _response }); }
public async Task CreateAlert(string name, int time, int?day, string text, List <ulong> roles, ulong channel, ulong user) { var timeInfo = await _timeZoneService.GetTime(user, day, time); var alert = new Alert { Name = name, Description = text, Roles = roles.ConcatenateULongs(), Time = timeInfo.Item2, Day = timeInfo.Item1, ChannelId = channel, DiscordUserId = user }; _plogDbContext.Add(alert); await _plogDbContext.SaveChangesAsync(); }
public async Task SaveTimeZonePreference(string abbreviation, ulong discordUserId) { var timePref = await _plogDbContext.Times.FirstOrDefaultAsync(t => t.DiscordUserId == discordUserId); if (timePref == null) { timePref = new TimeZonePreference { DiscordUserId = discordUserId, TimeZone = abbreviation }; _plogDbContext.Add(timePref); } else { timePref.TimeZone = abbreviation; _plogDbContext.Update(timePref); } await _plogDbContext.SaveChangesAsync(); }