From 926e8a33c86eb14f5449634a73f2ec65807a4012 Mon Sep 17 00:00:00 2001 From: Pg Date: Mon, 21 Nov 2016 13:21:39 +0100 Subject: [PATCH 01/37] Remove credential.json from tracked files --- src/NadekoBot/credentials.json | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 src/NadekoBot/credentials.json diff --git a/src/NadekoBot/credentials.json b/src/NadekoBot/credentials.json deleted file mode 100644 index 30f8f88f..00000000 --- a/src/NadekoBot/credentials.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "ClientId": 123123123, - "BotId": null, - "Token": "MTE5Nzc3MDIxMzE5NTc3NjEw.CxK2Og.N4u_RpZws88zmXWF16mQaQUSphI", - "OwnerIds": [ - 0 - ], - "LoLApiKey": "", - "GoogleApiKey": "", - "MashapeKey": "", - "OsuApiKey": "", - "SoundCloudClientId": "", - "Db": null, - "TotalShards": 1 -} \ No newline at end of file From 93f54d56cfb332c1cdbc2eeaa2fe450657d2c24a Mon Sep 17 00:00:00 2001 From: Pg Date: Fri, 25 Nov 2016 01:18:46 +0100 Subject: [PATCH 02/37] Implementation of pokegame commands Added the commands, description and usage to Resources/commandStrings using the previous definition of commands in Nadeko 0.9 --- .../Resources/CommandStrings.Designer.cs | 143 +++++++++++++++++- src/NadekoBot/Resources/CommandStrings.resx | 45 ++++++ 2 files changed, 184 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index 5d6bdf64..168b5d14 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -491,6 +491,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to attack. + /// + public static string attack_cmd { + get { + return ResourceManager.GetString("attack_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Attacks a target with the given move. Use `{0}movelist` to see a list of moves your type can use.. + /// + public static string attack_desc { + get { + return ResourceManager.GetString("attack_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}attack "vine whip" @someguy`. + /// + public static string attack_usage { + get { + return ResourceManager.GetString("attack_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to autoassignrole aar. /// @@ -906,7 +933,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Toggles automatic deletion of bye messages.. + /// Looks up a localized string similar to Sets the time it takes (in seconds) for bye messages to be auto-deleted. Set 0 to disable automatic deletion.. /// public static string byedel_desc { get { @@ -915,7 +942,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `{0}byedel`. + /// Looks up a localized string similar to `{0}byedel 0` or `{0}byedel 30`. /// public static string byedel_usage { get { @@ -2688,7 +2715,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Toggles automatic deletion of greet messages.. + /// Looks up a localized string similar to Sets the time it takes (in seconds) for greet messages to be auto-deleted. Set 0 to disable automatic deletion.. /// public static string greetdel_desc { get { @@ -2697,7 +2724,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `{0}greetdel`. + /// Looks up a localized string similar to `{0}greetdel 0` or `{0}greetdel 30`. /// public static string greetdel_usage { get { @@ -2894,6 +2921,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to heal. + /// + public static string heal_cmd { + get { + return ResourceManager.GetString("heal_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Heals someone. Revives those who fainted. Costs a NadekoFlower. + /// + public static string heal_desc { + get { + return ResourceManager.GetString("heal_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}heal @someone`. + /// + public static string heal_usage { + get { + return ResourceManager.GetString("heal_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to hearthstone hs. /// @@ -4244,6 +4298,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to movelist ml. + /// + public static string movelist_cmd { + get { + return ResourceManager.GetString("movelist_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lists the moves you are able to use. + /// + public static string movelist_desc { + get { + return ResourceManager.GetString("movelist_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}ml`. + /// + public static string movelist_usage { + get { + return ResourceManager.GetString("movelist_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to moveperm mp. /// @@ -6242,6 +6323,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to settype. + /// + public static string settype_cmd { + get { + return ResourceManager.GetString("settype_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Set your poketype. Costs a NadekoFlower.. + /// + public static string settype_desc { + get { + return ResourceManager.GetString("settype_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}settype fire`. + /// + public static string settype_usage { + get { + return ResourceManager.GetString("settype_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to shorten. /// @@ -6944,6 +7052,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to type. + /// + public static string type_cmd { + get { + return ResourceManager.GetString("type_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Get the poketype of the target.. + /// + public static string type_desc { + get { + return ResourceManager.GetString("type_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}type @someone`. + /// + public static string type_usage { + get { + return ResourceManager.GetString("type_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to typeadd. /// diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 76c0a001..2aa53d7c 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2700,4 +2700,49 @@ `{0}yandere tag1+tag2` + + attack + + + Attacks a target with the given move. Use `{0}movelist` to see a list of moves your type can use. + + + `{0}attack "vine whip" @someguy` + + + heal + + + Heals someone. Revives those who fainted. Costs a NadekoFlower + + + `{0}heal @someone` + + + movelist ml + + + Lists the moves you are able to use + + + `{0}ml` + + + settype + + + Set your poketype. Costs a NadekoFlower. + + + `{0}settype fire` + + + type + + + Get the poketype of the target. + + + `{0}type @someone` + \ No newline at end of file From 2397f3ca3030d5e345817c76e56a7f6748114db7 Mon Sep 17 00:00:00 2001 From: Pg Date: Fri, 25 Nov 2016 01:20:18 +0100 Subject: [PATCH 03/37] Add the model and the module to bot --- .../Modules/Pokemon/PokemonModule.cs | 339 ++++++++++++++++++ .../Services/Database/Models/PokeStats.cs | 15 + 2 files changed, 354 insertions(+) create mode 100644 src/NadekoBot/Modules/Pokemon/PokemonModule.cs create mode 100644 src/NadekoBot/Services/Database/Models/PokeStats.cs diff --git a/src/NadekoBot/Modules/Pokemon/PokemonModule.cs b/src/NadekoBot/Modules/Pokemon/PokemonModule.cs new file mode 100644 index 00000000..d494fffa --- /dev/null +++ b/src/NadekoBot/Modules/Pokemon/PokemonModule.cs @@ -0,0 +1,339 @@ +using Discord.Commands; +using Discord.Modules; +using NadekoBot.Classes; +using NadekoBot.Classes.JSONModels; +using NadekoBot.DataModels; +using NadekoBot.Extensions; +using NadekoBot.Modules.Permissions.Classes; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; + +namespace NadekoBot.Modules.Pokemon +{ + class PokemonModule : DiscordModule + { + public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Pokemon; + + private ConcurrentDictionary Stats = new ConcurrentDictionary(); + + public PokemonModule() + { + + } + + private int GetDamage(PokemonType usertype, PokemonType targetType) + { + var rng = new Random(); + int damage = rng.Next(40, 60); + foreach (PokemonMultiplier Multiplier in usertype.Multipliers) + { + if (Multiplier.Type == targetType.Name) + { + var multiplier = Multiplier.Multiplication; + damage = (int)(damage * multiplier); + } + } + + return damage; + } + + private PokemonType GetPokeType(ulong id) + { + + var db = DbHandler.Instance.GetAllRows(); + Dictionary setTypes = db.ToDictionary(x => x.UserId, y => y.type); + if (setTypes.ContainsKey((long)id)) + { + return stringToPokemonType(setTypes[(long)id]); + } + int count = NadekoBot.Config.PokemonTypes.Count; + + int remainder = Math.Abs((int)(id % (ulong)count)); + + return NadekoBot.Config.PokemonTypes[remainder]; + } + + + + private PokemonType stringToPokemonType(string v) + { + var str = v.ToUpperInvariant(); + var list = NadekoBot.Config.PokemonTypes; + foreach (PokemonType p in list) + { + if (str == p.Name) + { + return p; + } + } + return null; + } + + public override void Install(ModuleManager manager) + { + manager.CreateCommands("", cgb => + { + cgb.AddCheck(PermissionChecker.Instance); + + commands.ForEach(cmd => cmd.Init(cgb)); + + cgb.CreateCommand(Prefix + "attack") + .Description($"Attacks a target with the given move. Use `{Prefix}movelist` to see a list of moves your type can use. | `{Prefix}attack \"vine whip\" @someguy`") + .Parameter("move", ParameterType.Required) + .Parameter("target", ParameterType.Unparsed) + .Do(async e => + { + var move = e.GetArg("move"); + var targetStr = e.GetArg("target")?.Trim(); + if (string.IsNullOrWhiteSpace(targetStr)) + return; + var target = e.Server.FindUsers(targetStr).FirstOrDefault(); + if (target == null) + { + await e.Channel.SendMessage("No such person.").ConfigureAwait(false); + return; + } + else if (target == e.User) + { + await e.Channel.SendMessage("You can't attack yourself.").ConfigureAwait(false); + return; + } + // Checking stats first, then move + //Set up the userstats + PokeStats userStats; + userStats = Stats.GetOrAdd(e.User.Id, new PokeStats()); + + //Check if able to move + //User not able if HP < 0, has made more than 4 attacks + if (userStats.Hp < 0) + { + await e.Channel.SendMessage($"{e.User.Mention} has fainted and was not able to move!").ConfigureAwait(false); + return; + } + if (userStats.MovesMade >= 5) + { + await e.Channel.SendMessage($"{e.User.Mention} has used too many moves in a row and was not able to move!").ConfigureAwait(false); + return; + } + if (userStats.LastAttacked.Contains(target.Id)) + { + await e.Channel.SendMessage($"{e.User.Mention} can't attack again without retaliation!").ConfigureAwait(false); + return; + } + //get target stats + PokeStats targetStats; + targetStats = Stats.GetOrAdd(target.Id, new PokeStats()); + + //If target's HP is below 0, no use attacking + if (targetStats.Hp <= 0) + { + await e.Channel.SendMessage($"{target.Mention} has already fainted!").ConfigureAwait(false); + return; + } + + //Check whether move can be used + PokemonType userType = GetPokeType(e.User.Id); + + var enabledMoves = userType.Moves; + if (!enabledMoves.Contains(move.ToLowerInvariant())) + { + await e.Channel.SendMessage($"{e.User.Mention} was not able to use **{move}**, use `{Prefix}ml` to see moves you can use").ConfigureAwait(false); + return; + } + + //get target type + PokemonType targetType = GetPokeType(target.Id); + //generate damage + int damage = GetDamage(userType, targetType); + //apply damage to target + targetStats.Hp -= damage; + + var response = $"{e.User.Mention} used **{move}**{userType.Icon} on {target.Mention}{targetType.Icon} for **{damage}** damage"; + + //Damage type + if (damage < 40) + { + response += "\nIt's not effective.."; + } + else if (damage > 60) + { + response += "\nIt's super effective!"; + } + else + { + response += "\nIt's somewhat effective"; + } + + //check fainted + + if (targetStats.Hp <= 0) + { + response += $"\n**{target.Name}** has fainted!"; + } + else + { + response += $"\n**{target.Name}** has {targetStats.Hp} HP remaining"; + } + + //update other stats + userStats.LastAttacked.Add(target.Id); + userStats.MovesMade++; + targetStats.MovesMade = 0; + if (targetStats.LastAttacked.Contains(e.User.Id)) + { + targetStats.LastAttacked.Remove(e.User.Id); + } + + //update dictionary + //This can stay the same right? + Stats[e.User.Id] = userStats; + Stats[target.Id] = targetStats; + + await e.Channel.SendMessage(response).ConfigureAwait(false); + }); + + cgb.CreateCommand(Prefix + "movelist") + .Alias(Prefix + "ml") + .Description($"Lists the moves you are able to use | `{Prefix}ml`") + .Do(async e => + { + var userType = GetPokeType(e.User.Id); + var movesList = userType.Moves; + var str = $"**Moves for `{userType.Name}` type.**"; + foreach (string m in movesList) + { + str += $"\n{userType.Icon}{m}"; + } + await e.Channel.SendMessage(str).ConfigureAwait(false); + }); + + cgb.CreateCommand(Prefix + "heal") + .Description($"Heals someone. Revives those who fainted. Costs a {NadekoBot.Config.CurrencyName} | `{Prefix}heal @someone`") + .Parameter("target", ParameterType.Unparsed) + .Do(async e => + { + var targetStr = e.GetArg("target")?.Trim(); + if (string.IsNullOrWhiteSpace(targetStr)) + return; + var usr = e.Server.FindUsers(targetStr).FirstOrDefault(); + if (usr == null) + { + await e.Channel.SendMessage("No such person.").ConfigureAwait(false); + return; + } + if (Stats.ContainsKey(usr.Id)) + { + + var targetStats = Stats[usr.Id]; + int HP = targetStats.Hp; + if (targetStats.Hp == targetStats.MaxHp) + { + await e.Channel.SendMessage($"{usr.Name} already has full HP!").ConfigureAwait(false); + return; + } + //Payment~ + var amount = 1; + var pts = Classes.DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0; + if (pts < amount) + { + await e.Channel.SendMessage($"{e.User.Mention} you don't have enough {NadekoBot.Config.CurrencyName}s! \nYou still need {amount - pts} {NadekoBot.Config.CurrencySign} to be able to do this!").ConfigureAwait(false); + return; + } + var target = (usr.Id == e.User.Id) ? "yourself" : usr.Name; + await FlowersHandler.RemoveFlowers(e.User, $"Poke-Heal {target}", amount).ConfigureAwait(false); + //healing + targetStats.Hp = targetStats.MaxHp; + if (HP < 0) + { + //Could heal only for half HP? + Stats[usr.Id].Hp = (targetStats.MaxHp / 2); + await e.Channel.SendMessage($"{e.User.Name} revived {usr.Name} with one {NadekoBot.Config.CurrencySign}").ConfigureAwait(false); + return; + } + var vowelFirst = new[] { 'a', 'e', 'i', 'o', 'u' }.Contains(NadekoBot.Config.CurrencyName[0]); + await e.Channel.SendMessage($"{e.User.Name} healed {usr.Name} for {targetStats.MaxHp - HP} HP with {(vowelFirst ? "an" : "a")} {NadekoBot.Config.CurrencySign}").ConfigureAwait(false); + return; + } + else + { + await e.Channel.SendMessage($"{usr.Name} already has full HP!").ConfigureAwait(false); + } + }); + + cgb.CreateCommand(Prefix + "type") + .Description($"Get the poketype of the target. | `{Prefix}type @someone`") + .Parameter("target", ParameterType.Unparsed) + .Do(async e => + { + var usrStr = e.GetArg("target")?.Trim(); + if (string.IsNullOrWhiteSpace(usrStr)) + return; + var usr = e.Server.FindUsers(usrStr).FirstOrDefault(); + if (usr == null) + { + await e.Channel.SendMessage("No such person.").ConfigureAwait(false); + return; + } + var pType = GetPokeType(usr.Id); + await e.Channel.SendMessage($"Type of {usr.Name} is **{pType.Name.ToLowerInvariant()}**{pType.Icon}").ConfigureAwait(false); + + }); + + cgb.CreateCommand(Prefix + "settype") + .Description($"Set your poketype. Costs a {NadekoBot.Config.CurrencyName}. | `{Prefix}settype fire`") + .Parameter("targetType", ParameterType.Unparsed) + .Do(async e => + { + var targetTypeStr = e.GetArg("targetType")?.ToUpperInvariant(); + if (string.IsNullOrWhiteSpace(targetTypeStr)) + return; + var targetType = stringToPokemonType(targetTypeStr); + if (targetType == null) + { + await e.Channel.SendMessage("Invalid type specified. Type must be one of:\n" + string.Join(", ", NadekoBot.Config.PokemonTypes.Select(t => t.Name.ToUpperInvariant()))).ConfigureAwait(false); + return; + } + if (targetType == GetPokeType(e.User.Id)) + { + await e.Channel.SendMessage($"Your type is already {targetType.Name.ToLowerInvariant()}{targetType.Icon}").ConfigureAwait(false); + return; + } + + //Payment~ + var amount = 1; + var pts = DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0; + if (pts < amount) + { + await e.Channel.SendMessage($"{e.User.Mention} you don't have enough {NadekoBot.Config.CurrencyName}s! \nYou still need {amount - pts} {NadekoBot.Config.CurrencySign} to be able to do this!").ConfigureAwait(false); + return; + } + await FlowersHandler.RemoveFlowers(e.User, $"set usertype to {targetTypeStr}", amount).ConfigureAwait(false); + //Actually changing the type here + var preTypes = DbHandler.Instance.GetAllRows(); + Dictionary Dict = preTypes.ToDictionary(x => x.UserId, y => y.Id.Value); + if (Dict.ContainsKey((long)e.User.Id)) + { + //delete previous type + DbHandler.Instance.Delete(Dict[(long)e.User.Id]); + } + + DbHandler.Instance.Connection.Insert(new UserPokeTypes + { + UserId = (long)e.User.Id, + type = targetType.Name + }, typeof(UserPokeTypes)); + + //Now for the response + + await e.Channel.SendMessage($"Set type of {e.User.Mention} to {targetTypeStr}{targetType.Icon} for a {NadekoBot.Config.CurrencySign}").ConfigureAwait(false); + }); + }); + } + } +} + + + + diff --git a/src/NadekoBot/Services/Database/Models/PokeStats.cs b/src/NadekoBot/Services/Database/Models/PokeStats.cs new file mode 100644 index 00000000..b9795043 --- /dev/null +++ b/src/NadekoBot/Services/Database/Models/PokeStats.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace NadekoBot.Modules.Pokemon +{ + class PokeStats + { + //Health left + public int Hp { get; set; } = 500; + public int MaxHp { get; } = 500; + //Amount of moves made since last time attacked + public int MovesMade { get; set; } = 0; + //Last people attacked + public List LastAttacked { get; set; } = new List(); + } +} From 5958580abe6a503ebc326399530736b398b3764a Mon Sep 17 00:00:00 2001 From: Pg Date: Sat, 26 Nov 2016 01:52:27 +0100 Subject: [PATCH 04/37] Update file in database models --- .../Models => Modules/Pokemon}/PokeStats.cs | 0 .../Modules/Pokemon/PokemonModule.cs | 42 +++++++++++++++---- 2 files changed, 33 insertions(+), 9 deletions(-) rename src/NadekoBot/{Services/Database/Models => Modules/Pokemon}/PokeStats.cs (100%) diff --git a/src/NadekoBot/Services/Database/Models/PokeStats.cs b/src/NadekoBot/Modules/Pokemon/PokeStats.cs similarity index 100% rename from src/NadekoBot/Services/Database/Models/PokeStats.cs rename to src/NadekoBot/Modules/Pokemon/PokeStats.cs diff --git a/src/NadekoBot/Modules/Pokemon/PokemonModule.cs b/src/NadekoBot/Modules/Pokemon/PokemonModule.cs index d494fffa..fe13d795 100644 --- a/src/NadekoBot/Modules/Pokemon/PokemonModule.cs +++ b/src/NadekoBot/Modules/Pokemon/PokemonModule.cs @@ -1,18 +1,42 @@ +using Discord; using Discord.Commands; -using Discord.Modules; -using NadekoBot.Classes; -using NadekoBot.Classes.JSONModels; -using NadekoBot.DataModels; +using NadekoBot.Attributes; using NadekoBot.Extensions; -using NadekoBot.Modules.Permissions.Classes; -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NadekoBot.Services; +using Discord.WebSocket; +using NadekoBot.Services.Database.Models; +using System.Collections.Generic; +using System.Collections.Concurrent; +using System.Linq; + namespace NadekoBot.Modules.Pokemon { - class PokemonModule : DiscordModule + + [NadekoModule("PokeGame", ">")] + public partial class PokemonModule : DiscordModule + { + public static string CurrencyName { get; set; } + public static string CurrencyPluralName { get; set; } + public static string CurrencySign { get; set; } + + public Gambling(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client) + { + using (var uow = DbHandler.UnitOfWork()) + { + var conf = uow.BotConfig.GetOrCreate(); + + CurrencyName = conf.CurrencyName; + CurrencySign = conf.CurrencySign; + CurrencyPluralName = conf.CurrencyPluralName; + } + } + + + class PokemonModule : DiscordModule { public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Pokemon; From 713363dcc0787e294612b6a98a0bcbb4a94d91e7 Mon Sep 17 00:00:00 2001 From: Pg Date: Sat, 26 Nov 2016 02:34:53 +0100 Subject: [PATCH 05/37] Add PokemonType.json to the data of nadeko --- src/NadekoBot/data/PokemonTypes.json | 699 +++++++++++++++++++++++++++ 1 file changed, 699 insertions(+) create mode 100644 src/NadekoBot/data/PokemonTypes.json diff --git a/src/NadekoBot/data/PokemonTypes.json b/src/NadekoBot/data/PokemonTypes.json new file mode 100644 index 00000000..6d7ac74a --- /dev/null +++ b/src/NadekoBot/data/PokemonTypes.json @@ -0,0 +1,699 @@ +[ + { + "Name": "NORMAL", + "Multipliers": [ + { + "Type": "ROCK", + "Multiplication": 0.5 + }, + { + "Type": "GHOST", + "Multiplication": 0 + }, + { + "Type": "STEEL", + "Multiplication": 0.5 + } + ], + "Moves": [ + "sonic boom", + "quick attack", + "doubleslap", + "headbutt" + ], + "Icon": "⭕️" + }, + { + "Name": "FIRE", + "Multipliers": [ + { + "Type": "FIRE", + "Multiplication": 0.5 + }, + { + "Type": "WATER", + "Multiplication": 0.5 + }, + { + "Type": "GRASS", + "Multiplication": 2 + }, + { + "Type": "ICE", + "Multiplication": 2 + }, + { + "Type": "BUG", + "Multiplication": 2 + }, + { + "Type": "ROCK", + "Multiplication": 0.5 + }, + { + "Type": "DRAGON", + "Multiplication": 0.5 + }, + { + "Type": "STEEL", + "Multiplication": 2 + } + ], + "Moves": [ + "incinerate", + "ember", + "fire punch", + "fiery dance" + ], + "Icon": "🔥" + }, + { + "Name": "WATER", + "Multipliers": [ + { + "Type": "FIRE", + "Multiplication": 2 + }, + { + "Type": "WATER", + "Multiplication": 0.5 + }, + { + "Type": "GRASS", + "Multiplication": 0.5 + }, + { + "Type": "GROUND", + "Multiplication": 2 + }, + { + "Type": "ROCK", + "Multiplication": 2 + }, + { + "Type": "DRAGON", + "Multiplication": 0.5 + } + ], + "Moves": [ + "bubblebeam", + "dive", + "whirlpool", + "aqua tail" + ], + "Icon": "💦" + }, + { + "Name": "ELECTRIC", + "Multipliers": [ + { + "Type": "WATER", + "Multiplication": 2 + }, + { + "Type": "ELECTRIC", + "Multiplication": 0.5 + }, + { + "Type": "GRASS", + "Multiplication": 0.5 + }, + { + "Type": "GROUND", + "Multiplication": 0 + }, + { + "Type": "FLYING", + "Multiplication": 2 + }, + { + "Type": "DRAGON", + "Multiplication": 0.5 + } + ], + "Moves": [ + "nuzzle", + "thunderbolt", + "thundershock", + "discharge" + ], + "Icon": "⚡" + }, + { + "Name": "GRASS", + "Multipliers": [ + { + "Type": "FIRE", + "Multiplication": 0.5 + }, + { + "Type": "WATER", + "Multiplication": 2 + }, + { + "Type": "GRASS", + "Multiplication": 0.5 + }, + { + "Type": "ICE", + "Multiplication": 0.5 + }, + { + "Type": "BUG", + "Multiplication": 0.5 + }, + { + "Type": "ROCK", + "Multiplication": 2 + }, + { + "Type": "DRAGON", + "Multiplication": 0.5 + }, + { + "Type": "STEEL", + "Multiplication": 0.5 + }, + { + "Type": "POISON", + "Multiplication": 0.5 + }, + { + "Type": "GROUND", + "Multiplication": 2 + } + ], + "Moves": [ + "absorb", + "mega drain", + "vine whip", + "razor leaf" + ], + "Icon": "🍃" + }, + { + "Name": "ICE", + "Multipliers": [ + { + "Type": "FIRE", + "Multiplication": 0.5 + }, + { + "Type": "WATER", + "Multiplication": 0.5 + }, + { + "Type": "GRASS", + "Multiplication": 2 + }, + { + "Type": "ICE", + "Multiplication": 0.5 + }, + { + "Type": "GROUND", + "Multiplication": 2 + }, + { + "Type": "FLYING", + "Multiplication": 2 + }, + { + "Type": "DRAGON", + "Multiplication": 2 + }, + { + "Type": "STEEL", + "Multiplication": 0.5 + } + ], + "Moves": [ + "ice ball", + "powder snow", + "avalanche", + "icy wind" + ], + "Icon": "❄" + }, + { + "Name": "FIGHTING", + "Multipliers": [ + { + "Type": "NORMAL", + "Multiplication": 2 + }, + { + "Type": "ICE", + "Multiplication": 2 + }, + { + "Type": "POISON", + "Multiplication": 0.5 + }, + { + "Type": "FLYING", + "Multiplication": 0.5 + }, + { + "Type": "PSYCHIC", + "Multiplication": 0.5 + }, + { + "Type": "BUG", + "Multiplication": 0.5 + }, + { + "Type": "ROCK", + "Multiplication": 2 + }, + { + "Type": "GHOST", + "Multiplication": 0 + }, + { + "Type": "DARK", + "Multiplication": 2 + }, + { + "Type": "STEEL", + "Multiplication": 2 + }, + { + "Type": "FAIRY", + "Multiplication": 0.5 + } + ], + "Moves": [ + "low kick", + "force palm", + "mach punch", + "double kick" + ], + "Icon": "✊" + }, + { + "Name": "POISON", + "Multipliers": [ + { + "Type": "GRASS", + "Multiplication": 2 + }, + { + "Type": "POISON", + "Multiplication": 0.5 + }, + { + "Type": "GROUND", + "Multiplication": 0.5 + }, + { + "Type": "ROCK", + "Multiplication": 0.5 + }, + { + "Type": "GHOST", + "Multiplication": 0.5 + }, + { + "Type": "STEEL", + "Multiplication": 0 + }, + { + "Type": "FAIRY", + "Multiplication": 2 + } + ], + "Moves": [ + "acid", + "smog", + "sludge", + "poison jab" + ], + "Icon": "☠" + }, + { + "Name": "GROUND", + "Multipliers": [ + { + "Type": "FIRE", + "Multiplication": 2 + }, + { + "Type": "ELECTRIC", + "Multiplication": 2 + }, + { + "Type": "GRASS", + "Multiplication": 0.5 + }, + { + "Type": "POISON", + "Multiplication": 2 + }, + { + "Type": "FLYING", + "Multiplication": 0 + }, + { + "Type": "BUG", + "Multiplication": 0.5 + }, + { + "Type": "ROCK", + "Multiplication": 2 + }, + { + "Type": "STEEL", + "Multiplication": 2 + } + ], + "Moves": [ + "mud-slap", + "earthquake", + "bulldoze", + "dig" + ], + "Icon": "🗻" + }, + { + "Name": "FLYING", + "Multipliers": [ + { + "Type": "ELECTRIC", + "Multiplication": 0.5 + }, + { + "Type": "GRASS", + "Multiplication": 2 + }, + { + "Type": "FIGHTING", + "Multiplication": 2 + }, + { + "Type": "BUG", + "Multiplication": 2 + }, + { + "Type": "ROCK", + "Multiplication": 0.5 + }, + { + "Type": "STEEL", + "Multiplication": 0.5 + } + ], + "Moves": [ + "peck", + "pluck", + "gust", + "aerial ace" + ], + "Icon": "☁" + }, + { + "Name": "PSYCHIC", + "Multipliers": [ + { + "Type": "FIGHTING", + "Multiplication": 2 + }, + { + "Type": "POISON", + "Multiplication": 2 + }, + { + "Type": "PSYCHIC", + "Multiplication": 0.5 + }, + { + "Type": "DARK", + "Multiplication": 0 + }, + { + "Type": "STEEL", + "Multiplication": 0.5 + } + ], + "Moves": [ + "confusion", + "psybeam", + "psywave", + "heart stamp" + ], + "Icon": "🔮" + }, + { + "Name": "BUG", + "Multipliers": [ + { + "Type": "FIRE", + "Multiplication": 0.5 + }, + { + "Type": "GRASS", + "Multiplication": 2 + }, + { + "Type": "FIGHTING", + "Multiplication": 0.5 + }, + { + "Type": "POISON", + "Multiplication": 0.5 + }, + { + "Type": "FLYING", + "Multiplication": 0.5 + }, + { + "Type": "PSYCHIC", + "Multiplication": 2 + }, + { + "Type": "ROCK", + "Multiplication": 0.5 + }, + { + "Type": "DARK", + "Multiplication": 2 + }, + { + "Type": "STEEL", + "Multiplication": 0.5 + }, + { + "Type": "FAIRY", + "Multiplication": 0.5 + } + ], + "Moves": [ + "bug bite", + "infestation", + "x-scissors", + "twineedle" + ], + "Icon": "🐛" + }, + { + "Name": "ROCK", + "Multipliers": [ + { + "Type": "FIRE", + "Multiplication": 2 + }, + { + "Type": "ICE", + "Multiplication": 2 + }, + { + "Type": "FIGHTING", + "Multiplication": 0.5 + }, + { + "Type": "GROUND", + "Multiplication": 0.5 + }, + { + "Type": "FLYING", + "Multiplication": 2 + }, + { + "Type": "BUG", + "Multiplication": 2 + }, + { + "Type": "STEEL", + "Multiplication": 0.5 + } + ], + "Moves": [ + "rock throw", + "rollout", + "rock tomb", + "rock blast" + ], + "Icon": "💎" + }, + { + "Name": "GHOST", + "Multipliers": [ + { + "Type": "NORMAL", + "Multiplication": 0 + }, + { + "Type": "PSYCHIC", + "Multiplication": 2 + }, + { + "Type": "GHOST", + "Multiplication": 2 + }, + { + "Type": "DARK", + "Multiplication": 0.5 + } + ], + "Moves": [ + "astonish", + "night shade", + "lick", + "ominous wind", + "hex" + ], + "Icon": "👻" + }, + { + "Name": "DRAGON", + "Multipliers": [ + { + "Type": "DRAGON", + "Multiplication": 2 + }, + { + "Type": "STEEL", + "Multiplication": 0.5 + }, + { + "Type": "FAIRY", + "Multiplication": 0 + } + ], + "Moves": [ + "dragon tail", + "dragon rage", + "dragonbreath", + "twister" + ], + "Icon": "🐉" + }, + { + "Name": "DARK", + "Multipliers": [ + { + "Type": "FIGHTING", + "Multiplication": 0.5 + }, + { + "Type": "PSYCHIC", + "Multiplication": 2 + }, + { + "Type": "GHOST", + "Multiplication": 2 + }, + { + "Type": "DARK", + "Multiplication": 0.5 + }, + { + "Type": "FAIRY", + "Multiplication": 0.5 + } + ], + "Moves": [ + "pursuit", + "assurance", + "bite", + "faint attack" + ], + "Icon": "✴" + }, + { + "Name": "STEEL", + "Multipliers": [ + { + "Type": "FIRE", + "Multiplication": 0.5 + }, + { + "Type": "WATER", + "Multiplication": 0.5 + }, + { + "Type": "ELECTRIC", + "Multiplication": 0.5 + }, + { + "Type": "ICE", + "Multiplication": 2 + }, + { + "Type": "ROCK", + "Multiplication": 2 + }, + { + "Type": "STEEL", + "Multiplication": 0.5 + }, + { + "Type": "FAIRY", + "Multiplication": 2 + } + ], + "Moves": [ + "bullet punch", + "metal burst", + "gear grind", + "magnet bomb" + ], + "Icon": "🔩" + }, + { + "Name": "FAIRY", + "Multipliers": [ + { + "Type": "FIGHTING", + "Multiplication": 2 + }, + { + "Type": "FIRE", + "Multiplication": 0.5 + }, + { + "Type": "DARK", + "Multiplication": 2 + }, + { + "Type": "POISON", + "Multiplication": 0.5 + }, + { + "Type": "STEEL", + "Multiplication": 0.5 + }, + { + "Type": "DRAGON", + "Multiplication": 2 + } + ], + "Moves": [ + "fairy wind", + "draining kiss", + "dazzling gleam", + "play rough" + ], + "Icon": "💫" + } +] From d5262fcb2c7fdc5f874dd387ab84818f22e1ef72 Mon Sep 17 00:00:00 2001 From: Pg Date: Sat, 26 Nov 2016 02:43:07 +0100 Subject: [PATCH 06/37] Change name of PokemonType.json to pokemon_types.json I notice the 'convention' in .json in nadeko. I change the name to follow this 'convention'. --- src/NadekoBot/data/{PokemonTypes.json => pokemon_types.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/NadekoBot/data/{PokemonTypes.json => pokemon_types.json} (100%) diff --git a/src/NadekoBot/data/PokemonTypes.json b/src/NadekoBot/data/pokemon_types.json similarity index 100% rename from src/NadekoBot/data/PokemonTypes.json rename to src/NadekoBot/data/pokemon_types.json From ba5afa8da05de043ee6f16eaa4d66dd7e74e0d47 Mon Sep 17 00:00:00 2001 From: Pg Date: Sat, 26 Nov 2016 03:12:20 +0100 Subject: [PATCH 07/37] Add getter and setter for module --- .../Modules/Searches/Commands/Models/PokeStats.cs | 15 +++++++++++++++ .../Services/Database/Models/PokemonType.cs | 15 +++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/NadekoBot/Modules/Searches/Commands/Models/PokeStats.cs create mode 100644 src/NadekoBot/Services/Database/Models/PokemonType.cs diff --git a/src/NadekoBot/Modules/Searches/Commands/Models/PokeStats.cs b/src/NadekoBot/Modules/Searches/Commands/Models/PokeStats.cs new file mode 100644 index 00000000..b9795043 --- /dev/null +++ b/src/NadekoBot/Modules/Searches/Commands/Models/PokeStats.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace NadekoBot.Modules.Pokemon +{ + class PokeStats + { + //Health left + public int Hp { get; set; } = 500; + public int MaxHp { get; } = 500; + //Amount of moves made since last time attacked + public int MovesMade { get; set; } = 0; + //Last people attacked + public List LastAttacked { get; set; } = new List(); + } +} diff --git a/src/NadekoBot/Services/Database/Models/PokemonType.cs b/src/NadekoBot/Services/Database/Models/PokemonType.cs new file mode 100644 index 00000000..9187226a --- /dev/null +++ b/src/NadekoBot/Services/Database/Models/PokemonType.cs @@ -0,0 +1,15 @@ +using Discord; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NadekoBot.Services.Database.Models +{ + class UserPokeTypes : DbEntity + { + public long UserId { get; set; } + public string type { get; set; } + } +} From 9dc3b33ed1e7730fa4e3da9d865c2f9a3f4b1742 Mon Sep 17 00:00:00 2001 From: Pg Date: Sat, 26 Nov 2016 03:28:26 +0100 Subject: [PATCH 08/37] Change file name to match with class --- .../Services/Database/Models/{PokemonType.cs => PokeType.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/NadekoBot/Services/Database/Models/{PokemonType.cs => PokeType.cs} (100%) diff --git a/src/NadekoBot/Services/Database/Models/PokemonType.cs b/src/NadekoBot/Services/Database/Models/PokeType.cs similarity index 100% rename from src/NadekoBot/Services/Database/Models/PokemonType.cs rename to src/NadekoBot/Services/Database/Models/PokeType.cs From d82c399a5a9740baabfd18556fc346376b12c541 Mon Sep 17 00:00:00 2001 From: Pg Date: Sat, 26 Nov 2016 03:33:56 +0100 Subject: [PATCH 09/37] Correction of location of file I added in the wrong module folder, now corrected. --- .../Modules/Searches/Commands/Models/PokeStats.cs | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 src/NadekoBot/Modules/Searches/Commands/Models/PokeStats.cs diff --git a/src/NadekoBot/Modules/Searches/Commands/Models/PokeStats.cs b/src/NadekoBot/Modules/Searches/Commands/Models/PokeStats.cs deleted file mode 100644 index b9795043..00000000 --- a/src/NadekoBot/Modules/Searches/Commands/Models/PokeStats.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; - -namespace NadekoBot.Modules.Pokemon -{ - class PokeStats - { - //Health left - public int Hp { get; set; } = 500; - public int MaxHp { get; } = 500; - //Amount of moves made since last time attacked - public int MovesMade { get; set; } = 0; - //Last people attacked - public List LastAttacked { get; set; } = new List(); - } -} From 21b2f1252a7c6f1b557394cedc65b872fa250f77 Mon Sep 17 00:00:00 2001 From: Pg Date: Sun, 27 Nov 2016 03:51:10 +0100 Subject: [PATCH 10/37] PokeGame work, initialisation of database unstable, need to do with sql-request --- .../Modules/Pokemon/PokemonModule.cs | 563 +++++++++--------- src/NadekoBot/Modules/Pokemon/PokemonType.cs | 33 + .../Services/Database/IUnitOfWork.cs | 1 + .../Services/Database/Models/PokeType.cs | 2 +- .../Services/Database/NadekoContext.cs | 16 +- .../Repositories/IPokeGameRepository.cs | 10 + .../Repositories/Impl/PokeGameRepository.cs | 23 + src/NadekoBot/Services/Database/UnitOfWork.cs | 3 + 8 files changed, 374 insertions(+), 277 deletions(-) create mode 100644 src/NadekoBot/Modules/Pokemon/PokemonType.cs create mode 100644 src/NadekoBot/Services/Database/Repositories/IPokeGameRepository.cs create mode 100644 src/NadekoBot/Services/Database/Repositories/Impl/PokeGameRepository.cs diff --git a/src/NadekoBot/Modules/Pokemon/PokemonModule.cs b/src/NadekoBot/Modules/Pokemon/PokemonModule.cs index fe13d795..1aacbd55 100644 --- a/src/NadekoBot/Modules/Pokemon/PokemonModule.cs +++ b/src/NadekoBot/Modules/Pokemon/PokemonModule.cs @@ -1,17 +1,17 @@ -using Discord; using Discord.Commands; using NadekoBot.Attributes; using NadekoBot.Extensions; using System.Linq; -using System.Text; -using System.Threading.Tasks; using NadekoBot.Services; -using Discord.WebSocket; using NadekoBot.Services.Database.Models; using System.Collections.Generic; +using System.Threading.Tasks; +using Discord; +using NLog; +using System; +using Newtonsoft.Json; +using System.IO; using System.Collections.Concurrent; -using System.Linq; - namespace NadekoBot.Modules.Pokemon { @@ -23,30 +23,27 @@ namespace NadekoBot.Modules.Pokemon public static string CurrencyPluralName { get; set; } public static string CurrencySign { get; set; } - public Gambling(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client) - { - using (var uow = DbHandler.UnitOfWork()) - { - var conf = uow.BotConfig.GetOrCreate(); + private static List PokemonTypes = new List(); + private static ConcurrentDictionary Stats = new ConcurrentDictionary(); + + public const string PokemonTypesFile = "data/pokemon_types.json"; - CurrencyName = conf.CurrencyName; - CurrencySign = conf.CurrencySign; - CurrencyPluralName = conf.CurrencyPluralName; + private Logger _pokelog { get; } + + public PokemonModule(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client) + { + _pokelog = LogManager.GetCurrentClassLogger(); + if (File.Exists(PokemonTypesFile)) + { + PokemonTypes = JsonConvert.DeserializeObject>(File.ReadAllText(PokemonTypesFile)); + } + else + { + _pokelog.Warn(PokemonTypesFile + " is missing. Pokemon types not loaded."); } } - class PokemonModule : DiscordModule - { - public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Pokemon; - - private ConcurrentDictionary Stats = new ConcurrentDictionary(); - - public PokemonModule() - { - - } - private int GetDamage(PokemonType usertype, PokemonType targetType) { var rng = new Random(); @@ -62,21 +59,26 @@ namespace NadekoBot.Modules.Pokemon return damage; } + private PokemonType GetPokeType(ulong id) { - var db = DbHandler.Instance.GetAllRows(); - Dictionary setTypes = db.ToDictionary(x => x.UserId, y => y.type); + Dictionary setTypes; + using (var uow = DbHandler.UnitOfWork()) + { + setTypes = uow.PokeGame.GetAll().ToDictionary(x => x.UserId, y => y.type); + } + if (setTypes.ContainsKey((long)id)) { return stringToPokemonType(setTypes[(long)id]); } - int count = NadekoBot.Config.PokemonTypes.Count; + int count = PokemonTypes.Count; int remainder = Math.Abs((int)(id % (ulong)count)); - return NadekoBot.Config.PokemonTypes[remainder]; + return PokemonTypes[remainder]; } @@ -84,7 +86,7 @@ namespace NadekoBot.Modules.Pokemon private PokemonType stringToPokemonType(string v) { var str = v.ToUpperInvariant(); - var list = NadekoBot.Config.PokemonTypes; + var list = PokemonTypes; foreach (PokemonType p in list) { if (str == p.Name) @@ -95,266 +97,279 @@ namespace NadekoBot.Modules.Pokemon return null; } - public override void Install(ModuleManager manager) + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task Attack(IUserMessage umsg, string move, IGuildUser targetUser = null) { - manager.CreateCommands("", cgb => + var channel = (ITextChannel)umsg.Channel; + IGuildUser user = (IGuildUser)umsg.Author; + + if (string.IsNullOrWhiteSpace(move)) { + return; + } + + if (targetUser == null) { - cgb.AddCheck(PermissionChecker.Instance); + await channel.SendMessageAsync("No such person.").ConfigureAwait(false); + return; + } + else if (targetUser == user) + { + await channel.SendMessageAsync("You can't attack yourself.").ConfigureAwait(false); + return; + } - commands.ForEach(cmd => cmd.Init(cgb)); + + // Checking stats first, then move + //Set up the userstats + PokeStats userStats; + userStats = Stats.GetOrAdd(user.Id, new PokeStats()); - cgb.CreateCommand(Prefix + "attack") - .Description($"Attacks a target with the given move. Use `{Prefix}movelist` to see a list of moves your type can use. | `{Prefix}attack \"vine whip\" @someguy`") - .Parameter("move", ParameterType.Required) - .Parameter("target", ParameterType.Unparsed) - .Do(async e => - { - var move = e.GetArg("move"); - var targetStr = e.GetArg("target")?.Trim(); - if (string.IsNullOrWhiteSpace(targetStr)) - return; - var target = e.Server.FindUsers(targetStr).FirstOrDefault(); - if (target == null) - { - await e.Channel.SendMessage("No such person.").ConfigureAwait(false); - return; - } - else if (target == e.User) - { - await e.Channel.SendMessage("You can't attack yourself.").ConfigureAwait(false); - return; - } - // Checking stats first, then move - //Set up the userstats - PokeStats userStats; - userStats = Stats.GetOrAdd(e.User.Id, new PokeStats()); + //Check if able to move + //User not able if HP < 0, has made more than 4 attacks + if (userStats.Hp < 0) + { + await channel.SendMessageAsync($"{user.Mention} has fainted and was not able to move!").ConfigureAwait(false); + return; + } + if (userStats.MovesMade >= 5) + { + await channel.SendMessageAsync($"{user.Mention} has used too many moves in a row and was not able to move!").ConfigureAwait(false); + return; + } + if (userStats.LastAttacked.Contains(targetUser.Id)) + { + await channel.SendMessageAsync($"{user.Mention} can't attack again without retaliation!").ConfigureAwait(false); + return; + } + //get target stats + PokeStats targetStats; + targetStats = Stats.GetOrAdd(targetUser.Id, new PokeStats()); - //Check if able to move - //User not able if HP < 0, has made more than 4 attacks - if (userStats.Hp < 0) - { - await e.Channel.SendMessage($"{e.User.Mention} has fainted and was not able to move!").ConfigureAwait(false); - return; - } - if (userStats.MovesMade >= 5) - { - await e.Channel.SendMessage($"{e.User.Mention} has used too many moves in a row and was not able to move!").ConfigureAwait(false); - return; - } - if (userStats.LastAttacked.Contains(target.Id)) - { - await e.Channel.SendMessage($"{e.User.Mention} can't attack again without retaliation!").ConfigureAwait(false); - return; - } - //get target stats - PokeStats targetStats; - targetStats = Stats.GetOrAdd(target.Id, new PokeStats()); + //If target's HP is below 0, no use attacking + if (targetStats.Hp <= 0) + { + await channel.SendMessageAsync($"{targetUser.Mention} has already fainted!").ConfigureAwait(false); + return; + } - //If target's HP is below 0, no use attacking - if (targetStats.Hp <= 0) - { - await e.Channel.SendMessage($"{target.Mention} has already fainted!").ConfigureAwait(false); - return; - } + //Check whether move can be used + PokemonType userType = GetPokeType(user.Id); - //Check whether move can be used - PokemonType userType = GetPokeType(e.User.Id); + var enabledMoves = userType.Moves; + if (!enabledMoves.Contains(move.ToLowerInvariant())) + { + await channel.SendMessageAsync($"{user.Mention} is not able to use **{move}**. Type {NadekoBot.ModulePrefixes[typeof(PokemonModule).Name]}ml to see moves").ConfigureAwait(false); + return; + } - var enabledMoves = userType.Moves; - if (!enabledMoves.Contains(move.ToLowerInvariant())) - { - await e.Channel.SendMessage($"{e.User.Mention} was not able to use **{move}**, use `{Prefix}ml` to see moves you can use").ConfigureAwait(false); - return; - } + //get target type + PokemonType targetType = GetPokeType(targetUser.Id); + //generate damage + int damage = GetDamage(userType, targetType); + //apply damage to target + targetStats.Hp -= damage; - //get target type - PokemonType targetType = GetPokeType(target.Id); - //generate damage - int damage = GetDamage(userType, targetType); - //apply damage to target - targetStats.Hp -= damage; + var response = $"{user.Mention} used **{move}**{userType.Icon} on {targetUser.Mention}{targetType.Icon} for **{damage}** damage"; - var response = $"{e.User.Mention} used **{move}**{userType.Icon} on {target.Mention}{targetType.Icon} for **{damage}** damage"; + //Damage type + if (damage < 40) + { + response += "\nIt's not effective.."; + } + else if (damage > 60) + { + response += "\nIt's super effective!"; + } + else + { + response += "\nIt's somewhat effective"; + } - //Damage type - if (damage < 40) - { - response += "\nIt's not effective.."; - } - else if (damage > 60) - { - response += "\nIt's super effective!"; - } - else - { - response += "\nIt's somewhat effective"; - } + //check fainted - //check fainted + if (targetStats.Hp <= 0) + { + response += $"\n**{targetUser.Username}** has fainted!"; + } + else + { + response += $"\n**{targetUser.Username}** has {targetStats.Hp} HP remaining"; + } - if (targetStats.Hp <= 0) - { - response += $"\n**{target.Name}** has fainted!"; - } - else - { - response += $"\n**{target.Name}** has {targetStats.Hp} HP remaining"; - } + //update other stats + userStats.LastAttacked.Add(targetUser.Id); + userStats.MovesMade++; + targetStats.MovesMade = 0; + if (targetStats.LastAttacked.Contains(user.Id)) + { + targetStats.LastAttacked.Remove(user.Id); + } - //update other stats - userStats.LastAttacked.Add(target.Id); - userStats.MovesMade++; - targetStats.MovesMade = 0; - if (targetStats.LastAttacked.Contains(e.User.Id)) - { - targetStats.LastAttacked.Remove(e.User.Id); - } + //update dictionary + //This can stay the same right? + Stats[user.Id] = userStats; + Stats[targetUser.Id] = targetStats; - //update dictionary - //This can stay the same right? - Stats[e.User.Id] = userStats; - Stats[target.Id] = targetStats; - - await e.Channel.SendMessage(response).ConfigureAwait(false); - }); - - cgb.CreateCommand(Prefix + "movelist") - .Alias(Prefix + "ml") - .Description($"Lists the moves you are able to use | `{Prefix}ml`") - .Do(async e => - { - var userType = GetPokeType(e.User.Id); - var movesList = userType.Moves; - var str = $"**Moves for `{userType.Name}` type.**"; - foreach (string m in movesList) - { - str += $"\n{userType.Icon}{m}"; - } - await e.Channel.SendMessage(str).ConfigureAwait(false); - }); - - cgb.CreateCommand(Prefix + "heal") - .Description($"Heals someone. Revives those who fainted. Costs a {NadekoBot.Config.CurrencyName} | `{Prefix}heal @someone`") - .Parameter("target", ParameterType.Unparsed) - .Do(async e => - { - var targetStr = e.GetArg("target")?.Trim(); - if (string.IsNullOrWhiteSpace(targetStr)) - return; - var usr = e.Server.FindUsers(targetStr).FirstOrDefault(); - if (usr == null) - { - await e.Channel.SendMessage("No such person.").ConfigureAwait(false); - return; - } - if (Stats.ContainsKey(usr.Id)) - { - - var targetStats = Stats[usr.Id]; - int HP = targetStats.Hp; - if (targetStats.Hp == targetStats.MaxHp) - { - await e.Channel.SendMessage($"{usr.Name} already has full HP!").ConfigureAwait(false); - return; - } - //Payment~ - var amount = 1; - var pts = Classes.DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0; - if (pts < amount) - { - await e.Channel.SendMessage($"{e.User.Mention} you don't have enough {NadekoBot.Config.CurrencyName}s! \nYou still need {amount - pts} {NadekoBot.Config.CurrencySign} to be able to do this!").ConfigureAwait(false); - return; - } - var target = (usr.Id == e.User.Id) ? "yourself" : usr.Name; - await FlowersHandler.RemoveFlowers(e.User, $"Poke-Heal {target}", amount).ConfigureAwait(false); - //healing - targetStats.Hp = targetStats.MaxHp; - if (HP < 0) - { - //Could heal only for half HP? - Stats[usr.Id].Hp = (targetStats.MaxHp / 2); - await e.Channel.SendMessage($"{e.User.Name} revived {usr.Name} with one {NadekoBot.Config.CurrencySign}").ConfigureAwait(false); - return; - } - var vowelFirst = new[] { 'a', 'e', 'i', 'o', 'u' }.Contains(NadekoBot.Config.CurrencyName[0]); - await e.Channel.SendMessage($"{e.User.Name} healed {usr.Name} for {targetStats.MaxHp - HP} HP with {(vowelFirst ? "an" : "a")} {NadekoBot.Config.CurrencySign}").ConfigureAwait(false); - return; - } - else - { - await e.Channel.SendMessage($"{usr.Name} already has full HP!").ConfigureAwait(false); - } - }); - - cgb.CreateCommand(Prefix + "type") - .Description($"Get the poketype of the target. | `{Prefix}type @someone`") - .Parameter("target", ParameterType.Unparsed) - .Do(async e => - { - var usrStr = e.GetArg("target")?.Trim(); - if (string.IsNullOrWhiteSpace(usrStr)) - return; - var usr = e.Server.FindUsers(usrStr).FirstOrDefault(); - if (usr == null) - { - await e.Channel.SendMessage("No such person.").ConfigureAwait(false); - return; - } - var pType = GetPokeType(usr.Id); - await e.Channel.SendMessage($"Type of {usr.Name} is **{pType.Name.ToLowerInvariant()}**{pType.Icon}").ConfigureAwait(false); - - }); - - cgb.CreateCommand(Prefix + "settype") - .Description($"Set your poketype. Costs a {NadekoBot.Config.CurrencyName}. | `{Prefix}settype fire`") - .Parameter("targetType", ParameterType.Unparsed) - .Do(async e => - { - var targetTypeStr = e.GetArg("targetType")?.ToUpperInvariant(); - if (string.IsNullOrWhiteSpace(targetTypeStr)) - return; - var targetType = stringToPokemonType(targetTypeStr); - if (targetType == null) - { - await e.Channel.SendMessage("Invalid type specified. Type must be one of:\n" + string.Join(", ", NadekoBot.Config.PokemonTypes.Select(t => t.Name.ToUpperInvariant()))).ConfigureAwait(false); - return; - } - if (targetType == GetPokeType(e.User.Id)) - { - await e.Channel.SendMessage($"Your type is already {targetType.Name.ToLowerInvariant()}{targetType.Icon}").ConfigureAwait(false); - return; - } - - //Payment~ - var amount = 1; - var pts = DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0; - if (pts < amount) - { - await e.Channel.SendMessage($"{e.User.Mention} you don't have enough {NadekoBot.Config.CurrencyName}s! \nYou still need {amount - pts} {NadekoBot.Config.CurrencySign} to be able to do this!").ConfigureAwait(false); - return; - } - await FlowersHandler.RemoveFlowers(e.User, $"set usertype to {targetTypeStr}", amount).ConfigureAwait(false); - //Actually changing the type here - var preTypes = DbHandler.Instance.GetAllRows(); - Dictionary Dict = preTypes.ToDictionary(x => x.UserId, y => y.Id.Value); - if (Dict.ContainsKey((long)e.User.Id)) - { - //delete previous type - DbHandler.Instance.Delete(Dict[(long)e.User.Id]); - } - - DbHandler.Instance.Connection.Insert(new UserPokeTypes - { - UserId = (long)e.User.Id, - type = targetType.Name - }, typeof(UserPokeTypes)); - - //Now for the response - - await e.Channel.SendMessage($"Set type of {e.User.Mention} to {targetTypeStr}{targetType.Icon} for a {NadekoBot.Config.CurrencySign}").ConfigureAwait(false); - }); - }); + await channel.SendMessageAsync(response).ConfigureAwait(false); } + + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task Movelist(IUserMessage umsg) + { + var channel = (ITextChannel)umsg.Channel; + IGuildUser user = (IGuildUser)umsg.Author; + + var userType = GetPokeType(user.Id); + var movesList = userType.Moves; + var str = $"**Moves for `{userType.Name}` type.**"; + foreach (string m in movesList) + { + str += $"\n{userType.Icon}{m}"; + } + await channel.SendMessageAsync(str).ConfigureAwait(false); + } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task Heal(IUserMessage umsg, IGuildUser targetUser = null) + { + var channel = (ITextChannel)umsg.Channel; + IGuildUser user = (IGuildUser)umsg.Author; + + if (targetUser == null) { + await channel.SendMessageAsync("No such person.").ConfigureAwait(false); + return; + } + + if (Stats.ContainsKey(targetUser.Id)) + { + var targetStats = Stats[targetUser.Id]; + if (targetStats.Hp == targetStats.MaxHp) + { + await channel.SendMessageAsync($"{targetUser.Username} already has full HP!").ConfigureAwait(false); + return; + } + //Payment~ + var amount = 1; + + var target = (targetUser.Id == user.Id) ? "yourself" : targetUser.Username; + if (amount > 0) + { + if (!await CurrencyHandler.RemoveCurrencyAsync(user, $"Poke-Heal {target}", amount, true).ConfigureAwait(false)) + { + try { await channel.SendMessageAsync($"{user.Mention} You don't have enough {CurrencyName}s.").ConfigureAwait(false); } catch { } + return; + } + } + + //healing + targetStats.Hp = targetStats.MaxHp; + if (targetStats.Hp < 0) + { + //Could heal only for half HP? + Stats[targetUser.Id].Hp = (targetStats.MaxHp / 2); + if (target == "yourself") + { + await channel.SendMessageAsync($"You revived yourself with one {CurrencySign}").ConfigureAwait(false); + } + else + { + await channel.SendMessageAsync($"{user.Username} revived {targetUser.Username} with one {CurrencySign}").ConfigureAwait(false); + } + return; + } + await channel.SendMessageAsync($"{user.Username} healed {targetUser.Username} with one {CurrencySign}").ConfigureAwait(false); + return; + } + else + { + await channel.SendMessageAsync($"{targetUser.Username} already has full HP!").ConfigureAwait(false); + } + } + + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task Type(IUserMessage umsg, IGuildUser targetUser = null) + { + var channel = (ITextChannel)umsg.Channel; + IGuildUser user = (IGuildUser)umsg.Author; + + if (targetUser == null) + { + await channel.SendMessageAsync("No such person.").ConfigureAwait(false); + return; + } + + var pType = GetPokeType(targetUser.Id); + await channel.SendMessageAsync($"Type of {targetUser.Username} is **{pType.Name.ToLowerInvariant()}**{pType.Icon}").ConfigureAwait(false); + + } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task Settype(IUserMessage umsg, [Remainder] string typeTargeted = null) + { + var channel = (ITextChannel)umsg.Channel; + IGuildUser user = (IGuildUser)umsg.Author; + + if (string.IsNullOrWhiteSpace(typeTargeted)) + return; + var targetType = stringToPokemonType(typeTargeted); + if (targetType == null) + { + await channel.SendMessageAsync("Invalid type specified. Type must be one of:\n" + string.Join(", ", PokemonTypes.Select(t => t.Name.ToUpperInvariant()))).ConfigureAwait(false); + return; + } + if (targetType == GetPokeType(user.Id)) + { + await channel.SendMessageAsync($"Your type is already {targetType.Name.ToLowerInvariant()}{targetType.Icon}").ConfigureAwait(false); + return; + } + + //Payment~ + var amount = 1; + if (amount > 0) + { + if (!await CurrencyHandler.RemoveCurrencyAsync(user, $"{user.Username} change type to {typeTargeted}", amount, true).ConfigureAwait(false)) + { + try { await channel.SendMessageAsync($"{user.Mention} You don't have enough {CurrencyName}s.").ConfigureAwait(false); } catch { } + return; + } + } + + //Actually changing the type here + Dictionary setTypes; + + using (var uow = DbHandler.UnitOfWork()) + { + setTypes = uow.PokeGame.GetAll().ToDictionary(x => x.UserId, y => y.type); + var pt = new UserPokeTypes + { + UserId = (long)user.Id, + type = targetType.Name, + }; + if (!setTypes.ContainsKey((long)user.Id)) + { + //create user in db + uow.PokeGame.Add(pt); + } + else + { + //update user in db + uow.PokeGame.Update(pt); + } + await uow.CompleteAsync(); + } + + //Now for the response + await channel.SendMessageAsync($"Set type of {user.Mention} to {typeTargeted}{targetType.Icon} for a {CurrencySign}").ConfigureAwait(false); + } + } } diff --git a/src/NadekoBot/Modules/Pokemon/PokemonType.cs b/src/NadekoBot/Modules/Pokemon/PokemonType.cs new file mode 100644 index 00000000..d4cf9007 --- /dev/null +++ b/src/NadekoBot/Modules/Pokemon/PokemonType.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NadekoBot.Modules.Pokemon +{ + public class PokemonType + { + public PokemonType(string n, string i, string[] m, List multi) + { + Name = n; + Icon = i; + Moves = m; + Multipliers = multi; + } + public string Name { get; set; } + public List Multipliers { get; set; } + public string Icon { get; set; } + public string[] Moves { get; set; } + } + public class PokemonMultiplier + { + public PokemonMultiplier(string t, double m) + { + Type = t; + Multiplication = m; + } + public string Type { get; set; } + public double Multiplication { get; set; } + } +} diff --git a/src/NadekoBot/Services/Database/IUnitOfWork.cs b/src/NadekoBot/Services/Database/IUnitOfWork.cs index 66359ef2..c90d9736 100644 --- a/src/NadekoBot/Services/Database/IUnitOfWork.cs +++ b/src/NadekoBot/Services/Database/IUnitOfWork.cs @@ -21,6 +21,7 @@ namespace NadekoBot.Services.Database ICurrencyRepository Currency { get; } ICurrencyTransactionsRepository CurrencyTransactions { get; } IMusicPlaylistRepository MusicPlaylists { get; } + IPokeGameRepository PokeGame { get; } int Complete(); Task CompleteAsync(); diff --git a/src/NadekoBot/Services/Database/Models/PokeType.cs b/src/NadekoBot/Services/Database/Models/PokeType.cs index 9187226a..f9440350 100644 --- a/src/NadekoBot/Services/Database/Models/PokeType.cs +++ b/src/NadekoBot/Services/Database/Models/PokeType.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace NadekoBot.Services.Database.Models { - class UserPokeTypes : DbEntity + public class UserPokeTypes : DbEntity { public long UserId { get; set; } public string type { get; set; } diff --git a/src/NadekoBot/Services/Database/NadekoContext.cs b/src/NadekoBot/Services/Database/NadekoContext.cs index da16e598..768c4dd0 100644 --- a/src/NadekoBot/Services/Database/NadekoContext.cs +++ b/src/NadekoBot/Services/Database/NadekoContext.cs @@ -22,6 +22,7 @@ namespace NadekoBot.Services.Database public DbSet MusicPlaylists { get; set; } public DbSet CustomReactions { get; set; } public DbSet CurrencyTransactions { get; set; } + public DbSet PokeGame { get; set; } //logging public DbSet LogSettings { get; set; } @@ -69,7 +70,8 @@ namespace NadekoBot.Services.Database new ModulePrefix() { ModuleName = "Permissions", Prefix = ";" }, new ModulePrefix() { ModuleName = "Pokemon", Prefix = ">" }, new ModulePrefix() { ModuleName = "Utility", Prefix = "." }, - new ModulePrefix() { ModuleName = "CustomReactions", Prefix = "." } + new ModulePrefix() { ModuleName = "CustomReactions", Prefix = "." }, + new ModulePrefix() { ModuleName = "PokeGame", Prefix = ">" } }); bc.RaceAnimals.AddRange(new HashSet { @@ -216,7 +218,17 @@ namespace NadekoBot.Services.Database .HasMany(p => p.Songs) .WithOne() .OnDelete(Microsoft.EntityFrameworkCore.Metadata.DeleteBehavior.Cascade); - + + + #endregion + + #region PokeGame + var pokeGameEntity = modelBuilder.Entity(); + + pokeGameEntity + .HasIndex(pt => pt.UserId) + .IsUnique(); + #endregion } diff --git a/src/NadekoBot/Services/Database/Repositories/IPokeGameRepository.cs b/src/NadekoBot/Services/Database/Repositories/IPokeGameRepository.cs new file mode 100644 index 00000000..ca698422 --- /dev/null +++ b/src/NadekoBot/Services/Database/Repositories/IPokeGameRepository.cs @@ -0,0 +1,10 @@ +using NadekoBot.Services.Database.Models; +using System.Collections.Generic; + +namespace NadekoBot.Services.Database.Repositories +{ + public interface IPokeGameRepository : IRepository + { + //List GetAllPokeTypes(); + } +} diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/PokeGameRepository.cs b/src/NadekoBot/Services/Database/Repositories/Impl/PokeGameRepository.cs new file mode 100644 index 00000000..f23f17ca --- /dev/null +++ b/src/NadekoBot/Services/Database/Repositories/Impl/PokeGameRepository.cs @@ -0,0 +1,23 @@ +using NadekoBot.Services.Database.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.EntityFrameworkCore; + +namespace NadekoBot.Services.Database.Repositories.Impl +{ + public class PokeGameRepository : Repository, IPokeGameRepository + { + public PokeGameRepository(DbContext context) : base(context) + { + + } + + //List GetAllPokeTypes() + //{ + // var toReturn = _set.Include(pt => pt.UserId).ToList(); + // toReturn.ForEach(pt => pt.).ToList(); + // return toReturn; + //} + } +} diff --git a/src/NadekoBot/Services/Database/UnitOfWork.cs b/src/NadekoBot/Services/Database/UnitOfWork.cs index 7ba343ee..9601145d 100644 --- a/src/NadekoBot/Services/Database/UnitOfWork.cs +++ b/src/NadekoBot/Services/Database/UnitOfWork.cs @@ -48,6 +48,9 @@ namespace NadekoBot.Services.Database private ICustomReactionRepository _customReactions; public ICustomReactionRepository CustomReactions => _customReactions ?? (_customReactions = new CustomReactionsRepository(_context)); + private IPokeGameRepository _pokegame; + public IPokeGameRepository PokeGame => _pokegame ?? (_pokegame = new PokeGameRepository(_context)); + public UnitOfWork(NadekoContext context) { _context = context; From 90c80c7bd90a0bb8db32aef722069582306b10bf Mon Sep 17 00:00:00 2001 From: Pg Date: Mon, 28 Nov 2016 02:14:29 +0100 Subject: [PATCH 11/37] Fix database creation Add the Table PokeGame to the database initialisation --- .../20161127233843_PokeGame.Designer.cs | 802 ++++++++++++++++++ .../Migrations/20161127233843_PokeGame.cs | 38 + .../NadekoSqliteContextModelSnapshot.cs | 17 + .../Services/Database/NadekoContext.cs | 1 + 4 files changed, 858 insertions(+) create mode 100644 src/NadekoBot/Migrations/20161127233843_PokeGame.Designer.cs create mode 100644 src/NadekoBot/Migrations/20161127233843_PokeGame.cs diff --git a/src/NadekoBot/Migrations/20161127233843_PokeGame.Designer.cs b/src/NadekoBot/Migrations/20161127233843_PokeGame.Designer.cs new file mode 100644 index 00000000..47f998c4 --- /dev/null +++ b/src/NadekoBot/Migrations/20161127233843_PokeGame.Designer.cs @@ -0,0 +1,802 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using NadekoBot.Services.Database; +using NadekoBot.Services.Database.Models; +using NadekoBot.Modules.Music.Classes; + +namespace NadekoBot.Migrations +{ + [DbContext(typeof(NadekoContext))] + [Migration("20161127233843_PokeGame")] + partial class PokeGame + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.1.0-rtm-22752"); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.BlacklistItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("ItemId"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("BlacklistItem"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.BotConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BufferSize"); + + b.Property("CurrencyGenerationChance"); + + b.Property("CurrencyGenerationCooldown"); + + b.Property("CurrencyName"); + + b.Property("CurrencyPluralName"); + + b.Property("CurrencySign"); + + b.Property("DMHelpString"); + + b.Property("ForwardMessages"); + + b.Property("ForwardToAllOwners"); + + b.Property("HelpString"); + + b.Property("MigrationVersion"); + + b.Property("RemindMessageFormat"); + + b.Property("RotatingStatuses"); + + b.HasKey("Id"); + + b.ToTable("BotConfig"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashCaller", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BaseDestroyed"); + + b.Property("CallUser"); + + b.Property("ClashWarId"); + + b.Property("SequenceNumber"); + + b.Property("Stars"); + + b.Property("TimeAdded"); + + b.HasKey("Id"); + + b.HasIndex("ClashWarId"); + + b.ToTable("ClashCallers"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashWar", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("EnemyClan"); + + b.Property("GuildId"); + + b.Property("Size"); + + b.Property("StartedAt"); + + b.Property("WarState"); + + b.HasKey("Id"); + + b.ToTable("ClashOfClans"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CommandCooldown", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CommandName"); + + b.Property("GuildConfigId"); + + b.Property("Seconds"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("CommandCooldown"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ConvertUnit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("InternalTrigger"); + + b.Property("Modifier"); + + b.Property("UnitType"); + + b.HasKey("Id"); + + b.ToTable("ConversionUnits"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Currency"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CurrencyTransaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("Reason"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.ToTable("CurrencyTransactions"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CustomReaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("GuildId"); + + b.Property("IsRegex"); + + b.Property("OwnerOnly"); + + b.Property("Response"); + + b.Property("Trigger"); + + b.HasKey("Id"); + + b.ToTable("CustomReactions"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Donator", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("Name"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Donators"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.EightBallResponse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("Text"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("EightBallResponses"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FilterChannelId", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("GuildConfigId"); + + b.Property("GuildConfigId1"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.HasIndex("GuildConfigId1"); + + b.ToTable("FilterChannelId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FilteredWord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("GuildConfigId"); + + b.Property("Word"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("FilteredWord"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FollowedStream", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("GuildConfigId"); + + b.Property("GuildId"); + + b.Property("Type"); + + b.Property("Username"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("FollowedStream"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.GCChannelId", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("GuildConfigId"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("GCChannelId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.GuildConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AutoAssignRoleId"); + + b.Property("AutoDeleteByeMessages"); + + b.Property("AutoDeleteByeMessagesTimer"); + + b.Property("AutoDeleteGreetMessages"); + + b.Property("AutoDeleteGreetMessagesTimer"); + + b.Property("AutoDeleteSelfAssignedRoleMessages"); + + b.Property("ByeMessageChannelId"); + + b.Property("ChannelByeMessageText"); + + b.Property("ChannelGreetMessageText"); + + b.Property("CleverbotEnabled"); + + b.Property("DefaultMusicVolume"); + + b.Property("DeleteMessageOnCommand"); + + b.Property("DmGreetMessageText"); + + b.Property("ExclusiveSelfAssignedRoles"); + + b.Property("FilterInvites"); + + b.Property("FilterWords"); + + b.Property("GreetMessageChannelId"); + + b.Property("GuildId"); + + b.Property("LogSettingId"); + + b.Property("MuteRoleName"); + + b.Property("PermissionRole"); + + b.Property("RootPermissionId"); + + b.Property("SendChannelByeMessage"); + + b.Property("SendChannelGreetMessage"); + + b.Property("SendDmGreetMessage"); + + b.Property("VerbosePermissions"); + + b.Property("VoicePlusTextEnabled"); + + b.HasKey("Id"); + + b.HasIndex("GuildId") + .IsUnique(); + + b.HasIndex("LogSettingId"); + + b.HasIndex("RootPermissionId"); + + b.ToTable("GuildConfigs"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredLogChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("LogSettingId"); + + b.HasKey("Id"); + + b.HasIndex("LogSettingId"); + + b.ToTable("IgnoredLogChannels"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredVoicePresenceChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("LogSettingId"); + + b.HasKey("Id"); + + b.HasIndex("LogSettingId"); + + b.ToTable("IgnoredVoicePresenceCHannels"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.LogSetting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelCreated"); + + b.Property("ChannelDestroyed"); + + b.Property("ChannelId"); + + b.Property("ChannelUpdated"); + + b.Property("IsLogging"); + + b.Property("LogUserPresence"); + + b.Property("LogVoicePresence"); + + b.Property("MessageDeleted"); + + b.Property("MessageUpdated"); + + b.Property("UserBanned"); + + b.Property("UserJoined"); + + b.Property("UserLeft"); + + b.Property("UserPresenceChannelId"); + + b.Property("UserUnbanned"); + + b.Property("UserUpdated"); + + b.Property("VoicePresenceChannelId"); + + b.HasKey("Id"); + + b.ToTable("LogSettings"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ModulePrefix", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("ModuleName"); + + b.Property("Prefix"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("ModulePrefixes"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.MusicPlaylist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Author"); + + b.Property("AuthorId"); + + b.Property("Name"); + + b.HasKey("Id"); + + b.ToTable("MusicPlaylists"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("NextId"); + + b.Property("PrimaryTarget"); + + b.Property("PrimaryTargetId"); + + b.Property("SecondaryTarget"); + + b.Property("SecondaryTargetName"); + + b.Property("State"); + + b.HasKey("Id"); + + b.HasIndex("NextId") + .IsUnique(); + + b.ToTable("Permission"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.PlayingStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("Status"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("PlayingStatus"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.PlaylistSong", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("MusicPlaylistId"); + + b.Property("Provider"); + + b.Property("ProviderType"); + + b.Property("Query"); + + b.Property("Title"); + + b.Property("Uri"); + + b.HasKey("Id"); + + b.HasIndex("MusicPlaylistId"); + + b.ToTable("PlaylistSong"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Quote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AuthorId"); + + b.Property("AuthorName") + .IsRequired(); + + b.Property("GuildId"); + + b.Property("Keyword") + .IsRequired(); + + b.Property("Text") + .IsRequired(); + + b.HasKey("Id"); + + b.ToTable("Quotes"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.RaceAnimal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("Icon"); + + b.Property("Name"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("RaceAnimals"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Reminder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("IsPrivate"); + + b.Property("Message"); + + b.Property("ServerId"); + + b.Property("UserId"); + + b.Property("When"); + + b.HasKey("Id"); + + b.ToTable("Reminders"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Repeater", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("GuildId"); + + b.Property("Interval"); + + b.Property("Message"); + + b.HasKey("Id"); + + b.HasIndex("ChannelId") + .IsUnique(); + + b.ToTable("Repeaters"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.SelfAssignedRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("GuildId"); + + b.Property("RoleId"); + + b.HasKey("Id"); + + b.HasIndex("GuildId", "RoleId") + .IsUnique(); + + b.ToTable("SelfAssignableRoles"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.UserPokeTypes", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("UserId"); + + b.Property("type"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("PokeGame"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.BlacklistItem", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("Blacklist") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashCaller", b => + { + b.HasOne("NadekoBot.Services.Database.Models.ClashWar", "ClashWar") + .WithMany("Bases") + .HasForeignKey("ClashWarId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CommandCooldown", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("CommandCooldowns") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.EightBallResponse", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("EightBallResponses") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FilterChannelId", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("FilterInvitesChannelIds") + .HasForeignKey("GuildConfigId"); + + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("FilterWordsChannelIds") + .HasForeignKey("GuildConfigId1"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FilteredWord", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("FilteredWords") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FollowedStream", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("FollowedStreams") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.GCChannelId", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("GenerateCurrencyChannelIds") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.GuildConfig", b => + { + b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") + .WithMany() + .HasForeignKey("LogSettingId"); + + b.HasOne("NadekoBot.Services.Database.Models.Permission", "RootPermission") + .WithMany() + .HasForeignKey("RootPermissionId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredLogChannel", b => + { + b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") + .WithMany("IgnoredChannels") + .HasForeignKey("LogSettingId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredVoicePresenceChannel", b => + { + b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") + .WithMany("IgnoredVoicePresenceChannelIds") + .HasForeignKey("LogSettingId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ModulePrefix", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("ModulePrefixes") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Permission", b => + { + b.HasOne("NadekoBot.Services.Database.Models.Permission", "Next") + .WithOne("Previous") + .HasForeignKey("NadekoBot.Services.Database.Models.Permission", "NextId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.PlayingStatus", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("RotatingStatusMessages") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.PlaylistSong", b => + { + b.HasOne("NadekoBot.Services.Database.Models.MusicPlaylist") + .WithMany("Songs") + .HasForeignKey("MusicPlaylistId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.RaceAnimal", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("RaceAnimals") + .HasForeignKey("BotConfigId"); + }); + } + } +} diff --git a/src/NadekoBot/Migrations/20161127233843_PokeGame.cs b/src/NadekoBot/Migrations/20161127233843_PokeGame.cs new file mode 100644 index 00000000..8ea9ffa9 --- /dev/null +++ b/src/NadekoBot/Migrations/20161127233843_PokeGame.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace NadekoBot.Migrations +{ + public partial class PokeGame : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "PokeGame", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true), + UserId = table.Column(nullable: false), + type = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_PokeGame", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_PokeGame_UserId", + table: "PokeGame", + column: "UserId", + unique: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "PokeGame"); + } + } +} diff --git a/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs b/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs index dd4b8543..d209fb74 100644 --- a/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs +++ b/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs @@ -658,6 +658,23 @@ namespace NadekoBot.Migrations b.ToTable("SelfAssignableRoles"); }); + modelBuilder.Entity("NadekoBot.Services.Database.Models.UserPokeTypes", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("UserId"); + + b.Property("type"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("PokeGame"); + }); + modelBuilder.Entity("NadekoBot.Services.Database.Models.BlacklistItem", b => { b.HasOne("NadekoBot.Services.Database.Models.BotConfig") diff --git a/src/NadekoBot/Services/Database/NadekoContext.cs b/src/NadekoBot/Services/Database/NadekoContext.cs index 768c4dd0..6752343a 100644 --- a/src/NadekoBot/Services/Database/NadekoContext.cs +++ b/src/NadekoBot/Services/Database/NadekoContext.cs @@ -44,6 +44,7 @@ namespace NadekoBot.Services.Database this.Database.Migrate(); EnsureSeedData(); } + //Uncomment this to db initialisation with dotnet ef migration add [module] //protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) //{ // optionsBuilder.UseSqlite("Filename=./data/NadekoBot.db"); From 3fbd52d74bc1656176632e6bc8f8d4415bb66a62 Mon Sep 17 00:00:00 2001 From: Pg Date: Mon, 28 Nov 2016 02:15:08 +0100 Subject: [PATCH 12/37] Fix presenttation and change data connection --- .../Modules/Pokemon/PokemonModule.cs | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/NadekoBot/Modules/Pokemon/PokemonModule.cs b/src/NadekoBot/Modules/Pokemon/PokemonModule.cs index 1aacbd55..8418dee0 100644 --- a/src/NadekoBot/Modules/Pokemon/PokemonModule.cs +++ b/src/NadekoBot/Modules/Pokemon/PokemonModule.cs @@ -41,6 +41,15 @@ namespace NadekoBot.Modules.Pokemon { _pokelog.Warn(PokemonTypesFile + " is missing. Pokemon types not loaded."); } + + using (var uow = DbHandler.UnitOfWork()) + { + var conf = uow.BotConfig.GetOrCreate(); + + CurrencyName = conf.CurrencyName; + CurrencySign = conf.CurrencySign; + CurrencyPluralName = conf.CurrencyPluralName; + } } @@ -191,11 +200,11 @@ namespace NadekoBot.Modules.Pokemon if (targetStats.Hp <= 0) { - response += $"\n**{targetUser.Username}** has fainted!"; + response += $"\n**{targetUser.Nickname}** has fainted!"; } else { - response += $"\n**{targetUser.Username}** has {targetStats.Hp} HP remaining"; + response += $"\n**{targetUser.Nickname}** has {targetStats.Hp} HP remaining"; } //update other stats @@ -250,13 +259,13 @@ namespace NadekoBot.Modules.Pokemon var targetStats = Stats[targetUser.Id]; if (targetStats.Hp == targetStats.MaxHp) { - await channel.SendMessageAsync($"{targetUser.Username} already has full HP!").ConfigureAwait(false); + await channel.SendMessageAsync($"{targetUser.Nickname} already has full HP!").ConfigureAwait(false); return; } //Payment~ var amount = 1; - var target = (targetUser.Id == user.Id) ? "yourself" : targetUser.Username; + var target = (targetUser.Id == user.Id) ? "yourself" : targetUser.Nickname; if (amount > 0) { if (!await CurrencyHandler.RemoveCurrencyAsync(user, $"Poke-Heal {target}", amount, true).ConfigureAwait(false)) @@ -278,16 +287,16 @@ namespace NadekoBot.Modules.Pokemon } else { - await channel.SendMessageAsync($"{user.Username} revived {targetUser.Username} with one {CurrencySign}").ConfigureAwait(false); + await channel.SendMessageAsync($"{user.Nickname} revived {targetUser.Nickname} with one {CurrencySign}").ConfigureAwait(false); } return; } - await channel.SendMessageAsync($"{user.Username} healed {targetUser.Username} with one {CurrencySign}").ConfigureAwait(false); + await channel.SendMessageAsync($"{user.Nickname} healed {targetUser.Nickname} with one {CurrencySign}").ConfigureAwait(false); return; } else { - await channel.SendMessageAsync($"{targetUser.Username} already has full HP!").ConfigureAwait(false); + await channel.SendMessageAsync($"{targetUser.Nickname} already has full HP!").ConfigureAwait(false); } } @@ -301,12 +310,11 @@ namespace NadekoBot.Modules.Pokemon if (targetUser == null) { - await channel.SendMessageAsync("No such person.").ConfigureAwait(false); return; } var pType = GetPokeType(targetUser.Id); - await channel.SendMessageAsync($"Type of {targetUser.Username} is **{pType.Name.ToLowerInvariant()}**{pType.Icon}").ConfigureAwait(false); + await channel.SendMessageAsync($"Type of {targetUser.Nickname} is **{pType.Name.ToLowerInvariant()}**{pType.Icon}").ConfigureAwait(false); } @@ -335,7 +343,7 @@ namespace NadekoBot.Modules.Pokemon var amount = 1; if (amount > 0) { - if (!await CurrencyHandler.RemoveCurrencyAsync(user, $"{user.Username} change type to {typeTargeted}", amount, true).ConfigureAwait(false)) + if (!await CurrencyHandler.RemoveCurrencyAsync(user, $"{user.Nickname} change type to {typeTargeted}", amount, true).ConfigureAwait(false)) { try { await channel.SendMessageAsync($"{user.Mention} You don't have enough {CurrencyName}s.").ConfigureAwait(false); } catch { } return; @@ -347,7 +355,8 @@ namespace NadekoBot.Modules.Pokemon using (var uow = DbHandler.UnitOfWork()) { - setTypes = uow.PokeGame.GetAll().ToDictionary(x => x.UserId, y => y.type); + var pokeUsers = uow.PokeGame.GetAll(); + setTypes = pokeUsers.ToDictionary(x => x.UserId, y => y.type); var pt = new UserPokeTypes { UserId = (long)user.Id, @@ -361,7 +370,9 @@ namespace NadekoBot.Modules.Pokemon else { //update user in db - uow.PokeGame.Update(pt); + var pokeUserCmd = pokeUsers.Where(p => p.UserId == (long)user.Id).FirstOrDefault(); + pokeUserCmd.type = targetType.Name; + uow.PokeGame.Update(pokeUserCmd); } await uow.CompleteAsync(); } From e21767cc4ae233a63238b22554ded68e4393f03a Mon Sep 17 00:00:00 2001 From: Pg Date: Mon, 28 Nov 2016 02:28:53 +0100 Subject: [PATCH 13/37] Re-add the credential.json --- src/NadekoBot/credentials.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/NadekoBot/credentials.json diff --git a/src/NadekoBot/credentials.json b/src/NadekoBot/credentials.json new file mode 100644 index 00000000..31a9414f --- /dev/null +++ b/src/NadekoBot/credentials.json @@ -0,0 +1,15 @@ +{ + "ClientId": 123123123, + "BotId": null, + "Token": "", + "OwnerIds": [ + 0 + ], + "LoLApiKey": "", + "GoogleApiKey": "", + "MashapeKey": "", + "OsuApiKey": "", + "SoundCloudClientId": "", + "Db": null, + "TotalShards": 1 +} \ No newline at end of file From 8e3016602608be1051d529f07132b0d9a3d3ad51 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 4 Dec 2016 05:57:44 +0100 Subject: [PATCH 14/37] fixed .prune? --- discord.net | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord.net b/discord.net index 48b66d55..053db2e0 160000 --- a/discord.net +++ b/discord.net @@ -1 +1 @@ -Subproject commit 48b66d55f3f26f60fc001123ff6d7afeade3a51d +Subproject commit 053db2e02992ce967399f8a9f894aaa479ef568d From 240e242eaf39f91dda4abcf2be143bdfc329c7a1 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 4 Dec 2016 06:41:20 +0100 Subject: [PATCH 15/37] Updated discord.net to fix .prune --- discord.net | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord.net b/discord.net index 053db2e0..57fc8290 160000 --- a/discord.net +++ b/discord.net @@ -1 +1 @@ -Subproject commit 053db2e02992ce967399f8a9f894aaa479ef568d +Subproject commit 57fc8290666dba35b2385c97e3a51c493b40a425 From 149a9e49bc403c6deb414d675f3bf6d6f9127638 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 4 Dec 2016 04:54:10 -0500 Subject: [PATCH 16/37] await prune task of deleting messages There was an issue where it would sometimes delete once or twice or sometimes does not delete at all or would return 404 error --- src/NadekoBot/Modules/Administration/Administration.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Administration.cs b/src/NadekoBot/Modules/Administration/Administration.cs index b602c8b4..9634e698 100644 --- a/src/NadekoBot/Modules/Administration/Administration.cs +++ b/src/NadekoBot/Modules/Administration/Administration.cs @@ -643,7 +643,7 @@ namespace NadekoBot.Modules.Administration var enumerable = (await umsg.Channel.GetMessagesAsync()).AsEnumerable(); enumerable = enumerable.Where(x => x.Author.Id == user.Id); - await umsg.Channel.DeleteMessagesAsync(enumerable); + await umsg.Channel.DeleteMessagesAsync(enumerable).ConfigureAwait(false); } // prune x @@ -656,7 +656,7 @@ namespace NadekoBot.Modules.Administration await (msg as IUserMessage).DeleteAsync(); int limit = (count < 100) ? count : 100; var enumerable = (await msg.Channel.GetMessagesAsync(limit: limit)); - await msg.Channel.DeleteMessagesAsync(enumerable); + await msg.Channel.DeleteMessagesAsync(enumerable).ConfigureAwait(false); } //prune @user [x] @@ -668,7 +668,7 @@ namespace NadekoBot.Modules.Administration var channel = (ITextChannel)msg.Channel; int limit = (count < 100) ? count : 100; var enumerable = (await msg.Channel.GetMessagesAsync(limit: limit)).Where(m => m.Author == user); - await msg.Channel.DeleteMessagesAsync(enumerable); + await msg.Channel.DeleteMessagesAsync(enumerable).ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] From 06916f7ea2114556537d4d9a90b864c9055ba7c3 Mon Sep 17 00:00:00 2001 From: samvaio Date: Sun, 4 Dec 2016 20:55:22 +0530 Subject: [PATCH 17/37] Update Utility.cs --- src/NadekoBot/Modules/Utility/Utility.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 4e479ab8..4b27544b 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -176,47 +176,47 @@ namespace NadekoBot.Modules.Utility }, Fields = new[] { new EmbedField() { - Name = "Author", + Name = "**Author**", Value = stats.Author, Inline = true }, new EmbedField() { - Name = "Library", + Name = "**Library**", Value = stats.Library, Inline = true }, new EmbedField() { - Name = "Bot ID", + Name = "**Bot ID**", Value = NadekoBot.Client.GetCurrentUser().Id.ToString(), Inline = true }, new EmbedField() { - Name = "Commands Ran", + Name = "**Commands Ran**", Value = stats.CommandsRan.ToString(), Inline = true }, new EmbedField() { - Name = "Messages", + Name = "**Messages**", Value = $"{stats.MessageCounter} [{stats.MessagesPerSecond:F2}/sec]", Inline = true }, new EmbedField() { - Name = "Memory", + Name = "**Memory**", Value = $"{stats.Heap} MB", Inline = true }, new EmbedField() { - Name = "Owner ID(s)", + Name = "**Owner ID(s)**", Value = stats.OwnerIds, Inline = true }, new EmbedField() { - Name = "Uptime", + Name = "**Uptime**", Value = stats.GetUptimeString("\n"), Inline = true }, new EmbedField() { - Name = "Presence", + Name = "**Presence**", Value = $"{NadekoBot.Client.GetGuilds().Count} servers\n{stats.TextChannels} Text Channels\n{stats.VoiceChannels} Voice Channels", Inline = true }, From 1b6274919fe05acd0e727195c7b51c255feac10d Mon Sep 17 00:00:00 2001 From: samvaio Date: Sun, 4 Dec 2016 20:57:58 +0530 Subject: [PATCH 18/37] Update Searches.cs --- src/NadekoBot/Modules/Searches/Searches.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 904a7b1f..870f3805 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -44,15 +44,15 @@ namespace NadekoBot.Modules.Searches var obj = JObject.Parse(response)["weather"]; var embed = new EmbedBuilder() - .AddField(fb => fb.WithName("🌍 Location").WithValue($"{obj["target"]}").WithIsInline(true)) - .AddField(fb => fb.WithName("📏 Lat,Long").WithValue($"{obj["latitude"]}, {obj["longitude"]}").WithIsInline(true)) - .AddField(fb => fb.WithName("☁ Condition").WithValue($"{obj["condition"]}").WithIsInline(true)) - .AddField(fb => fb.WithName("😓 Humidity").WithValue($"{obj["humidity"]}%").WithIsInline(true)) - .AddField(fb => fb.WithName("💨 Wind Speed").WithValue($"{obj["windspeedk"]}km/h ({obj["windspeedm"]}mph)").WithIsInline(true)) - .AddField(fb => fb.WithName("🌡 Temperature").WithValue($"{obj["centigrade"]}°C ({obj["fahrenheit"]}°F)").WithIsInline(true)) - .AddField(fb => fb.WithName("🔆 Feels like").WithValue($"{obj["feelscentigrade"]}°C ({obj["feelsfahrenheit"]}°F)").WithIsInline(true)) - .AddField(fb => fb.WithName("🌄 Sunrise").WithValue($"{obj["sunrise"]}").WithIsInline(true)) - .AddField(fb => fb.WithName("🌇 Sunset").WithValue($"{obj["sunset"]}").WithIsInline(true)) + .AddField(fb => fb.WithName("🌍 **Location**").WithValue($"{obj["target"]}").WithIsInline(true)) + .AddField(fb => fb.WithName("📏 **Lat,Long**").WithValue($"{obj["latitude"]}, {obj["longitude"]}").WithIsInline(true)) + .AddField(fb => fb.WithName("☁ **Condition**").WithValue($"{obj["condition"]}").WithIsInline(true)) + .AddField(fb => fb.WithName("😓 **Humidity**").WithValue($"{obj["humidity"]}%").WithIsInline(true)) + .AddField(fb => fb.WithName("💨 **Wind Speed**").WithValue($"{obj["windspeedk"]}km/h ({obj["windspeedm"]}mph)").WithIsInline(true)) + .AddField(fb => fb.WithName("🌡 **Temperature**").WithValue($"{obj["centigrade"]}°C ({obj["fahrenheit"]}°F)").WithIsInline(true)) + .AddField(fb => fb.WithName("🔆 **Feels like**").WithValue($"{obj["feelscentigrade"]}°C ({obj["feelsfahrenheit"]}°F)").WithIsInline(true)) + .AddField(fb => fb.WithName("🌄 **Sunrise**").WithValue($"{obj["sunrise"]}").WithIsInline(true)) + .AddField(fb => fb.WithName("🌇 **Sunset**").WithValue($"{obj["sunset"]}").WithIsInline(true)) .WithColor(NadekoBot.OkColor); await channel.EmbedAsync(embed.Build()).ConfigureAwait(false); } From 37001dddbe89b8e75d4b1a1a920a8400d6164357 Mon Sep 17 00:00:00 2001 From: samvaio Date: Sun, 4 Dec 2016 21:03:19 +0530 Subject: [PATCH 19/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index 73f10f05..e7cc92b3 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -104,14 +104,15 @@ namespace NadekoBot.Modules.Help if (alias != null) str += $" / `{alias}`"; var embed = new EmbedBuilder() - .WithAuthor(eau => eau.WithName("Help") + .WithAuthor(eau => eau.WithName("Command") .WithUrl("http://nadekobot.readthedocs.io/en/latest/Commands%20List/") .WithIconUrl(NadekoBot.Client.GetCurrentUser().AvatarUrl)) + .WithDescription(str) //.WithTitle(str) //.WithDescription($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}") - .AddField(fb => fb.WithIndex(1).WithName("**Command**").WithValue(str).WithIsInline(true)) + //.AddField(fb => fb.WithIndex(1).WithName("**Command**").WithValue(str).WithIsInline(true)) .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(true)) - .AddField(fb => fb.WithIndex(3).WithName("Description").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(false)) + .AddField(fb => fb.WithIndex(3).WithName("**Description**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .WithColor(NadekoBot.OkColor); if (com != null) await channel.EmbedAsync(embed.Build()).ConfigureAwait(false); From 2d3662fa73d8e74b38ef59efc18ed3d48aafe8b5 Mon Sep 17 00:00:00 2001 From: samvaio Date: Sun, 4 Dec 2016 21:24:34 +0530 Subject: [PATCH 20/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index e7cc92b3..353e53c2 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -107,12 +107,12 @@ namespace NadekoBot.Modules.Help .WithAuthor(eau => eau.WithName("Command") .WithUrl("http://nadekobot.readthedocs.io/en/latest/Commands%20List/") .WithIconUrl(NadekoBot.Client.GetCurrentUser().AvatarUrl)) - .WithDescription(str) + //.WithDescription(str) //.WithTitle(str) //.WithDescription($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}") - //.AddField(fb => fb.WithIndex(1).WithName("**Command**").WithValue(str).WithIsInline(true)) - .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(true)) - .AddField(fb => fb.WithIndex(3).WithName("**Description**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) + .AddField(fb => fb.WithIndex(1).WithName("**(str)**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) + .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(false)) + //.AddField(fb => fb.WithIndex(3).WithName("**Description**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .WithColor(NadekoBot.OkColor); if (com != null) await channel.EmbedAsync(embed.Build()).ConfigureAwait(false); From 4b15d813e129c04481a1544486f5f5fe70d463ea Mon Sep 17 00:00:00 2001 From: samvaio Date: Sun, 4 Dec 2016 21:33:15 +0530 Subject: [PATCH 21/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index 353e53c2..d8cbe529 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -110,7 +110,7 @@ namespace NadekoBot.Modules.Help //.WithDescription(str) //.WithTitle(str) //.WithDescription($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}") - .AddField(fb => fb.WithIndex(1).WithName("**(str)**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) + .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(false)) //.AddField(fb => fb.WithIndex(3).WithName("**Description**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .WithColor(NadekoBot.OkColor); From 5b8285d21b8abe509797cd0ee7ff0eb78986915b Mon Sep 17 00:00:00 2001 From: samvaio Date: Sun, 4 Dec 2016 21:40:41 +0530 Subject: [PATCH 22/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index d8cbe529..dae63fe6 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -99,10 +99,10 @@ namespace NadekoBot.Modules.Help await channel.EmbedAsync(erro.Build()); return; } - var str = $"{com.Text}"; + var str = $"**{com.Text}**"; var alias = com.Aliases.Skip(1).FirstOrDefault(); if (alias != null) - str += $" / `{alias}`"; + str += $" / **`{alias}`**"; var embed = new EmbedBuilder() .WithAuthor(eau => eau.WithName("Command") .WithUrl("http://nadekobot.readthedocs.io/en/latest/Commands%20List/") From 9facdb27d710fab08b619988ced1625d1c2b329c Mon Sep 17 00:00:00 2001 From: samvaio Date: Sun, 4 Dec 2016 21:46:48 +0530 Subject: [PATCH 23/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index dae63fe6..a094f37b 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -99,18 +99,17 @@ namespace NadekoBot.Modules.Help await channel.EmbedAsync(erro.Build()); return; } - var str = $"**{com.Text}**"; + var str = $"**`{com.Text}`"; var alias = com.Aliases.Skip(1).FirstOrDefault(); if (alias != null) - str += $" / **`{alias}`**"; + str += $" / `{alias}`**"; var embed = new EmbedBuilder() .WithAuthor(eau => eau.WithName("Command") .WithUrl("http://nadekobot.readthedocs.io/en/latest/Commands%20List/") .WithIconUrl(NadekoBot.Client.GetCurrentUser().AvatarUrl)) - //.WithDescription(str) //.WithTitle(str) //.WithDescription($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}") - .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) + .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)} { GetCommandRequirements(com)}").WithIsInline(true)) .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(false)) //.AddField(fb => fb.WithIndex(3).WithName("**Description**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .WithColor(NadekoBot.OkColor); From 56ce2a00d9cbf9df91ada0a9008aff6dfbbd7fc0 Mon Sep 17 00:00:00 2001 From: samvaio Date: Sun, 4 Dec 2016 21:55:40 +0530 Subject: [PATCH 24/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index a094f37b..3f7e8129 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -109,7 +109,7 @@ namespace NadekoBot.Modules.Help .WithIconUrl(NadekoBot.Client.GetCurrentUser().AvatarUrl)) //.WithTitle(str) //.WithDescription($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}") - .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)} { GetCommandRequirements(com)}").WithIsInline(true)) + .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix, )}{ GetCommandRequirements(com)}").WithIsInline(true)) .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(false)) //.AddField(fb => fb.WithIndex(3).WithName("**Description**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .WithColor(NadekoBot.OkColor); From b0582ae6aa89f4fc6e6972437d33d1aef5daddaa Mon Sep 17 00:00:00 2001 From: samvaio Date: Sun, 4 Dec 2016 21:58:59 +0530 Subject: [PATCH 25/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index 3f7e8129..c9c6bb3c 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -109,7 +109,8 @@ namespace NadekoBot.Modules.Help .WithIconUrl(NadekoBot.Client.GetCurrentUser().AvatarUrl)) //.WithTitle(str) //.WithDescription($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}") - .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix, )}{ GetCommandRequirements(com)}").WithIsInline(true)) + .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)} + { GetCommandRequirements(com)}").WithIsInline(true)) .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(false)) //.AddField(fb => fb.WithIndex(3).WithName("**Description**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .WithColor(NadekoBot.OkColor); From 01f2d7776ab1115d23ec0d38bf076fb25829690a Mon Sep 17 00:00:00 2001 From: samvaio Date: Sun, 4 Dec 2016 22:03:59 +0530 Subject: [PATCH 26/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index c9c6bb3c..8abeb8a2 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -109,8 +109,7 @@ namespace NadekoBot.Modules.Help .WithIconUrl(NadekoBot.Client.GetCurrentUser().AvatarUrl)) //.WithTitle(str) //.WithDescription($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}") - .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)} - { GetCommandRequirements(com)}").WithIsInline(true)) + .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}\n{ GetCommandRequirements(com)}").WithIsInline(true)) .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(false)) //.AddField(fb => fb.WithIndex(3).WithName("**Description**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .WithColor(NadekoBot.OkColor); From fae62a2b9993aa2c73186f76213f2c34f6d29d20 Mon Sep 17 00:00:00 2001 From: samvaio Date: Sun, 4 Dec 2016 22:07:59 +0530 Subject: [PATCH 27/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index 8abeb8a2..1857b68a 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -109,7 +109,7 @@ namespace NadekoBot.Modules.Help .WithIconUrl(NadekoBot.Client.GetCurrentUser().AvatarUrl)) //.WithTitle(str) //.WithDescription($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}") - .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}\n{ GetCommandRequirements(com)}").WithIsInline(true)) + .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements( com)}").WithIsInline(true)) .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(false)) //.AddField(fb => fb.WithIndex(3).WithName("**Description**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .WithColor(NadekoBot.OkColor); From 39183f70d5565330497c39e769cf13000e839795 Mon Sep 17 00:00:00 2001 From: samvaio Date: Sun, 4 Dec 2016 22:11:11 +0530 Subject: [PATCH 28/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index 1857b68a..b8488a98 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -109,8 +109,8 @@ namespace NadekoBot.Modules.Help .WithIconUrl(NadekoBot.Client.GetCurrentUser().AvatarUrl)) //.WithTitle(str) //.WithDescription($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}") - .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements( com)}").WithIsInline(true)) - .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(false)) + .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(, com)}").WithIsInline(true)) + .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(true)) //.AddField(fb => fb.WithIndex(3).WithName("**Description**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .WithColor(NadekoBot.OkColor); if (com != null) From 218e2dbcb78bfaa416b5df57ff505b1c68d8fd9e Mon Sep 17 00:00:00 2001 From: samvaio Date: Sun, 4 Dec 2016 22:14:40 +0530 Subject: [PATCH 29/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index b8488a98..c8d2abb1 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -109,7 +109,7 @@ namespace NadekoBot.Modules.Help .WithIconUrl(NadekoBot.Client.GetCurrentUser().AvatarUrl)) //.WithTitle(str) //.WithDescription($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}") - .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(, com)}").WithIsInline(true)) + .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(true)) //.AddField(fb => fb.WithIndex(3).WithName("**Description**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .WithColor(NadekoBot.OkColor); From e4f2a82f9ad5f9ff64db516dd6a4e0a0b422d275 Mon Sep 17 00:00:00 2001 From: samvaio Date: Sun, 4 Dec 2016 23:07:56 +0530 Subject: [PATCH 30/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index c8d2abb1..b8ad983f 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -110,7 +110,7 @@ namespace NadekoBot.Modules.Help //.WithTitle(str) //.WithDescription($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}") .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) - .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(true)) + .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(false)) //.AddField(fb => fb.WithIndex(3).WithName("**Description**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .WithColor(NadekoBot.OkColor); if (com != null) From c1792db98dc56996770f498343a97fba3e863599 Mon Sep 17 00:00:00 2001 From: samvaio Date: Mon, 5 Dec 2016 00:05:44 +0530 Subject: [PATCH 31/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index b8ad983f..9de61d21 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -99,17 +99,17 @@ namespace NadekoBot.Modules.Help await channel.EmbedAsync(erro.Build()); return; } - var str = $"**`{com.Text}`"; + var str = $"**`{com.Text}`**"; var alias = com.Aliases.Skip(1).FirstOrDefault(); if (alias != null) - str += $" / `{alias}`**"; + str += $"** / `{alias}`**"; var embed = new EmbedBuilder() .WithAuthor(eau => eau.WithName("Command") .WithUrl("http://nadekobot.readthedocs.io/en/latest/Commands%20List/") .WithIconUrl(NadekoBot.Client.GetCurrentUser().AvatarUrl)) //.WithTitle(str) //.WithDescription($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}") - .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) + .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)} **|** { GetCommandRequirements(com)}").WithIsInline(true)) .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(false)) //.AddField(fb => fb.WithIndex(3).WithName("**Description**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .WithColor(NadekoBot.OkColor); From 66d8f5838e4a2b11ebef0bce3a77c9daa3d040f6 Mon Sep 17 00:00:00 2001 From: samvaio Date: Mon, 5 Dec 2016 00:12:51 +0530 Subject: [PATCH 32/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index 9de61d21..efe3530a 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -102,7 +102,7 @@ namespace NadekoBot.Modules.Help var str = $"**`{com.Text}`**"; var alias = com.Aliases.Skip(1).FirstOrDefault(); if (alias != null) - str += $"** / `{alias}`**"; + str += $" **/** **`{alias}`**"; var embed = new EmbedBuilder() .WithAuthor(eau => eau.WithName("Command") .WithUrl("http://nadekobot.readthedocs.io/en/latest/Commands%20List/") From 854e76ac022a25860019b09be8ab86b993f7a365 Mon Sep 17 00:00:00 2001 From: samvaio Date: Mon, 5 Dec 2016 00:21:11 +0530 Subject: [PATCH 33/37] Update Utility.cs --- src/NadekoBot/Modules/Utility/Utility.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 4b27544b..4eb914bd 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -176,47 +176,47 @@ namespace NadekoBot.Modules.Utility }, Fields = new[] { new EmbedField() { - Name = "**Author**", + Name = Format.Bold("Author"), Value = stats.Author, Inline = true }, new EmbedField() { - Name = "**Library**", + Name = Format.Bold("Library"), Value = stats.Library, Inline = true }, new EmbedField() { - Name = "**Bot ID**", + Name = Format.Bold("Bot ID"), Value = NadekoBot.Client.GetCurrentUser().Id.ToString(), Inline = true }, new EmbedField() { - Name = "**Commands Ran**", + Name = Format.Bold("Commands Ran"), Value = stats.CommandsRan.ToString(), Inline = true }, new EmbedField() { - Name = "**Messages**", - Value = $"{stats.MessageCounter} [{stats.MessagesPerSecond:F2}/sec]", + Name = Format.Bold("Messages"), + Value = $"{stats.MessageCounter} ({stats.MessagesPerSecond:F2}/sec)", Inline = true }, new EmbedField() { - Name = "**Memory**", + Name = Format.Bold("Memory"), Value = $"{stats.Heap} MB", Inline = true }, new EmbedField() { - Name = "**Owner ID(s)**", + Name = Format.Bold("Owner ID(s)"), Value = stats.OwnerIds, Inline = true }, new EmbedField() { - Name = "**Uptime**", + Name = Format.Bold("Uptime"), Value = stats.GetUptimeString("\n"), Inline = true }, new EmbedField() { - Name = "**Presence**", + Name = Format.Bold("Presence"), Value = $"{NadekoBot.Client.GetGuilds().Count} servers\n{stats.TextChannels} Text Channels\n{stats.VoiceChannels} Voice Channels", Inline = true }, From aecf83940c07088ffae32167aab6c6e442c04356 Mon Sep 17 00:00:00 2001 From: samvaio Date: Mon, 5 Dec 2016 00:22:16 +0530 Subject: [PATCH 34/37] Update Utility.cs --- src/NadekoBot/Modules/Utility/Utility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 4eb914bd..5dce8930 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -217,7 +217,7 @@ namespace NadekoBot.Modules.Utility }, new EmbedField() { Name = Format.Bold("Presence"), - Value = $"{NadekoBot.Client.GetGuilds().Count} servers\n{stats.TextChannels} Text Channels\n{stats.VoiceChannels} Voice Channels", + Value = $"{NadekoBot.Client.GetGuilds().Count} Servers\n{stats.TextChannels} Text Channels\n{stats.VoiceChannels} Voice Channels", Inline = true }, From 7a8b95e077cb460002a3182960302855e081cd40 Mon Sep 17 00:00:00 2001 From: samvaio Date: Mon, 5 Dec 2016 00:30:20 +0530 Subject: [PATCH 35/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index efe3530a..bb10569d 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -109,7 +109,7 @@ namespace NadekoBot.Modules.Help .WithIconUrl(NadekoBot.Client.GetCurrentUser().AvatarUrl)) //.WithTitle(str) //.WithDescription($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}") - .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)} **|** { GetCommandRequirements(com)}").WithIsInline(true)) + .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)} { GetCommandRequirements(com)}").WithIsInline(true)) .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(false)) //.AddField(fb => fb.WithIndex(3).WithName("**Description**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .WithColor(NadekoBot.OkColor); From 2de14c2b66e9e125ae7e91a9b866afa420cb29d4 Mon Sep 17 00:00:00 2001 From: samvaio Date: Mon, 5 Dec 2016 00:38:22 +0530 Subject: [PATCH 36/37] Update Help.cs --- src/NadekoBot/Modules/Help/Help.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index bb10569d..5661c2b0 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -109,7 +109,7 @@ namespace NadekoBot.Modules.Help .WithIconUrl(NadekoBot.Client.GetCurrentUser().AvatarUrl)) //.WithTitle(str) //.WithDescription($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}") - .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)} { GetCommandRequirements(com)}").WithIsInline(true)) + .AddField(fb => fb.WithIndex(1).WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Prefix)} { GetCommandRequirements(com)}").WithIsInline(true)) .AddField(fb => fb.WithIndex(2).WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Prefix)}").WithIsInline(false)) //.AddField(fb => fb.WithIndex(3).WithName("**Description**").WithValue($"{ string.Format(com.Summary, com.Module.Prefix)}{ GetCommandRequirements(com)}").WithIsInline(true)) .WithColor(NadekoBot.OkColor); From 223e0993b85919f1c5b7f5c8d5520df9f575be48 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 4 Dec 2016 22:28:31 +0100 Subject: [PATCH 37/37] slight change --- src/NadekoBot/Modules/Pokemon/Pokemon.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Pokemon/Pokemon.cs b/src/NadekoBot/Modules/Pokemon/Pokemon.cs index 8a4227f3..9395cf7b 100644 --- a/src/NadekoBot/Modules/Pokemon/Pokemon.cs +++ b/src/NadekoBot/Modules/Pokemon/Pokemon.cs @@ -17,7 +17,7 @@ using static NadekoBot.Modules.Gambling.Gambling; namespace NadekoBot.Modules.Pokemon { - [NadekoModule("PokeGame", ">")] + [NadekoModule("Pokemon", ">")] public partial class Pokemon : DiscordModule { private static List PokemonTypes = new List();