public async Task AddResponse([Remainder] string message) { var sb = new StringBuilder(); await _db.AddAsync(new RememberThis { AnswerText = message, AnswerAuthor = Context.User.Username.ToString() } ); await _db.SaveChangesAsync(); sb.AppendLine("I'll try to remember that"); await ReplyAsync(sb.ToString()); await Task.Delay(5000); var messages = Context.Channel.GetMessagesAsync(2).Flatten(); foreach (var h in await messages.ToArrayAsync()) { await this.Context.Channel.DeleteMessageAsync(h); } }
public async Task AddResponse(string answer, string color) { var sb = new StringBuilder(); var embed = new EmbedBuilder(); // get user info from the Context var user = Context.User; // check to see if the color is valid if (!_validColors.Contains(color.ToLower())) { sb.AppendLine($"**Sorry, [{user.Username}], you must specify a valid color.**"); sb.AppendLine("Valid colors are:"); sb.AppendLine(); foreach (var validColor in _validColors) { sb.AppendLine($"{validColor}"); } embed.Color = new Color(255, 0, 0); } else { // add answer/color to table await _db.AddAsync(new EightBallAnswer { AnswerText = answer, AnswerColor = color.ToLower() } ); // save changes to database await _db.SaveChangesAsync(); sb.AppendLine(); sb.AppendLine("**Added answer:**"); sb.AppendLine(answer); sb.AppendLine(); sb.AppendLine("**With color:**"); sb.AppendLine(color); embed.Color = new Color(0, 255, 0); } // set embed embed.Title = "Eight Ball Answer Addition"; embed.Description = sb.ToString(); // send embed reply await ReplyAsync(null, false, embed.Build()); }
public async Task AddTacbux(string user, int amount) { var embed = new EmbedBuilder(); var userList = await _db.TacbuxSystem.ToListAsync(); var userToAdjust = userList.Where(a => a.User == user).FirstOrDefault(); if (Context.User.Equals(await Context.Guild.GetOwnerAsync())) { if (userToAdjust != null) { embed.Title = "Tacbux"; embed.WithAuthor(Context.Client.CurrentUser); embed.Description = $"{amount} tacbux given to {user}, amounting to {userToAdjust.TacbuxTotal + (long)amount}."; userToAdjust.TacbuxTotal = userToAdjust.TacbuxTotal + (long)amount; await _db.SaveChangesAsync(); } else { await _db.AddAsync(new TacbuxSystem { User = user, TacbuxTotal = (long)amount } ); embed.Title = "Tacbux"; embed.WithAuthor(Context.Client.CurrentUser); embed.Description = $"User {user} created in database. {amount} tacbux given to {user}, amounting to {(long)amount}."; await _db.SaveChangesAsync(); } } else { embed.Title = "Tacbux"; embed.WithAuthor(Context.Client.CurrentUser); embed.Description = $"{Context.User.Username.ToString()} does not have permission level required to use this command."; } await ReplyAsync(null, false, embed.Build()); }