public Task EightBallAsync(ICommandContext e) { string output = e.Locale.GetString("miki_module_fun_8ball_result", e.Author.Username, e.Locale.GetString(reactions[MikiRandom.Next(0, reactions.Length)])); e.Channel.QueueMessage(output); return(Task.CompletedTask); }
public async Task PunchAsync(EventContext e) => await QueueAction(e, "punches", punchImages[MikiRandom.Next(punchImages.Length)]);
public async Task LickAsync(EventContext e) => await QueueAction(e, "licks", lickImages[MikiRandom.Next(lickImages.Length)]);
public async Task GlareAsync(EventContext e) => await QueueAction(e, "glares at", glareImages[MikiRandom.Next(glareImages.Length)]);
public async Task HugAsync(EventContext e) => await QueueAction(e, "hugs", hugImages[MikiRandom.Next(hugImages.Length)]);
public async Task RollAsync(EventContext e) { string rollResult; if (string.IsNullOrWhiteSpace(e.Arguments.ToString())) // No Arguments. { rollResult = MikiRandom.Roll(100).ToString(); } else { if (int.TryParse(e.Arguments.ToString(), out int max)) // Simple number argument. { rollResult = MikiRandom.Roll(max).ToString(); } else // Assume the user has entered an advanced expression. { Regex regex = new Regex(@"(?<dieCount>\d+)d(?<dieSides>\d+)"); string fullExpression = e.Arguments.ToString(); int expressionCount = 0; foreach (Match match in regex.Matches(e.Arguments.ToString())) { GroupCollection groupCollection = match.Groups; int dieCount = int.Parse(groupCollection["dieCount"].Value); int dieSides = int.Parse(groupCollection["dieSides"].Value); string partialExpression = ""; for (int i = 0; i < dieCount; i++) { partialExpression += MikiRandom.Roll(dieSides).ToString(); if (i + 1 < dieCount) { partialExpression += " + "; } } fullExpression = regex.Replace(fullExpression, $"( {partialExpression} )", 1); expressionCount++; } if (expressionCount > 1) { fullExpression = $"( {fullExpression} )"; } Expression evaluation = new Expression(fullExpression); rollResult = evaluation.Evaluate().ToString() + $" `{fullExpression}`"; } } if (rollResult == "1" || rollResult.StartsWith("1 ")) { await AchievementManager.Instance.GetContainerById("badluck").CheckAsync(new BasePacket() { discordUser = e.Author, discordChannel = e.Channel }); } rollResult = Regex.Replace(rollResult, @"(\s)\s+", "$1"); rollResult = Regex.Replace(rollResult, @"(\S)([^\d\s])", "$1 $2"); e.Channel.QueueMessageAsync(e.Locale.GetString(LocaleTags.RollResult, e.Author.Username, rollResult)); }
public async Task CakeAsync(EventContext e) => await QueueAction(e, "feeds", cakeImages[MikiRandom.Next(cakeImages.Length)]);
public Task PickAsync(EventContext e) { string args = e.Arguments.Pack.TakeAll(); if (string.IsNullOrWhiteSpace(args)) { e.Channel.QueueMessage(e.Locale.GetString("miki_module_fun_pick_no_arg")); return(Task.CompletedTask); } string[] choices = args.Split(','); e.Channel.QueueMessage(e.Locale.GetString("miki_module_fun_pick", new object[] { e.Author.Username, choices[MikiRandom.Next(0, choices.Length)] })); return(Task.CompletedTask); }
public Task PunAsync(EventContext e) { e.Channel.QueueMessage(e.Locale.GetString(puns[MikiRandom.Next(0, puns.Length)])); return(Task.CompletedTask); }
public async Task SlapAsync(EventContext e) => await QueueAction(e, "slaps", slapImages[MikiRandom.Next(slapImages.Length)]);
public Task CageAsync(EventContext e) { e.Channel.QueueMessage("http://www.placecage.com/c/" + MikiRandom.Next(100, 1500) + "/" + MikiRandom.Next(100, 1500)); return(Task.CompletedTask); }
public async Task GiveawayAsync(EventContext e) { Emoji emoji = new Emoji("🎁"); var arg = e.Arguments.FirstOrDefault(); string giveAwayText = arg?.Argument ?? ""; arg = arg?.Next(); while (!(arg?.Argument ?? "-").StartsWith("-")) { giveAwayText += " " + arg.Argument; arg = arg?.Next(); } var mml = new MMLParser(arg?.TakeUntilEnd()?.Argument ?? "").Parse(); bool isUnique = mml.Get("unique", false); int amount = mml.Get("amount", 1); TimeSpan timeLeft = mml.Get("time", "1h").GetTimeFromString(); if (amount > 10) { e.ErrorEmbed("We can only allow up to 10 picks per giveaway") .Build().QueueToChannel(e.Channel); return; } giveAwayText = giveAwayText + ((amount > 1) ? " x " + amount : ""); List <IUser> winners = new List <IUser>(); IMessage msg = await CreateGiveawayEmbed(e, giveAwayText) .AddField("Time", (DateTime.Now + timeLeft).ToShortTimeString(), true) .AddField("React to participate", "good luck", true) .Build().SendToChannel(e.Channel); await(msg as IUserMessage).AddReactionAsync(emoji); int updateTask = -1; int task = taskScheduler.AddTask(e.Author.Id, async(desc) => { msg = await e.Channel.GetMessageAsync(msg.Id); if (msg != null) { await(msg as IUserMessage).RemoveReactionAsync(emoji, await e.Guild.GetCurrentUserAsync()); List <IUser> reactions = new List <IUser>(); int reactionsGained = 0; do { reactions.AddRange(await(msg as IUserMessage).GetReactionUsersAsync(emoji, 100, reactions.LastOrDefault()?.Id ?? null)); reactionsGained += 100; } while (reactions.Count == reactionsGained); // Select random winners for (int i = 0; i < amount; i++) { if (reactions.Count == 0) { break; } int index = MikiRandom.Next(reactions.Count); winners.Add(reactions[index]); if (isUnique) { reactions.RemoveAt(index); } } if (updateTask != -1) { taskScheduler.CancelReminder(e.Author.Id, updateTask); } string winnerText = string.Join("\n", winners.Select(x => x.Username + "#" + x.Discriminator).ToArray()); if (string.IsNullOrEmpty(winnerText)) { winnerText = "nobody!"; } await(msg as IUserMessage).ModifyAsync(x => { x.Embed = CreateGiveawayEmbed(e, giveAwayText) .AddField("Winners", winnerText) .Build(); }); } }, "description var", timeLeft); }
public async Task PruneAsync(EventContext e, int _amount = 100, ulong _target = 0) { IDiscordGuildUser invoker = await e.Guild.GetSelfAsync(); if (!(await(e.Channel as IDiscordGuildChannel).GetPermissionsAsync(invoker)).HasFlag(GuildPermission.ManageMessages)) { e.Channel.QueueMessageAsync(e.Locale.GetString("miki_module_admin_prune_error_no_access")); return; } int amount = _amount; string[] argsSplit = e.Arguments.ToString().Split(' '); ulong target = e.message.MentionedUserIds.Count > 0 ? (await e.Guild.GetMemberAsync(e.message.MentionedUserIds.First())).Id : _target; if (!string.IsNullOrEmpty(argsSplit[0])) { if (int.TryParse(argsSplit[0], out amount)) { if (amount < 0) { Utils.ErrorEmbed(e, e.Locale.GetString("miki_module_admin_prune_error_negative")) .ToEmbed().QueueToChannel(e.Channel); return; } if (amount > 100) { Utils.ErrorEmbed(e, e.Locale.GetString("miki_module_admin_prune_error_max")) .ToEmbed().QueueToChannel(e.Channel); return; } } else { Utils.ErrorEmbed(e, e.Locale.GetString("miki_module_admin_prune_error_parse")) .ToEmbed().QueueToChannel(e.Channel); return; } } await e.message.DeleteAsync(); // Delete the calling message before we get the message history. IEnumerable <IDiscordMessage> messages = await e.Channel.GetMessagesAsync(amount); List <IDiscordMessage> deleteMessages = new List <IDiscordMessage>(); amount = messages.Count(); if (amount < 1) { string prefix = await e.commandHandler.GetDefaultPrefixValueAsync(e.Guild.Id); await e.message.DeleteAsync(); e.ErrorEmbed(e.Locale.GetString("miki_module_admin_prune_no_messages", prefix)) .ToEmbed().QueueToChannel(e.Channel); return; } for (int i = 0; i < amount; i++) { if (target != 0 && messages.ElementAt(i)?.Author.Id != target) { continue; } if (messages.ElementAt(i).Timestamp.AddDays(14) > DateTime.Now) { deleteMessages.Add(messages.ElementAt(i)); } } if (deleteMessages.Count > 0) { await e.Channel.DeleteMessagesAsync(deleteMessages.ToArray()); } string[] titles = new string[] { "POW!", "BANG!", "BAM!", "KAPOW!", "BOOM!", "ZIP!", "ZING!", "SWOOSH!", "POP!" }; new EmbedBuilder { Title = titles[MikiRandom.Next(titles.Length - 1)], Description = e.Locale.GetString("miki_module_admin_prune_success", deleteMessages.Count), Color = new Color(1, 1, 0.5f) }.ToEmbed().QueueToChannel(e.Channel) .ThenWait(5000) .ThenDelete(); }
public void LoadAchievements() { AchievementDataContainer AchievementAchievements = new AchievementDataContainer(x => { x.Name = "achievements"; x.Achievements = new List <IAchievement>() { new AchievementAchievement() { Name = "Underachiever", Icon = "🖍", CheckAchievement = async(p) => { await Task.Yield(); return(p.count >= 3); }, Points = 5, }, new AchievementAchievement() { Name = "Achiever", Icon = "✏️", CheckAchievement = async(p) => { await Task.Yield(); return(p.count >= 5); }, Points = 10, }, new AchievementAchievement() { Name = "Overachiever", Icon = "🖋️", CheckAchievement = async(p) => { return(p.count >= 12); }, Points = 15, }, new AchievementAchievement() { Name = "Completionist", Icon = "🖊️", CheckAchievement = async(p) => { return(p.count >= 25); }, Points = 30, } }; }); AchievementDataContainer LotteryAchievements = new AchievementDataContainer(x => { x.Name = "lottery"; x.Achievements = new List <IAchievement>() { // Win a lottery > 100k new ManualAchievement() { Name = "Celebrator", Icon = "🍺", Points = 5, }, // Win a lottery > 10m new ManualAchievement() { Name = "Absolute Madman", Icon = "🍸", Points = 10, }, // Win a lottery > 250m new ManualAchievement() { Name = "Pop da champagne", Icon = "🍾", Points = 15 } }; }); AchievementDataContainer InfoAchievement = new AchievementDataContainer(x => { x.Name = "info"; x.Achievements = new List <IAchievement>() { new CommandAchievement() { Name = "Informed", Icon = "📚", CheckCommand = async(p) => { await Task.Yield(); return(p.command.Name.ToLower() == "info"); }, Points = 5 } }; }); AchievementDataContainer LonelyAchievement = new AchievementDataContainer(x => { x.Name = "fa"; x.Achievements = new List <IAchievement>() { new CommandAchievement() { Name = "Lonely", Icon = "😭", CheckCommand = async(p) => { await Task.Yield(); return(p.command.Name.ToLower() == "marry" && p.message.MentionedUserIds.FirstOrDefault() == p.message.Author.Id); }, Points = 5, } }; }); AchievementDataContainer ChefAchievement = new AchievementDataContainer(x => { x.Name = "creator"; x.Achievements = new List <IAchievement>() { new CommandAchievement() { Name = "Chef", Icon = "📝", CheckCommand = async(p) => { await Task.Yield(); return(p.command.Name.ToLower() == "createpasta"); }, Points = 5, } }; }); AchievementDataContainer NoPermissionAchievement = new AchievementDataContainer(x => { x.Name = "noperms"; x.Achievements = new List <IAchievement>() { new CommandAchievement() { Name = "NO! Don't touch that!", Icon = "😱", CheckCommand = async(p) => { return(await MikiApp.Instance.GetService <EventSystem>().GetCommandHandler <SimpleCommandHandler>().GetUserAccessibility(p.message, p.discordChannel as IDiscordGuildChannel) < p.command.Accessibility); }, Points = 5 } }; }); AchievementDataContainer LevelAchievement = new AchievementDataContainer(x => { x.Name = "levelachievements"; x.Achievements = new List <IAchievement>() { new LevelAchievement() { Name = "Novice", Icon = "🎟", CheckLevel = async(p) => p.level >= 3, Points = 5, }, new LevelAchievement() { Name = "Intermediate", Icon = "🎫", CheckLevel = async(p) => p.level >= 5, Points = 10, }, new LevelAchievement() { Name = "Experienced", Icon = "🏵", CheckLevel = async(p) => p.level >= 10, Points = 15, }, new LevelAchievement() { Name = "Expert", Icon = "🎗", CheckLevel = async(p) => p.level >= 20, Points = 20, }, new LevelAchievement() { Name = "Sage", Icon = "🎖", CheckLevel = async(p) => p.level >= 30, Points = 25, }, new LevelAchievement() { Name = "Master", Icon = "🏅", CheckLevel = async(p) => p.level >= 50, Points = 30, }, new LevelAchievement() { Name = "Legend", Icon = "💮", CheckLevel = async(p) => p.level >= 100, Points = 35, }, new LevelAchievement() { Name = "Epic", Icon = "🌸", CheckLevel = async(p) => p.level >= 150, Points = 40, } }; }); AchievementDataContainer FrogAchievement = new AchievementDataContainer(x => { x.Name = "frog"; x.Achievements = new List <IAchievement>() { new CommandAchievement() { Name = "Oh shit! Waddup", Icon = "🐸", CheckCommand = async(p) => { return(p.command.Name == "pasta" && p.message.Content.Contains("dat boi")); }, Points = 5 } }; }); AchievementDataContainer LennyAchievement = new AchievementDataContainer(x => { x.Name = "lenny"; x.Achievements = new List <IAchievement>() { new CommandAchievement() { Name = "Lenny", Icon = "😏", CheckCommand = async(p) => { return(p.command.Name == "pasta" && p.message.Content.Contains("( ͡° ͜ʖ ͡°)")); }, Points = 5 } }; }); AchievementDataContainer PoiAchievement = new AchievementDataContainer(x => { x.Name = "poi"; x.Achievements = new List <IAchievement> { new CommandAchievement() { Name = "Shipgirl", Icon = "⛵", CheckCommand = async(p) => { return(p.command.Name == "pasta" && p.message.Content.Split(' ').Contains("poi")); }, Points = 5, } }; }); AchievementDataContainer LuckyAchievement = new AchievementDataContainer(x => { x.Name = "goodluck"; x.Achievements = new List <IAchievement>() { new CommandAchievement() { Name = "Lucky", Icon = "🍀", CheckCommand = async(p) => { return(MikiRandom.Next(0, 10000000) == 5033943); }, Points = 25 } }; }); AchievementDataContainer MekosAchievement = new AchievementDataContainer(x => { x.Name = "meko"; x.Achievements = new List <IAchievement>() { new TransactionAchievement() { Name = "Loaded", Icon = "💵", CheckTransaction = async(p) => { return(p.receiver.Currency > 10000); }, Points = 5 }, new TransactionAchievement() { Name = "Rich", Icon = "💸", CheckTransaction = async(p) => { return(p.receiver.Currency > 50000); }, Points = 10 }, new TransactionAchievement() { Name = "Minted", Icon = "💲", CheckTransaction = async(p) => { return(p.receiver.Currency > 125000); }, Points = 15 }, new TransactionAchievement() { Name = "Millionaire", Icon = "🤑", CheckTransaction = async(p) => { return(p.receiver.Currency > 1000000); }, Points = 20 }, new TransactionAchievement() { Name = "Billionaire", Icon = "🏦", CheckTransaction = async(p) => { return(p.receiver.Currency > 1000000000); }, Points = 25 } }; }); AchievementDataContainer DiscordBotsOrgAchievement = new AchievementDataContainer(x => { x.Name = "voter"; x.Achievements = new List <IAchievement>() { // first vote new ManualAchievement() { Name = "Helper", Icon = "✉", Points = 5, }, // 10 votes new ManualAchievement() { Name = "Voter", Icon = "🗳", Points = 10, }, // 50 votes new ManualAchievement() { Name = "Elector", Icon = "🗃", Points = 15, } }; }); AchievementDataContainer SlotsAchievement = new AchievementDataContainer(x => { x.Name = "slots"; x.Achievements = new List <IAchievement> { new ManualAchievement() { Name = "Jackpot", Icon = "🎰", Points = 15 } }; }); #region Achievement Achievements AchievementManager.Instance.OnAchievementUnlocked += async(pa) => { await AchievementAchievements.CheckAsync(pa); }; #endregion Achievement Achievements #region Command Achievements AchievementManager.Instance.OnCommandUsed += InfoAchievement.CheckAsync; AchievementManager.Instance.OnCommandUsed += LonelyAchievement.CheckAsync; AchievementManager.Instance.OnCommandUsed += ChefAchievement.CheckAsync; AchievementManager.Instance.OnCommandUsed += NoPermissionAchievement.CheckAsync; #endregion Command Achievements #region Level Achievements AchievementManager.Instance.OnLevelGained += LevelAchievement.CheckAsync; #endregion Level Achievements AchievementManager.Instance.OnCommandUsed += LennyAchievement.CheckAsync; AchievementManager.Instance.OnCommandUsed += PoiAchievement.CheckAsync; AchievementManager.Instance.OnCommandUsed += LuckyAchievement.CheckAsync; AchievementManager.Instance.OnCommandUsed += FrogAchievement.CheckAsync; #region Misc Achievements new AchievementDataContainer(x => { x.Name = "badluck"; x.Achievements = new List <IAchievement>() { new ManualAchievement() { Name = "Unlucky", Icon = "🎲", Points = 5 } }; }); #endregion Misc Achievements #region User Update Achievements (don't disable these) new AchievementDataContainer(x => { x.Name = "contributor"; x.Achievements = new List <IAchievement>() { new UserUpdateAchievement() { Name = "Contributor", Icon = "⭐", CheckUserUpdate = async(p) => { return(false); } } }; }); new AchievementDataContainer(x => { x.Name = "developer"; x.Achievements = new List <IAchievement>() { new UserUpdateAchievement() { Name = "Developer", Icon = "🌟", CheckUserUpdate = async(p) => { return(false); } } }; }); new AchievementDataContainer(x => { x.Name = "glitch"; x.Achievements = new List <IAchievement>() { new UserUpdateAchievement() { Name = "Glitch", Icon = "👾", CheckUserUpdate = async(p) => { return(false); } } }; }); new AchievementDataContainer(x => { x.Name = "donator"; x.Achievements = new List <IAchievement>() { new ManualAchievement() { Name = "Donator", Icon = "💖", Points = 0, }, new ManualAchievement() { Name = "Supporter", Icon = "💘", Points = 0, }, new ManualAchievement() { Name = "Sponsor", Icon = "💟", Points = 0, }, }; }); #endregion User Update Achievements (don't disable these) #region Transaction Achievements AchievementManager.Instance.OnTransaction += MekosAchievement.CheckAsync; #endregion Transaction Achievements }
public async Task PickAsync(EventContext e) { if (string.IsNullOrWhiteSpace(e.Arguments.ToString())) { e.Channel.QueueMessageAsync(e.Locale.GetString(LocaleTags.ErrorPickNoArgs)); return; } string[] choices = e.Arguments.ToString().Split(','); e.Channel.QueueMessageAsync(e.Locale.GetString(LocaleTags.PickMessage, new object[] { e.Author.Username, choices[MikiRandom.Next(0, choices.Length)] })); }
public async Task GuildWeekly(EventContext e) { using (MikiContext database = new MikiContext()) { LocalExperience thisUser = await database.LocalExperience.FindAsync(e.Guild.Id.ToDbLong(), e.Author.Id.ToDbLong()); GuildUser thisGuild = await database.GuildUsers.FindAsync(e.Guild.Id.ToDbLong()); Timer timer = await database.Timers.FindAsync(e.Guild.Id.ToDbLong(), e.Author.Id.ToDbLong()); if (thisUser == null) { return; } if (thisGuild == null) { return; } if (thisUser.Experience >= thisGuild.MinimalExperienceToGetRewards) { if (timer == null) { timer = (await database.Timers.AddAsync(new Timer() { GuildId = e.Guild.Id.ToDbLong(), UserId = e.Author.Id.ToDbLong(), Value = DateTime.Now.AddDays(-30) })).Entity; await database.SaveChangesAsync(); } if (timer.Value.AddDays(7) <= DateTime.Now) { GuildUser rival = await thisGuild.GetRivalOrDefaultAsync(database); if (rival.Experience > thisGuild.Experience) { new EmbedBuilder() .SetTitle(e.Locale.GetString("miki_terms_weekly")) .SetDescription(e.Locale.GetString("guildweekly_error_low_level")) .ToEmbed().QueueToChannel(e.Channel); return; } int mekosGained = (int)Math.Round((((MikiRandom.NextDouble() + thisGuild.GuildHouseMultiplier) * 0.5) * 10) * thisGuild.CalculateLevel(thisGuild.Experience)); User user = await database.Users.FindAsync(e.Author.Id.ToDbLong()); if (user == null) { // TODO: Add response return; } await user.AddCurrencyAsync(mekosGained, e.Channel); new EmbedBuilder() .SetTitle(e.Locale.GetString("miki_terms_weekly")) .AddInlineField("Mekos", mekosGained.ToFormattedString()) .ToEmbed().QueueToChannel(e.Channel); timer.Value = DateTime.Now; await database.SaveChangesAsync(); } else { new EmbedBuilder() .SetTitle(e.Locale.GetString("miki_terms_weekly")) .SetDescription(e.Locale.GetString("guildweekly_error_timer_running", (timer.Value.AddDays(7) - DateTime.Now).ToTimeString(e.Locale))) .ToEmbed().QueueToChannel(e.Channel); } } else { new EmbedBuilder() .SetTitle(e.Locale.GetString("miki_terms_weekly")) .SetDescription(e.Locale.GetString("miki_guildweekly_insufficient_exp", thisGuild.MinimalExperienceToGetRewards.ToFormattedString())) .ToEmbed().QueueToChannel(e.Channel); } } }
public async Task PunAsync(EventContext e) { e.Channel.QueueMessageAsync(e.Locale.GetString(puns[MikiRandom.Next(0, puns.Length)])); }
public async Task HandleLotteryAsync(IContext context, string _) { var lotteryService = context.GetService <ILotteryService>(); var entries = await lotteryService.GetEntriesAsync(); var entryCount = entries?.Sum(x => x.TicketCount) ?? 0; if (entryCount == 0) { Log.Warning("No entries found."); return; } var winnerIndex = MikiRandom.Next(entryCount); LotteryEntry winner = null; foreach (var entry in entries) { if (entry.TicketCount > winnerIndex) { winner = entry; break; } winnerIndex -= entry.TicketCount; } if (winner == null) { Log.Warning("Winner was null"); return; } var winningAmount = await lotteryService.GetTotalPrizeAsync(); var transactionService = context.GetService <ITransactionService>(); await transactionService.CreateTransactionAsync( new TransactionRequest.Builder() .WithSender(AppProps.Currency.BankId) .WithReceiver(winner.UserId) .WithAmount(winningAmount) .Build()); try { var discordClient = context.GetService <IDiscordClient>(); var channel = await discordClient.CreateDMAsync((ulong)winner.UserId); await channel.SendMessageAsync( string.Empty, embed : new EmbedBuilder() .SetTitle("🏅 Winner") .SetDescription($"You won the jackpot of {winningAmount} mekos!") .SetColor(103, 172, 237) .ToEmbed()); } catch (DiscordRestException) { Log.Warning("Message failed to send"); // Couldn't send message to winner. } var cache = context.GetService <ICacheClient>(); await cache.RemoveAsync(LotteryObjectsKey); await OnLotteryWinAchievementsAsync(context, winner.UserId, winningAmount); }
public async Task BiteAsync(EventContext e) => await QueueAction(e, "bites", biteImages[MikiRandom.Next(biteImages.Length)]);
public async Task PruneAsync(EventContext e, int _amount = 100, ulong _target = 0) { IDiscordGuildUser invoker = await e.Guild.GetSelfAsync(); if (!(await(e.Channel as IDiscordGuildChannel).GetPermissionsAsync(invoker)).HasFlag(GuildPermission.ManageMessages)) { e.Channel.QueueMessageAsync(e.Locale.GetString("miki_module_admin_prune_error_no_access")); return; } int amount = _amount; string[] argsSplit = e.Arguments.ToString().Split(' '); ulong target = e.message.MentionedUserIds.Count > 0 ? (await e.Guild.GetMemberAsync(e.message.MentionedUserIds.First())).Id : _target; if (!string.IsNullOrEmpty(argsSplit[0])) { if (int.TryParse(argsSplit[0], out amount)) { if (amount < 0) { Utils.ErrorEmbed(e, e.Locale.GetString("miki_module_admin_prune_error_negative")) .ToEmbed().QueueToChannel(e.Channel); return; } if (amount > 100) { Utils.ErrorEmbed(e, e.Locale.GetString("miki_module_admin_prune_error_max")) .ToEmbed().QueueToChannel(e.Channel); return; } } else { Utils.ErrorEmbed(e, e.Locale.GetString("miki_module_admin_prune_error_parse")) .ToEmbed().QueueToChannel(e.Channel); return; } } await e.message.DeleteAsync(); // Delete the calling message before we get the message history. //IEnumerable<IDiscordMessage> messages = await e.Channel.GetMessagesAsync(amount).FlattenAsync(); List <IDiscordMessage> deleteMessages = new List <IDiscordMessage>(); //amount = messages.Count(); // Checks if the amount of messages to delete is more than the amount of messages availiable. //if (amount < 1) //{ // string prefix = await e.commandHandler.GetPrefixAsync(e.Guild.Id); // await e.message.DeleteAsync(); // e.ErrorEmbed(e.GetResource("miki_module_admin_prune_no_messages", prefix)) // .ToEmbed().QueueToChannel(e.Channel); // return; //} //for (int i = 0; i < amount; i++) //{ // if (target != 0 && messages.ElementAt(i)?.Author.Id != target) // continue; // if (messages.ElementAt(i).Timestamp.AddDays(14) > DateTime.Now) // { // deleteMessages.Add(messages.ElementAt(i)); // } //} //if (deleteMessages.Count > 0) //{ // await e.Channel.DeleteMessagesAsync(deleteMessages); //} Task.WaitAll(); string[] titles = new string[] { "POW!", "BANG!", "BAM!", "KAPOW!", "BOOM!", "ZIP!", "ZING!", "SWOOSH!", "POP!" }; EmbedBuilder embed = Utils.Embed; embed.Title = titles[MikiRandom.Next(titles.Length - 1)]; embed.Description = e.Locale.GetString("miki_module_admin_prune_success", deleteMessages.Count); embed.Color = new Color(1, 1, 0.5f); IDiscordMessage _dMessage = await embed.ToEmbed().SendToChannel(e.Channel); Task.Run(async() => { await Task.Delay(5000); await _dMessage.DeleteAsync(); }); }
public async Task CuddleAsync(EventContext e) => await QueueAction(e, "cuddles", cuddleImages[MikiRandom.Next(cuddleImages.Length)]);
public void LoadAchievements() { AchievementDataContainer AchievementAchievements = new AchievementDataContainer(x => { x.Name = "achievements"; x.Achievements = new List <BaseAchievement>() { new AchievementAchievement() { Name = "Underachiever", Icon = "🖍", CheckAchievement = async(p) => { await Task.Yield(); return(p.count >= 3); }, }, new AchievementAchievement() { Name = "Achiever", Icon = "✏️", CheckAchievement = async(p) => { await Task.Yield(); return(p.count >= 5); }, }, new AchievementAchievement() { Name = "Overachiever", Icon = "🖋️", CheckAchievement = async(p) => { return(p.count >= 12); }, }, new AchievementAchievement() { Name = "Completionist", Icon = "🖊️", CheckAchievement = async(p) => { return(p.count >= 12); }, } }; }); AchievementDataContainer InfoAchievement = new AchievementDataContainer(x => { x.Name = "info"; x.Achievements = new List <BaseAchievement>() { new CommandAchievement() { Name = "Informed", Icon = "📚", CheckCommand = async(p) => { await Task.Yield(); return(p.command.Name.ToLower() == "info"); }, Points = 5 } }; }); AchievementDataContainer LonelyAchievement = new AchievementDataContainer(x => { x.Name = "fa"; x.Achievements = new List <BaseAchievement>() { new CommandAchievement() { Name = "Lonely", Icon = "😭", CheckCommand = async(p) => { await Task.Yield(); return(p.command.Name.ToLower() == "marry" && p.message.MentionedUserIds.First() == p.message.Author.Id); }, Points = 5, } }; }); AchievementDataContainer ChefAchievement = new AchievementDataContainer(x => { x.Name = "creator"; x.Achievements = new List <BaseAchievement>() { new CommandAchievement() { Name = "Chef", Icon = "📝", CheckCommand = async(p) => { await Task.Yield(); return(p.command.Name.ToLower() == "createpasta"); }, Points = 5, } }; }); AchievementDataContainer NoPermissionAchievement = new AchievementDataContainer(x => { x.Name = "noperms"; x.Achievements = new List <BaseAchievement>() { new CommandAchievement() { Name = "NO! Don't touch that!", Icon = "😱", CheckCommand = async(p) => { await Task.Yield(); return(EventSystem.Instance.CommandHandler.GetUserAccessibility(p.message) < p.command.Accessibility); }, Points = 0 } }; }); AchievementDataContainer LevelAchievement = new AchievementDataContainer(x => { x.Name = "levelachievements"; x.Achievements = new List <BaseAchievement>() { new LevelAchievement() { Name = "Novice", Icon = "🎟", CheckLevel = async(p) => p.level >= 3, Points = 5, }, new LevelAchievement() { Name = "Intermediate", Icon = "🎫", CheckLevel = async(p) => p.level >= 5, Points = 5, }, new LevelAchievement() { Name = "Experienced", Icon = "🏵", CheckLevel = async(p) => p.level >= 10, Points = 5, }, new LevelAchievement() { Name = "Expert", Icon = "🎗", CheckLevel = async(p) => p.level >= 20, Points = 5, }, new LevelAchievement() { Name = "Sage", Icon = "🎖", CheckLevel = async(p) => p.level >= 30, Points = 5, }, new LevelAchievement() { Name = "Master", Icon = "🏅", CheckLevel = async(p) => p.level >= 50, Points = 5, }, new LevelAchievement() { Name = "Legend", Icon = "💮", CheckLevel = async(p) => p.level >= 100, Points = 5, }, new LevelAchievement() { Name = "Epic", Icon = "🌸", CheckLevel = async(p) => p.level >= 150, Points = 5, } }; }); AchievementDataContainer FrogAchievement = new AchievementDataContainer(x => { x.Name = "frog"; x.Achievements = new List <BaseAchievement>() { new MessageAchievement() { Name = "Oh shit! Waddup", Icon = "🐸", CheckMessage = async(p) => p.message.Content.Contains("dat boi"), Points = 5 } }; }); AchievementDataContainer LennyAchievement = new AchievementDataContainer(x => { x.Name = "lenny"; x.Achievements = new List <BaseAchievement>() { new MessageAchievement() { Name = "Lenny", Icon = "😏", CheckMessage = async(p) => { return(p.message.Content.Contains("( ͡° ͜ʖ ͡°)")); }, Points = 5 } }; }); AchievementDataContainer PoiAchievement = new AchievementDataContainer(x => { x.Name = "poi"; x.Achievements = new List <BaseAchievement> { new MessageAchievement() { Name = "Shipgirl", Icon = "⛵", CheckMessage = async(p) => { return(p.message.Content.Split(' ').Contains("poi")); }, Points = 5, } }; }); AchievementDataContainer LuckyAchievement = new AchievementDataContainer(x => { x.Name = "goodluck"; x.Achievements = new List <BaseAchievement>() { new MessageAchievement() { Name = "Lucky", Icon = "🍀", CheckMessage = async(p) => { return(MikiRandom.Next(0, 10000000) == 5033943); }, Points = 25 } }; }); AchievementDataContainer MekosAchievement = new AchievementDataContainer(x => { x.Name = "meko"; x.Achievements = new List <BaseAchievement>() { new TransactionAchievement() { Name = "Loaded", Icon = "💵", CheckTransaction = async(p) => { return(p.receiver.Currency > 10000); }, Points = 5 }, new TransactionAchievement() { Name = "Rich", Icon = "💸", CheckTransaction = async(p) => { return(p.receiver.Currency > 50000); }, Points = 5 }, new TransactionAchievement() { Name = "Minted", Icon = "💲", CheckTransaction = async(p) => { return(p.receiver.Currency > 125000); }, Points = 10 }, new TransactionAchievement() { Name = "Millionaire", Icon = "🤑", CheckTransaction = async(p) => { return(p.receiver.Currency > 1000000); }, Points = 25 } }; }); AchievementDataContainer DiscordBotsOrgAchievement = new AchievementDataContainer() { Name = "Voter", Achievements = new List <BaseAchievement>() { new BaseAchievement() { Name = "Helper", Icon = "✉", Points = 5, }, new BaseAchievement() { Name = "Voter", Icon = "🗳", Points = 25, }, new BaseAchievement() { Name = "Elector", Icon = "🗃", Points = 50, } } }; #region Achievement Achievements AchievementManager.Instance.OnAchievementUnlocked += async(pa) => { await AchievementAchievements.CheckAsync(pa); }; #endregion Achievement Achievements #region Command Achievements AchievementManager.Instance.OnCommandUsed += InfoAchievement.CheckAsync; AchievementManager.Instance.OnCommandUsed += LonelyAchievement.CheckAsync; AchievementManager.Instance.OnCommandUsed += ChefAchievement.CheckAsync; AchievementManager.Instance.OnCommandUsed += NoPermissionAchievement.CheckAsync; #endregion Command Achievements #region Level Achievements AchievementManager.Instance.OnLevelGained += LevelAchievement.CheckAsync; #endregion Level Achievements #region Misc Achievements new AchievementDataContainer(x => { x.Name = "badluck"; x.Achievements = new List <BaseAchievement>() { new BaseAchievement() { Name = "Unlucky", Icon = "🎲", Points = 5 } }; }); #endregion Misc Achievements #region User Update Achievements (don't disable these) new AchievementDataContainer(x => { x.Name = "contributor"; x.Achievements = new List <BaseAchievement>() { new UserUpdateAchievement() { Name = "Contributor", Icon = "⭐", CheckUserUpdate = async(p) => { if (p.userNew.Guild.Id == 160067691783127041) { IDiscordRole role = p.userNew.Guild.Roles.Find(r => { return(r.Name == "Contributors"); }); if (p.userNew.RoleIds.Contains(role.Id)) { return(true); } } return(false); } } }; }); new AchievementDataContainer(x => { x.Name = "developer"; x.Achievements = new List <BaseAchievement>() { new UserUpdateAchievement() { Name = "Developer", Icon = "🌟", CheckUserUpdate = async(p) => { if (p.userNew.Guild.Id == 160067691783127041) { IDiscordRole role = p.userNew.Guild.Roles.Find(r => { return(r.Name == "Developer"); }); if (p.userNew.RoleIds.Contains(role.Id)) { return(true); } } return(false); } } }; }); new AchievementDataContainer(x => { x.Name = "glitch"; x.Achievements = new List <BaseAchievement>() { new UserUpdateAchievement() { Name = "Glitch", Icon = "👾", CheckUserUpdate = async(p) => { return(false); } } }; }); new AchievementDataContainer(x => { x.Name = "donator"; x.Achievements = new List <BaseAchievement>() { new UserUpdateAchievement() { Name = "Donator", Icon = "💖", CheckUserUpdate = async(p) => { return(false); }, Points = 0, }, new UserUpdateAchievement() { Name = "Supporter", Icon = "💘", CheckUserUpdate = async(p) => { return(false); }, Points = 0, }, new UserUpdateAchievement() { Name = "Sponsor", Icon = "💟", CheckUserUpdate = async(p) => { return(false); }, Points = 0, }, }; }); #endregion User Update Achievements (don't disable these) #region Transaction Achievements AchievementManager.Instance.OnTransaction += MekosAchievement.CheckAsync; #endregion Transaction Achievements }
public async Task HighFiveAsync(EventContext e) => await QueueAction(e, "high-fives", highFiveImages[MikiRandom.Next(highFiveImages.Length)]);
public async Task EightBallAsync(EventContext e) { string output = e.Locale.GetString("miki_module_fun_8ball_result", e.Author.Username, e.Locale.GetString(reactions[MikiRandom.Next(0, reactions.Length)])); e.Channel.QueueMessageAsync(output); }
public async Task PokeAsync(EventContext e) => await QueueAction(e, "pokes", pokeImages[MikiRandom.Next(pokeImages.Length)]);
public async Task ComplimentAsync(EventContext e) { string[] I_LIKE = { "I like ", "I love ", "I admire ", "I really enjoy ", "For some reason I like " }; string[] BODY_PART = { "that silly fringe of yours", "the lower part of your lips", "the smallest toe on your left foot", "the smallest toe on your right foot", "the second eyelash from your left eye", "the lower part of your chin", "your creepy finger on your left hand", "your cute smile", "those dazzling eyes of yours", "your creepy finger on your right hand", "the special angles your elbows make", "the dimples on your cheeks", "your smooth hair" }; string[] SUFFIX = { " a lot.", " a bit.", " quite a bit.", " a lot, is that weird?", }; e.Channel.QueueMessageAsync(I_LIKE[MikiRandom.Next(0, I_LIKE.Length)] + BODY_PART[MikiRandom.Next(0, BODY_PART.Length)] + SUFFIX[MikiRandom.Next(0, SUFFIX.Length)]); }
public async Task KissAsync(EventContext e) => await QueueAction(e, "kisses", kissImages[MikiRandom.Next(kissImages.Length)]);
public async Task CageAsync(EventContext e) { e.Channel.QueueMessageAsync("http://www.placecage.com/c/" + MikiRandom.Next(100, 1500) + "/" + MikiRandom.Next(100, 1500)); }
public async Task PetAsync(EventContext e) => await QueueAction(e, "pats", patImages[MikiRandom.Next(patImages.Length)]);
public async Task CheckAsync(IDiscordMessage e) { if (e.Author.IsBot) { return; } if (!lastTimeExpGranted.ContainsKey(e.Author.Id)) { lastTimeExpGranted.Add(e.Author.Id, DateTime.MinValue); } if (lastTimeExpGranted[e.Author.Id].AddMinutes(1) < DateTime.Now) { int addedExperience = MikiRandom.Next(2, 5); await MeruUtils.TryAsync(async() => { User a; LocalExperience experience; long userId = e.Author.Id.ToDbLong(); int currentGlobalLevel = 0; int currentLocalLevel = 0; using (var context = new MikiContext()) { a = await context.Users.FindAsync(e.Author.Id.ToDbLong()); if (a == null) { a = await User.CreateAsync(e); } experience = await context.Experience.FindAsync(e.Guild.Id.ToDbLong(), userId); if (experience == null) { experience = await LocalExperience.CreateAsync(context, e.Guild.Id.ToDbLong(), e.Author.Id.ToDbLong()); } if (experience.LastExperienceTime == null) { experience.LastExperienceTime = DateTime.Now; } GuildUser guildUser = await context.GuildUsers.FindAsync(e.Guild.Id.ToDbLong()); if (guildUser == null) { long guildId = e.Guild.Id.ToDbLong(); int?userCount = Bot.instance.Client.GetGuild(e.Guild.Id).Users.Count; int?value = await context.Experience .Where(x => x.ServerId == guildId) .SumAsync(x => x.Experience); guildUser = new GuildUser(); guildUser.Name = e.Guild.Name; guildUser.Id = guildId; guildUser.Experience = value ?? 0; guildUser.UserCount = userCount ?? 0; guildUser.LastRivalRenewed = Utils.MinDbValue; guildUser.MinimalExperienceToGetRewards = 100; guildUser = context.GuildUsers.Add(guildUser); } currentLocalLevel = User.CalculateLevel(experience.Experience); currentGlobalLevel = User.CalculateLevel(a.Total_Experience); experience.Experience += addedExperience; a.Total_Experience += addedExperience; guildUser.Experience += addedExperience; await context.SaveChangesAsync(); } if (currentLocalLevel != User.CalculateLevel(experience.Experience)) { await LevelUpLocalAsync(e, a, currentLocalLevel + 1); } if (currentGlobalLevel != User.CalculateLevel(a.Total_Experience)) { await LevelUpGlobalAsync(e, a, currentGlobalLevel + 1); } lastTimeExpGranted[e.Author.Id] = DateTime.Now; }); } }