public async Task Waifu([Remainder] string extraTags = null) { DateTime curTime = DateTime.Now; DateTime lastMessage; lastMessage = _cooldowns.GetUserCooldownsForCommand("NSFW", Context.User.Id); if (lastMessage + new TimeSpan(0, 2, 0) > curTime) { var msg = await Context.Channel.SendErrorAsync("You may only use one of these NSFW commands every two minutes."); Context.Message.DeleteAfter(3); msg.DeleteAfter(3); return; } string waifu = null; using (var uow = DBHandler.UnitOfWork()) { waifu = uow.Waifus.GetRandomWaifu(); } if (waifu == null) { return; } if (extraTags != null) { if (extraTags.StartsWith("+")) { extraTags = extraTags.Substring(1); } waifu += " + " + extraTags; } string parsedWaifu = waifu.ParseBooruTags(); var message = await Context.Channel.SendSuccessAsync("Searching..."); string imageURL = await GetImageURL(parsedWaifu); EmbedBuilder eb = new EmbedBuilder(); //Big issue?! if (imageURL == null) { await message.ModifyAsync(x => x.Embed = eb.EmbedErrorAsync($"No images found. The specified tags probably don't exist: {waifu}.")); return; } _cooldowns.AddUserCooldowns("NSFW", Context.User.Id, curTime); //We have the URL let us use it await message.ModifyAsync(x => x.Embed = eb.PictureEmbed($"{waifu}", "", $"{imageURL}")); }
public async Task Claim(ulong side) { DateTime curTime = DateTime.Now; DateTime lastMessage; lastMessage = _cooldowns.GetUserCooldownsForCommand("InfiniteDieCreate", Context.User.Id); if (lastMessage + new TimeSpan(3, 0, 0) > curTime) { await Context.Channel.SendErrorAsync("You may only use this command once every 3 hours!"); return; } _cooldowns.AddUserCooldowns("InfiniteDieCreate", Context.User.Id, curTime); DBconnection _conn = DBconnection.Instance(); _conn.DBName = "cynicalp_weebnation"; ulong DiceID = 0; if (_conn.IsConnected()) { string query = "SELECT DiceID FROM dice WHERE DiceNumber=@side"; var cmd = new MySqlCommand(query, _conn.Connection); cmd.Parameters.AddWithValue("@side", side); var reader = await cmd.ExecuteReaderAsync(); if (!reader.HasRows) { return; } while (await reader.ReadAsync()) { DiceID = (ulong)reader.GetInt64(0); } _conn.Close(); } if (DiceID != 0) { await Context.Channel.SendErrorAsync("You cannot claim a side owned by someone."); return; } if (_conn.IsConnected()) { string query = "INSERT INTO dice(DiceNumber, DiceOwner) VALUES (@did, @dOwner)"; var cmd = new MySqlCommand(query, _conn.Connection); cmd.Parameters.AddWithValue("@did", side); cmd.Parameters.AddWithValue("@dOwner", Context.User.Id); await cmd.ExecuteNonQueryAsync(); _conn.Close(); } }
private bool AllowImage(ulong ChID) { DateTime curTime = DateTime.Now; DateTime lastImageInChannel; lastImageInChannel = _cooldowns.GetUserCooldownsForCommand("Interactions", ChID); if (lastImageInChannel + new TimeSpan(0, 5, 0) > curTime) { return(false); } _cooldowns.AddUserCooldowns("Interactions", ChID, curTime); return(true); }