public async Task Roll(int number, int times) { try { var mess = ""; if (times > 100) { await SendMessAsync( "Boole! We are not going to roll that many times!"); return; } if (number > 999999999) { await SendMessAsync( "Boole! This numbers is way too big for us :c"); return; } for (var i = 0; i < times; i++) { var randomIndexRoll = _secureRandom.Random(1, number); mess += $"It's a {randomIndexRoll}!\n"; } var embed = new EmbedBuilder(); embed.WithFooter("lil octo notebook"); embed.WithTitle($"Roll {times} times:"); embed.WithDescription($"{mess}"); await SendMessAsync(embed); } catch { // await ReplyAsync( // "boo... An error just appear >_< \nTry to use this command properly: **roll [times] [max_value_of_roll]**\n" + // "Alias: Роллл, Ролл"); } }
public async Task RandomStats() { ulong times = 10000; var statsList = new List <StatsStruct> { new StatsStruct(1, 0), new StatsStruct(2, 0), new StatsStruct(3, 0), new StatsStruct(4, 0), new StatsStruct(5, 0), new StatsStruct(6, 0), new StatsStruct(7, 0), new StatsStruct(8, 0), new StatsStruct(9, 0), new StatsStruct(10, 0) }; for (ulong i = 0; i < times; i++) { var ran = _secureRandom.Random(1, 10); statsList.Find(x => x.Number == ran).Count += 1; } var mess = $"{statsList[0].Number} = {statsList[0].Count}\n" + $"{statsList[1].Number} = {statsList[1].Count}\n" + $"{statsList[2].Number} = {statsList[2].Count}\n" + $"{statsList[3].Number} = {statsList[3].Count}\n" + $"{statsList[4].Number} = {statsList[4].Count}\n" + $"{statsList[5].Number} = {statsList[5].Count}\n" + $"{statsList[6].Number} = {statsList[6].Count}\n" + $"{statsList[7].Number} = {statsList[7].Count}\n" + $"{statsList[8].Number} = {statsList[8].Count}\n" + $"{statsList[9].Number} = {statsList[9].Count}\n"; var embed = new EmbedBuilder(); embed.WithTitle($"Roll {times} times:"); embed.WithDescription($"{mess}"); await SendMessAsync(embed); }
public async Task AllCustomRoles() { var guild = _serverAccounts.GetServerAccount(Context.Guild); var rolesList = guild.Roles.ToList(); var embed = new EmbedBuilder(); embed.WithColor(_secureRandom.Random(0, 255), _secureRandom.Random(0, 255), _secureRandom.Random(0, 255)); embed.WithAuthor(Context.User); var text = ""; foreach (var t in rolesList) { text += $"{t.Key} - {t.Value}\n"; } embed.AddField("All Custom Commands To Get Roles:", $"Format: **KeyName - RoleName**\n" + $"By Saying `{guild.Prefix}KeyName` you will get **RoleName** role.\n" + $"**______**\n\n" + $"{text}\n"); embed.WithFooter("Say **dcr KeyName** to delete the Command from the list"); await SendMessAsync(embed); }
public async void SetBotAva(object sender, ElapsedEventArgs e) { try { var octoIndex = OctoPicPull.OctoPics.Length - 1; var randomIndex = _secureRandom.Random(0, octoIndex); var octoToPost = OctoPicPull.OctoPics[randomIndex]; var webClient = new WebClient(); var imageBytes = webClient.DownloadData(octoToPost); var stream = new MemoryStream(imageBytes); var image = new Image(stream); await Global.Client.CurrentUser.ModifyAsync(k => k.Avatar = image); } catch (Exception ex) { ConsoleLogger.Log($"[Exception] (Change avatar) - {ex.Message}", ConsoleColor.DarkBlue); } }
public async Task AddReminder([Remainder] string args) { try { string[] splittedArgs = { }; if (args.ToLower().Contains(" in ")) { splittedArgs = args.ToLower().Split(new[] { " in " }, StringSplitOptions.None); } else if (args.ToLower().Contains(" in ")) { splittedArgs = args.ToLower().Split(new[] { " in " }, StringSplitOptions.None); } else if (args.ToLower().Contains(" in ")) { splittedArgs = args.ToLower().Split(new[] { " in " }, StringSplitOptions.None); } else if (args.ToLower().Contains(" in ")) { splittedArgs = args.ToLower().Split(new[] { " in " }, StringSplitOptions.None); } if (splittedArgs == null) { const string bigmess = "boole-boole... you are using this command incorrectly!!\n" + "Right way: `Remind [text] in [time]`\n" + "Between message and time **HAVE TO BE** written `in` part" + "(Time can be different, but follow the rules! **day-hour-minute-second**. You can skip any of those parts, but they have to be in the same order. One space or without it between each of the parts\n" + "I'm a loving order octopus!"; await CommandHandeling.ReplyAsync(Context, bigmess); return; } var account = UserAccounts.GetAccount(Context.User, 0); var accountForTimeZone = UserAccounts.GetAccount(Context.User, Context.Guild.Id); var timezone = accountForTimeZone.TimeZone ?? "UTC"; TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById($"{timezone}"); var timeString = splittedArgs[splittedArgs.Length - 1]; if (timeString == "24h") { timeString = "1d"; } splittedArgs[splittedArgs.Length - 1] = ""; var reminderString = string.Join(" in ", splittedArgs, 0, splittedArgs.Length - 1); var timeDateTime = DateTime.UtcNow + TimeSpan.ParseExact(timeString, ReminderFormat.Formats, CultureInfo.CurrentCulture); var randomIndex = _secureRandom.Random(0, OctoNamePull.OctoNameRu.Length - 1); var randomOcto = OctoNamePull.OctoNameRu[randomIndex]; var extra = randomOcto.Split(new[] { "](" }, StringSplitOptions.RemoveEmptyEntries); var name = extra[0].Remove(0, 1); var url = extra[1].Remove(extra[1].Length - 1, 1); var localTime = TimeZoneInfo.ConvertTimeFromUtc(timeDateTime, tz); var bigmess2 = $"{reminderString}\n\n" + $"We will send you a DM in __**{localTime}**__ `by {timezone}`\n"; var embed = new EmbedBuilder(); embed.WithAuthor(Context.User); embed.WithTimestamp(DateTimeOffset.UtcNow); embed.WithColor(_secureRandom.Random(0, 254), _secureRandom.Random(0, 254), _secureRandom.Random(0, 254)); embed.AddField($"**____**", $"{bigmess2}"); embed.WithTitle($"{name} напомнит тебе:"); embed.WithUrl(url); var newReminder = new CreateReminder(timeDateTime, reminderString); account.ReminderList.Add(newReminder); UserAccounts.SaveAccounts(0); await CommandHandeling.ReplyAsync(Context, embed); } catch (Exception e) { var botMess = await ReplyAsync( "boo... An error just appear >_< \n" + "Say `HelpRemind`"); HelperFunctions.DeleteMessOverTime(botMess, 5); ConsoleLogger.Log($" [REMINDER][Exception] ({Context.User.Username}) - {e.Message}", ConsoleColor.DarkBlue); Console.WriteLine(e.Message); } }
public async Task OctopusPicture() { try { var embed = new EmbedBuilder(); var account = UserAccounts.GetAccount(Context.User, 0); var difference = DateTime.UtcNow - account.LastOctoPic; if (difference.TotalHours > 5) { var randomKeyPossible = _secureRandom.Random(0, 100000); if (randomKeyPossible == 1448) { embed.AddField("Boole!?", "What is it? Some king of a quest... I found a number - **228**, " + "what can it mean... if you will know, say `quest ANSWER`, I think this should be one eglish word."); } } account.LastOctoPic = DateTime.UtcNow; UserAccounts.SaveAccounts(0); var index = _secureRandom.Random(0, 254); if (index == 5 || index == 38 || index == 69) { var lll = await Context.Channel.SendMessageAsync("boole"); HelperFunctions.DeleteMessOverTime(lll, 6); } else { var octoIndex = _secureRandom.Random(0, OctoPicPull.OctoPics.Length - 1); var octoToPost = OctoPicPull.OctoPics[octoIndex]; var color1Index = _secureRandom.Random(0, 254); var color2Index = _secureRandom.Random(0, 254); var color3Index = _secureRandom.Random(0, 254); var randomIndex = _secureRandom.Random(0, OctoNamePull.OctoNameRu.Length); var randomOcto = OctoNamePull.OctoNameRu[randomIndex]; embed.WithDescription($"{randomOcto} found:"); embed.WithFooter("lil octo notebook"); embed.WithColor(color1Index, color2Index, color3Index); embed.WithAuthor(Context.User); embed.WithImageUrl("" + octoToPost); await CommandHandeling.ReplyAsync(Context, embed); if (octoIndex == 19) { var lll = await Context.Channel.SendMessageAsync("Ooooo, it was I who just passed Dark Souls!"); HelperFunctions.DeleteMessOverTime(lll, 6); } if (octoIndex == 9) { var lll = await Context.Channel.SendMessageAsync("I'm drawing an octopus :3"); HelperFunctions.DeleteMessOverTime(lll, 6); } if (octoIndex == 26) { var lll = await Context.Channel.SendMessageAsync( "Oh, this is New Year! time to gift turtles!!"); HelperFunctions.DeleteMessOverTime(lll, 6); } } } catch { // await ReplyAsync("boo... An error just appear >_< \nTry to use this command properly: **Octo**\n"); } }