public async Task SetCall([Remainder] string args = null) { StringBuilder sb = new StringBuilder(); var embed = new EmbedBuilder(); CallSignAssociation callInfo = null; callInfo = _db.CallSignAssociation.Where(d => d.DiscordUserId == (long)Context.User.Id).FirstOrDefault(); if (callInfo != null) { var record = _db.CallSignAssociation.Where(r => r.DiscordUserId == (long)Context.User.Id).FirstOrDefault(); record.CallSign = args.ToUpper(); await _db.SaveChangesAsync(); } else { _db.CallSignAssociation.Add(new CallSignAssociation { DiscordUserId = (long)Context.User.Id, DiscordUserName = Context.User.Username, CallSign = args.ToUpper() }); await _db.SaveChangesAsync(); } sb.AppendLine($"{Context.User.Mention} your call sign is now set to:"); sb.AppendLine($"{args.ToUpper()}"); embed.Title = $"Call sign information for {Context.User.Username}!"; embed.Description = sb.ToString(); await ReplyAsync(null, false, embed.Build()); }
public async Task GetCall([Remainder] string args = null) { StringBuilder sb = new StringBuilder(); var embed = new EmbedBuilder(); CallSignAssociation callInfo = null; using (var db = _db) { callInfo = db.CallSignAssociation.Where(d => d.DiscordUserId == (long)Context.User.Id).FirstOrDefault(); } if (callInfo != null) { sb.AppendLine($"{Context.User.Mention} your call sign is:"); sb.AppendLine($"{callInfo.CallSign}"); } else { sb.AppendLine($"No data found!"); } embed.Title = $"Call sign information for {Context.User.Username}!"; embed.Description = sb.ToString(); await ReplyAsync(null, false, embed.Build()); }