public async Task Fish(CommandContext ctx) { var chance = new Random().Next(0, 10); string reply; int castCost = 3; int castEarn; int commonFish = 5; int rareFish = 10; int superRareFish = 20; ctx.Client.DebugLogger.LogMessage(LogLevel.Debug, "Wiggims Bot: fish command", $"Random value was {chance}", DateTime.Now, null); switch (chance) { case 0: castEarn = 0; reply = "You caught nothing"; break; case 1: castEarn = 0; reply = "You caught nothing"; break; case 2: castEarn = 0; reply = "You caught nothing"; break; case 3: castEarn = 0; reply = $"You caught nothing"; break; case 4: castEarn = commonFish; reply = $"You caught a common fish worth {castEarn} gold"; break; case 5: castEarn = commonFish; reply = $"You caught a common fish worth {castEarn} gold"; break; case 6: castEarn = commonFish; reply = $"You caught a common fish worth {castEarn} gold"; break; case 7: castEarn = commonFish; reply = $"You caught a common fish worth {castEarn} gold"; break; case 8: castEarn = rareFish; reply = $"You caught a rare fish worth {castEarn} gold"; break; case 9: castEarn = rareFish; reply = $"You caught a rare fish worth {castEarn} gold"; break; case 10: castEarn = superRareFish; reply = $"You caught a super rare fish worth {castEarn} gold"; break; default: throw new Exception($"{chance} was not in the range."); } var embed = new DiscordEmbedBuilder() { Title = $"{ctx.Member.Username} went fishing", Description = reply + $", You spent {castCost} gold to cast the rod", Color = ctx.Member.Color }; embed.WithFooter("This crappy command will not stay like this for long."); Profile profile = await _profileService.GetOrCreateProfileAsync(ctx.Member.Id, ctx.Guild.Id); if (profile.Gold < castCost) { await ctx.RespondAsync($"You do not have enough gold to cast your rod, you need at least {castCost} gold."); return; } Profile botProfile = await _profileService.GetOrCreateProfileAsync(ctx.Client.CurrentUser.Id, ctx.Guild.Id); await _goldService.TransferGold(botProfile, profile, castEarn - castCost, false); await ctx.RespondAsync(embed : embed); }
public async Task WiggimsBotSpell(CommandContext ctx) { bool isCommand = ctx.Message.Content.ToLower().Contains("w!") || ctx.Message.Content.ToLower().Contains("w@"); bool isBot = ctx.Message.Author.IsBot; bool isCodeBlock = ctx.Message.Content.Contains("```"); string[] message = ctx.Message.Content.Split(); int errorCount = 0; int correctCount = 0; int boganCount = 0; List <string> sb = new List <string> { }; GuildPreferences guildPreferences = await _guildPreferences.GetOrCreateGuildPreferences(ctx.Guild.Id); if (!isCommand && !isBot && !isCodeBlock) { foreach (string word in message) { if ( string.IsNullOrWhiteSpace(word) || word.Contains("https://") || word.Length > 18 || word.Contains(":") || word.Contains("😢") || word.Contains("👍") || word.Contains("👎") || word.Contains("😀") || word.Contains("😃") || word.Contains("😄") || word.Contains("😁") || word.Contains("😆") || word.Contains("😅") || word.Contains("😂") || word.StartsWith("!") || word.StartsWith("d!") || word.StartsWith(">") || !guildPreferences.SpellingEnabled ) { return; } var dictionary = WordList.CreateFromFiles(@"Resources/en_au.dic"); var boganDictionary = WordList.CreateFromFiles(@"Resources/badwords.dic"); string cleanedWord = Regex.Replace(word.ToLower(), @"[^\w\s]", ""); bool notOk = dictionary.Check(cleanedWord); bool Bogan = boganDictionary.Check(cleanedWord); if (notOk == false) { errorCount += 1; Console.WriteLine(cleanedWord); sb.Add(cleanedWord); await File.AppendAllTextAsync(@"Resources/missspelledwordsall.txt", $"\n{cleanedWord} - {word}"); var wrongDictionary = WordList.CreateFromFiles(@"Resources/missspelledwords.dic"); bool alreadyPresent = wrongDictionary.Check(cleanedWord); if (alreadyPresent == false) { string dicFilePath = @"Resources/missspelledwords.dic"; await File.AppendAllTextAsync(dicFilePath, $"\n{cleanedWord}"); } if (Bogan == true) { boganCount += 1; } } else { correctCount += 1; if (Bogan == true) { boganCount += 1; } } } Console.WriteLine($"{ctx.Message.Author.Username} sent a message in the {ctx.Guild.Name} guild. spelling stats:\nCorrect: {correctCount}\tIncorrect: {errorCount}\tBogan words: {boganCount}"); Profile profile = await _profileService.GetOrCreateProfileAsync(ctx.Member.Id, ctx.Guild.Id); TextProcessorViewModel viewModel = await _textProcessorService.ProcessTextAsync(ctx.Member.Id, ctx.Guild.Id, $"{ctx.Member.Username}#{ctx.Member.Discriminator}", correctCount, errorCount, boganCount, 1, guildPreferences.ErrorListLength, sb).ConfigureAwait(false); if (!viewModel.LevelledUp) { return; } var json = string.Empty; using (var fs = File.OpenRead("config.json")) using (var sr = new StreamReader(fs, new UTF8Encoding(false))) json = sr.ReadToEnd(); var configJson = JsonConvert.DeserializeObject <ConfigJson>(json); int goldperlevelup = configJson.goldperlevelup; await _goldService.TransferGold(ctx.Client.CurrentUser.Id, ctx.Member.Id, ctx.Guild.Id, goldperlevelup, true); if (profile.QuietMode == true) { return; } var levelUpEmbed = new DiscordEmbedBuilder { Title = $"{ctx.Member.DisplayName} Is Now Level {viewModel.Profile.Level}", Thumbnail = new DiscordEmbedBuilder.EmbedThumbnail { Url = ctx.Member.AvatarUrl }, Color = ctx.Member.Color }; if (goldperlevelup > 0) { levelUpEmbed.WithDescription($"+ {goldperlevelup} :moneybag:"); } levelUpEmbed.WithFooter("`w!profile togglenotifications` to hide In future."); await ctx.Channel.SendMessageAsync(embed : levelUpEmbed).ConfigureAwait(false); } }