From 5c36a90408647187c3d83a270224563a8eff744d Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 17 Jul 2016 16:41:46 +0200 Subject: [PATCH 01/43] added $rolluo (unordered roll) for games where order of dice matters --- NadekoBot/Modules/Gambling/DiceRollCommand.cs | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/NadekoBot/Modules/Gambling/DiceRollCommand.cs b/NadekoBot/Modules/Gambling/DiceRollCommand.cs index 5e1a7833..68a665fe 100644 --- a/NadekoBot/Modules/Gambling/DiceRollCommand.cs +++ b/NadekoBot/Modules/Gambling/DiceRollCommand.cs @@ -24,6 +24,13 @@ namespace NadekoBot.Modules.Gambling " If you split 2 numbers with letter d (xdy) it will roll x dice from 1 to y. | $roll or $roll 7 or $roll 3d5") .Parameter("num", ParameterType.Optional) .Do(RollFunc()); + + cgb.CreateCommand(Module.Prefix + "rolluo") + .Description("Rolls 0-100. If you supply a number [x] it rolls up to 30 normal dice (unordered)." + + " If you split 2 numbers with letter d (xdy) it will roll x dice from 1 to y. | $roll or $roll 7 or $roll 3d5") + .Parameter("num", ParameterType.Optional) + .Do(RollFunc(false)); + cgb.CreateCommand(Module.Prefix + "nroll") .Description("Rolls in a given range. | `$nroll 5` (rolls 0-5) or `$nroll 5-15`") .Parameter("range", ParameterType.Required) @@ -40,7 +47,7 @@ namespace NadekoBot.Modules.Gambling Regex dndRegex = new Regex(@"(?\d+)d(?\d+)", RegexOptions.Compiled); - private Func RollFunc() + private Func RollFunc(bool ordered = true) { var r = new Random(); return async e => @@ -73,7 +80,7 @@ namespace NadekoBot.Modules.Gambling arr[i] = r.Next(1, n2 + 1); } var elemCnt = 0; - await e.Channel.SendMessage($"`Rolled {n1} {(n1 == 1 ? "die" : "dice")} 1-{n2}.`\n`Result:` " + string.Join(", ", arr.OrderBy(x => x).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false); + await e.Channel.SendMessage($"`Rolled {n1} {(n1 == 1 ? "die" : "dice")} 1-{n2}.`\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false); } return; } @@ -92,17 +99,23 @@ namespace NadekoBot.Modules.Gambling { var randomNumber = r.Next(1, 7); var toInsert = dices.Count; - if (randomNumber == 6 || dices.Count == 0) - toInsert = 0; - else if (randomNumber != 1) - for (var j = 0; j < dices.Count; j++) - { - if (values[j] < randomNumber) + if (ordered) + { + if (randomNumber == 6 || dices.Count == 0) + toInsert = 0; + else if (randomNumber != 1) + for (var j = 0; j < dices.Count; j++) { - toInsert = j; - break; + if (values[j] < randomNumber) + { + toInsert = j; + break; + } } - } + } + else { + toInsert = dices.Count; + } dices.Insert(toInsert, GetDice(randomNumber)); values.Insert(toInsert, randomNumber); } From 3512a99ce1df79971232ccf87cd42735e5c0e873 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 17 Jul 2016 17:52:06 +0200 Subject: [PATCH 02/43] added `.logignore` to ignore channels you don't want logged with .logserver --- NadekoBot/Classes/ServerSpecificConfig.cs | 16 ++++++ .../Administration/Commands/LogCommand.cs | 49 ++++++++++++++----- NadekoBot/Modules/DiscordCommand.cs | 2 +- NadekoBot/Modules/DiscordModule.cs | 2 +- 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/NadekoBot/Classes/ServerSpecificConfig.cs b/NadekoBot/Classes/ServerSpecificConfig.cs index 4296b648..b92915f1 100644 --- a/NadekoBot/Classes/ServerSpecificConfig.cs +++ b/NadekoBot/Classes/ServerSpecificConfig.cs @@ -100,6 +100,21 @@ namespace NadekoBot.Classes } } + [JsonIgnore] + private ObservableCollection logserverIgnoreChannels; + public ObservableCollection LogserverIgnoreChannels { + get { return logserverIgnoreChannels; } + set { + logserverIgnoreChannels = value; + if (value != null) + logserverIgnoreChannels.CollectionChanged += (s, e) => + { + if (!SpecificConfigurations.Instantiated) return; + OnPropertyChanged(); + }; + } + } + [JsonProperty("LogPresenceChannel")] private ulong? logPresenceChannel = null; [JsonIgnore] @@ -212,6 +227,7 @@ namespace NadekoBot.Classes ObservingStreams = new ObservableCollection(); GenerateCurrencyChannels = new ObservableConcurrentDictionary(); VoiceChannelLog = new ObservableConcurrentDictionary(); + LogserverIgnoreChannels = new ObservableCollection(); } public event PropertyChangedEventHandler PropertyChanged = delegate { SpecificConfigurations.Default.Save(); }; diff --git a/NadekoBot/Modules/Administration/Commands/LogCommand.cs b/NadekoBot/Modules/Administration/Commands/LogCommand.cs index 8f51c9e5..25107ca0 100644 --- a/NadekoBot/Modules/Administration/Commands/LogCommand.cs +++ b/NadekoBot/Modules/Administration/Commands/LogCommand.cs @@ -51,8 +51,9 @@ namespace NadekoBot.Modules.Administration.Commands { try { - var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel; - if (chId == null) + var config = SpecificConfigurations.Default.Of(e.Server.Id); + var chId = config.LogServerChannel; + if (chId == null || config.LogserverIgnoreChannels.Contains(e.After.Id)) return; Channel ch; if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) @@ -72,8 +73,9 @@ namespace NadekoBot.Modules.Administration.Commands { try { - var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel; - if (chId == null) + var config = SpecificConfigurations.Default.Of(e.Server.Id); + var chId = config.LogServerChannel; + if (chId == null || config.LogserverIgnoreChannels.Contains(e.Channel.Id)) return; Channel ch; if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) @@ -87,8 +89,9 @@ namespace NadekoBot.Modules.Administration.Commands { try { - var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel; - if (chId == null) + var config = SpecificConfigurations.Default.Of(e.Server.Id); + var chId = config.LogServerChannel; + if (chId == null || config.LogserverIgnoreChannels.Contains(e.Channel.Id)) return; Channel ch; if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) @@ -164,8 +167,9 @@ namespace NadekoBot.Modules.Administration.Commands { if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id) return; - var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel; - if (chId == null || e.Channel.Id == chId) + var config = SpecificConfigurations.Default.Of(e.Server.Id); + var chId = config.LogServerChannel; + if (chId == null || e.Channel.Id == chId || config.LogserverIgnoreChannels.Contains(e.Channel.Id)) return; Channel ch; if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) @@ -192,8 +196,9 @@ namespace NadekoBot.Modules.Administration.Commands { if (e.Server == null || e.Channel.IsPrivate || e.User?.Id == NadekoBot.Client.CurrentUser.Id) return; - var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel; - if (chId == null || e.Channel.Id == chId) + var config = SpecificConfigurations.Default.Of(e.Server.Id); + var chId = config.LogServerChannel; + if (chId == null || e.Channel.Id == chId || config.LogserverIgnoreChannels.Contains(e.Channel.Id)) return; Channel ch; if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) @@ -219,8 +224,9 @@ namespace NadekoBot.Modules.Administration.Commands { if (e.Server == null || e.Channel.IsPrivate || e.User?.Id == NadekoBot.Client.CurrentUser.Id) return; - var chId = SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel; - if (chId == null || e.Channel.Id == chId) + var config = SpecificConfigurations.Default.Of(e.Server.Id); + var chId = config.LogServerChannel; + if (chId == null || e.Channel.Id == chId || config.LogserverIgnoreChannels.Contains(e.Channel.Id)) return; Channel ch; if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) @@ -370,6 +376,25 @@ $@"๐Ÿ•”`{prettyCurrentTime}` **Message** ๐Ÿ“ `#{e.Channel.Name}` await e.Channel.SendMessage($"โ—**NO LONGER LOGGING IN {ch.Mention} CHANNEL**โ—").ConfigureAwait(false); }); + + cgb.CreateCommand(Prefix + "logignore") + .Alias($"Toggles whether the {Prefix}logserver command ignores this channel. Useful if you have hidden admin channel and public log channel.") + .AddCheck(SimpleCheckers.OwnerOnly()) + .AddCheck(SimpleCheckers.ManageServer()) + .Do(async e => + { + var config = SpecificConfigurations.Default.Of(e.Server.Id); + if (config.LogserverIgnoreChannels.Remove(e.Channel.Id)) + { + await e.Channel.SendMessage($"`{Prefix}logserver will stop ignoring this channel.`"); + } + else + { + config.LogserverIgnoreChannels.Add(e.Channel.Id); + await e.Channel.SendMessage($"`{Prefix}logserver will ignore this channel.`"); + } + }); + cgb.CreateCommand(Module.Prefix + "userpresence") .Description("Starts logging to this channel when someone from the server goes online/offline/idle.") .AddCheck(SimpleCheckers.ManageServer()) diff --git a/NadekoBot/Modules/DiscordCommand.cs b/NadekoBot/Modules/DiscordCommand.cs index 726c813b..05f9a42a 100644 --- a/NadekoBot/Modules/DiscordCommand.cs +++ b/NadekoBot/Modules/DiscordCommand.cs @@ -7,7 +7,7 @@ namespace NadekoBot.Classes /// Base DiscordCommand Class. /// Inherit this class to create your own command. /// - internal abstract class DiscordCommand + public abstract class DiscordCommand { /// diff --git a/NadekoBot/Modules/DiscordModule.cs b/NadekoBot/Modules/DiscordModule.cs index 48427732..5e131233 100644 --- a/NadekoBot/Modules/DiscordModule.cs +++ b/NadekoBot/Modules/DiscordModule.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using NadekoBot.Classes; namespace NadekoBot.Modules { - internal abstract class DiscordModule : IModule { + public abstract class DiscordModule : IModule { protected readonly HashSet commands = new HashSet(); public abstract string Prefix { get; } From d24aac4f76e49bbeb715a1d89aa737ba240ae472 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 17 Jul 2016 18:09:11 +0200 Subject: [PATCH 03/43] ... what was i thinkng --- NadekoBot/Modules/Permissions/Classes/PermissionChecker.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/NadekoBot/Modules/Permissions/Classes/PermissionChecker.cs b/NadekoBot/Modules/Permissions/Classes/PermissionChecker.cs index 551ad193..a3268570 100644 --- a/NadekoBot/Modules/Permissions/Classes/PermissionChecker.cs +++ b/NadekoBot/Modules/Permissions/Classes/PermissionChecker.cs @@ -4,6 +4,7 @@ using Discord.Commands.Permissions; using NadekoBot.Classes.JSONModels; using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.Threading.Tasks; namespace NadekoBot.Modules.Permissions.Classes @@ -13,7 +14,7 @@ namespace NadekoBot.Modules.Permissions.Classes { public static PermissionChecker Instance { get; } = new PermissionChecker(); - private ConcurrentDictionary timeBlackList { get; } = new ConcurrentDictionary(); + private HashSet timeBlackList { get; } = new HashSet(); static PermissionChecker() { } private PermissionChecker() @@ -46,10 +47,10 @@ namespace NadekoBot.Modules.Permissions.Classes return false; } - if (timeBlackList.ContainsKey(user)) + if (timeBlackList.Contains(user.Id)) return false; - timeBlackList.TryAdd(user, DateTime.Now); + timeBlackList.Add(user.Id); if (!channel.IsPrivate && !channel.Server.CurrentUser.GetPermissions(channel).SendMessages) { From 520902b6265cafe6be4294f804800ea0ae374b9f Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 17 Jul 2016 18:15:29 +0200 Subject: [PATCH 04/43] grammar --- NadekoBot/Modules/Pokemon/PokemonModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NadekoBot/Modules/Pokemon/PokemonModule.cs b/NadekoBot/Modules/Pokemon/PokemonModule.cs index 9d9c4a29..bef55e56 100644 --- a/NadekoBot/Modules/Pokemon/PokemonModule.cs +++ b/NadekoBot/Modules/Pokemon/PokemonModule.cs @@ -210,7 +210,7 @@ namespace NadekoBot.Modules.Pokemon }); cgb.CreateCommand(Prefix + "heal") - .Description($"Heals someone. Revives those that fainted. Costs a {NadekoBot.Config.CurrencyName} |{Prefix}revive @someone") + .Description($"Heals someone. Revives those who fainted. Costs a {NadekoBot.Config.CurrencyName} | {Prefix}revive @someone") .Parameter("target", ParameterType.Unparsed) .Do(async e => { From 6e20c8d719f00edc10231eabbcefa6a4386258d5 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 17 Jul 2016 18:20:55 +0200 Subject: [PATCH 05/43] minor cleanup --- NadekoBot/Modules/Help/HelpModule.cs | 1 - NadekoBot/Modules/Pokemon/PokemonModule.cs | 6 +++--- NadekoBot/Modules/Searches/Commands/EvalCommand.cs | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/NadekoBot/Modules/Help/HelpModule.cs b/NadekoBot/Modules/Help/HelpModule.cs index 511779c2..941ffa9e 100644 --- a/NadekoBot/Modules/Help/HelpModule.cs +++ b/NadekoBot/Modules/Help/HelpModule.cs @@ -53,7 +53,6 @@ namespace NadekoBot.Modules.Help await e.Channel.SendMessage("That module does not exist.").ConfigureAwait(false); return; } - var i = 0; if (module != "customreactions" && module != "conversations") { await e.Channel.SendMessage("`List Of Commands:`\n" + SearchHelper.ShowInPrettyCode(cmdsArray, diff --git a/NadekoBot/Modules/Pokemon/PokemonModule.cs b/NadekoBot/Modules/Pokemon/PokemonModule.cs index bef55e56..ae3ae0d9 100644 --- a/NadekoBot/Modules/Pokemon/PokemonModule.cs +++ b/NadekoBot/Modules/Pokemon/PokemonModule.cs @@ -210,7 +210,7 @@ namespace NadekoBot.Modules.Pokemon }); cgb.CreateCommand(Prefix + "heal") - .Description($"Heals someone. Revives those who fainted. Costs a {NadekoBot.Config.CurrencyName} | {Prefix}revive @someone") + .Description($"Heals someone. Revives those who fainted. Costs a {NadekoBot.Config.CurrencyName} | {Prefix}heal @someone") .Parameter("target", ParameterType.Unparsed) .Do(async e => { @@ -242,7 +242,7 @@ namespace NadekoBot.Modules.Pokemon return; } var target = (usr.Id == e.User.Id) ? "yourself" : usr.Name; - FlowersHandler.RemoveFlowers(e.User, $"Poke-Heal {target}", amount); + await FlowersHandler.RemoveFlowers(e.User, $"Poke-Heal {target}", amount).ConfigureAwait(false); //healing targetStats.Hp = targetStats.MaxHp; if (HP < 0) @@ -309,7 +309,7 @@ namespace NadekoBot.Modules.Pokemon 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; } - FlowersHandler.RemoveFlowers(e.User, $"set usertype to {targetTypeStr}", amount); + 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); diff --git a/NadekoBot/Modules/Searches/Commands/EvalCommand.cs b/NadekoBot/Modules/Searches/Commands/EvalCommand.cs index 0e815f71..ed469517 100644 --- a/NadekoBot/Modules/Searches/Commands/EvalCommand.cs +++ b/NadekoBot/Modules/Searches/Commands/EvalCommand.cs @@ -49,11 +49,11 @@ namespace NadekoBot.Modules.Searches.Commands string result = parser.Parse(expression).ToString(); return result; } - catch (OverflowException e) + catch (OverflowException) { return $"Overflow error on {expression}"; } - catch (FormatException e) + catch (FormatException) { return $"\"{expression}\" was not formatted correctly"; } From 4b9ae7b403d35834c6700ceb385bf4dd39571728 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 17 Jul 2016 19:42:58 +0200 Subject: [PATCH 06/43] self assigned roles are not ordered alphabeticaly --- .../Modules/Administration/Commands/SelfAssignedRolesCommand.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs b/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs index 723b0f06..94c695e8 100644 --- a/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs +++ b/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs @@ -74,7 +74,7 @@ namespace NadekoBot.Modules.Administration.Commands var config = SpecificConfigurations.Default.Of(e.Server.Id); var msg = new StringBuilder($"There are `{config.ListOfSelfAssignableRoles.Count}` self assignable roles:\n"); var toRemove = new HashSet(); - foreach (var roleId in config.ListOfSelfAssignableRoles) + foreach (var roleId in config.ListOfSelfAssignableRoles.OrderBy(r=>r.ToString())) { var role = e.Server.GetRole(roleId); if (role == null) From e28c705bfd96c33d6a88d33ff1fba55156fcef63 Mon Sep 17 00:00:00 2001 From: appelemac Date: Sun, 17 Jul 2016 20:42:41 +0200 Subject: [PATCH 07/43] sat --- NadekoBot/Classes/ServerSpecificConfig.cs | 15 +++++++++++++++ .../Commands/SelfAssignedRolesCommand.cs | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/NadekoBot/Classes/ServerSpecificConfig.cs b/NadekoBot/Classes/ServerSpecificConfig.cs index e7e7437e..b1458f37 100644 --- a/NadekoBot/Classes/ServerSpecificConfig.cs +++ b/NadekoBot/Classes/ServerSpecificConfig.cs @@ -97,6 +97,8 @@ namespace NadekoBot.Classes } } + + [JsonIgnore] private ulong autoAssignedRole = 0; public ulong AutoAssignedRole { @@ -122,6 +124,19 @@ namespace NadekoBot.Classes } } + [JsonIgnore] + private bool exclusiveSelfAssignedRoles = false; + public bool ExclusiveSelfAssignedRoles + { + get { return exclusiveSelfAssignedRoles; } + set + { + exclusiveSelfAssignedRoles = value; + if (!SpecificConfigurations.Instantiated) return; + OnPropertyChanged(); + } + } + public ObservableCollection ObservingStreams { get { return observingStreams; } set { diff --git a/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs b/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs index eaf59a3a..328d244b 100644 --- a/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs +++ b/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs @@ -94,6 +94,19 @@ namespace NadekoBot.Modules.Administration.Commands await e.Channel.SendMessage(msg.ToString()).ConfigureAwait(false); }); + + + cgb.CreateCommand(Module.Prefix + "togglexclsar").Alias(Module.Prefix +"tesar") + .Description("toggle whether the self-assigned roles should be exclusive") + .AddCheck(SimpleCheckers.CanManageRoles) + .Do(async e => + { + var config = SpecificConfigurations.Default.Of(e.Server.Id); + config.ExclusiveSelfAssignedRoles = !config.ExclusiveSelfAssignedRoles; + string exl = config.ExclusiveSelfAssignedRoles ? "exclusive" : "not exclusive"; + await e.Channel.SendMessage("Self assigned roles are now " + exl); + }); + cgb.CreateCommand(Module.Prefix + "iam") .Description("Adds a role to you that you choose. " + "Role must be on a list of self-assignable roles." + @@ -121,6 +134,12 @@ namespace NadekoBot.Modules.Administration.Commands await e.Channel.SendMessage($":anger:You already have {role.Name} role.").ConfigureAwait(false); return; } + var sameRoles = e.User.Roles.Where(r => config.ListOfSelfAssignableRoles.Contains(r.Id)); + if (config.ExclusiveSelfAssignedRoles && sameRoles.Any()) + { + await e.Channel.SendMessage($":anger:You already have {sameRoles.FirstOrDefault().Name} role.").ConfigureAwait(false); + return; + } try { await e.User.AddRoles(role).ConfigureAwait(false); From 1908ed827f46bb94a3d7e232d4d5a4fde6d97cf3 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 17 Jul 2016 21:19:18 +0200 Subject: [PATCH 08/43] -commands command now prints in alphabetical order --- NadekoBot/Modules/Help/Commands/HelpCommand.cs | 2 +- NadekoBot/Modules/Help/HelpModule.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NadekoBot/Modules/Help/Commands/HelpCommand.cs b/NadekoBot/Modules/Help/Commands/HelpCommand.cs index 2b4ad3b8..3bf86435 100644 --- a/NadekoBot/Modules/Help/Commands/HelpCommand.cs +++ b/NadekoBot/Modules/Help/Commands/HelpCommand.cs @@ -43,7 +43,7 @@ namespace NadekoBot.Classes.Help.Commands { string helpstr = $@"######For more information and how to setup your own NadekoBot, go to: **http://github.com/Kwoth/NadekoBot/** -######You can donate on paypal: `nadekodiscordbot@gmail.com` or Bitcoin `17MZz1JAqME39akMLrVT4XBPffQJ2n1EPa` +######You can donate on paypal: `nadekodiscordbot@gmail.com` #NadekoBot List Of Commands Version: `{NadekoStats.Instance.BotVersion}`"; diff --git a/NadekoBot/Modules/Help/HelpModule.cs b/NadekoBot/Modules/Help/HelpModule.cs index 941ffa9e..20e8279c 100644 --- a/NadekoBot/Modules/Help/HelpModule.cs +++ b/NadekoBot/Modules/Help/HelpModule.cs @@ -46,7 +46,9 @@ namespace NadekoBot.Modules.Help if (string.IsNullOrWhiteSpace(module)) return; var cmds = NadekoBot.Client.GetService().AllCommands - .Where(c => c.Category.ToLower() == module); + .Where(c => c.Category.ToLower() == module) + .OrderBy(c=>c.Text) + .AsEnumerable(); var cmdsArray = cmds as Command[] ?? cmds.ToArray(); if (!cmdsArray.Any()) { From b05b2b8015c323002f078aba0a2c56717603f806 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 17 Jul 2016 21:29:58 +0200 Subject: [PATCH 09/43] can no longer $give 0 flowers --- NadekoBot/Modules/Gambling/GamblingModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NadekoBot/Modules/Gambling/GamblingModule.cs b/NadekoBot/Modules/Gambling/GamblingModule.cs index 96567ced..579e1ed6 100644 --- a/NadekoBot/Modules/Gambling/GamblingModule.cs +++ b/NadekoBot/Modules/Gambling/GamblingModule.cs @@ -68,7 +68,7 @@ namespace NadekoBot.Modules.Gambling { var amountStr = e.GetArg("amount")?.Trim(); long amount; - if (!long.TryParse(amountStr, out amount) || amount < 0) + if (!long.TryParse(amountStr, out amount) || amount <= 0) return; var mentionedUser = e.Message.MentionedUsers.FirstOrDefault(u => From 6f853938b5c254405dfddb9eff39abf954a8aef7 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 17 Jul 2016 22:53:00 +0200 Subject: [PATCH 10/43] Added `;cmdcd` command - set command cooldowns per user --- .../Permissions/Classes/PermissionChecker.cs | 47 +++++++++++++++---- .../Permissions/Classes/PermissionsHandler.cs | 20 ++++++++ .../Modules/Permissions/PermissionsModule.cs | 33 +++++++++++++ NadekoBot/NadekoBot.cs | 2 +- 4 files changed, 92 insertions(+), 10 deletions(-) diff --git a/NadekoBot/Modules/Permissions/Classes/PermissionChecker.cs b/NadekoBot/Modules/Permissions/Classes/PermissionChecker.cs index a3268570..94de43f6 100644 --- a/NadekoBot/Modules/Permissions/Classes/PermissionChecker.cs +++ b/NadekoBot/Modules/Permissions/Classes/PermissionChecker.cs @@ -14,6 +14,9 @@ namespace NadekoBot.Modules.Permissions.Classes { public static PermissionChecker Instance { get; } = new PermissionChecker(); + //key - sid:command + //value - userid + private ConcurrentDictionary commandCooldowns = new ConcurrentDictionary(); private HashSet timeBlackList { get; } = new HashSet(); static PermissionChecker() { } @@ -50,15 +53,23 @@ namespace NadekoBot.Modules.Permissions.Classes if (timeBlackList.Contains(user.Id)) return false; - timeBlackList.Add(user.Id); - if (!channel.IsPrivate && !channel.Server.CurrentUser.GetPermissions(channel).SendMessages) { return false; } - //{ - // user.SendMessage($"I ignored your command in {channel.Server.Name}/#{channel.Name} because i don't have permissions to write to it. Please use `;acm channel_name 0` in that server instead of muting me.").GetAwaiter().GetResult(); - //} + + timeBlackList.Add(user.Id); + + ServerPermissions perms; + PermissionsHandler.PermissionsDict.TryGetValue(user.Server.Id, out perms); + + AddUserCooldown(user.Server.Id, user.Id, command.Text.ToLower()); + if (commandCooldowns.Keys.Contains(user.Server.Id+":"+command.Text.ToLower())) + { + if(perms?.Verbose == true) + error = $"{user.Mention} You have a cooldown on that command."; + return false; + } try { @@ -76,8 +87,6 @@ namespace NadekoBot.Modules.Permissions.Classes catch { } if (user.Server.Owner.Id == user.Id || (role != null && user.HasRole(role))) return true; - ServerPermissions perms; - PermissionsHandler.PermissionsDict.TryGetValue(user.Server.Id, out perms); throw new Exception($"You don't have the necessary role (**{(perms?.PermissionsControllerRole ?? "Nadeko")}**) to change permissions."); } @@ -129,8 +138,7 @@ namespace NadekoBot.Modules.Permissions.Classes Console.WriteLine($"Exception in canrun: {ex}"); try { - ServerPermissions perms; - if (PermissionsHandler.PermissionsDict.TryGetValue(user.Server.Id, out perms) && perms.Verbose) + if (perms != null && perms.Verbose) //if verbose - print errors error = ex.Message; } @@ -141,5 +149,26 @@ namespace NadekoBot.Modules.Permissions.Classes return false; } } + + public void AddUserCooldown(ulong serverId, ulong userId, string commandName) { + commandCooldowns.TryAdd(commandName, userId); + var tosave = serverId + ":" + commandName; + Task.Run(async () => + { + ServerPermissions perms; + PermissionsHandler.PermissionsDict.TryGetValue(serverId, out perms); + int cd; + if (!perms.CommandCooldowns.TryGetValue(commandName,out cd)) { + return; + } + if (commandCooldowns.TryAdd(tosave, userId)) + { + await Task.Delay(cd * 1000); + ulong throwaway; + commandCooldowns.TryRemove(tosave, out throwaway); + } + + }); + } } } diff --git a/NadekoBot/Modules/Permissions/Classes/PermissionsHandler.cs b/NadekoBot/Modules/Permissions/Classes/PermissionsHandler.cs index 93fa8686..c5d2e64c 100644 --- a/NadekoBot/Modules/Permissions/Classes/PermissionsHandler.cs +++ b/NadekoBot/Modules/Permissions/Classes/PermissionsHandler.cs @@ -424,6 +424,21 @@ namespace NadekoBot.Modules.Permissions.Classes Task.Run(() => WriteServerToJson(serverPerms)); } + public static void SetCommandCooldown(Server server, string commandName, int value) + { + var serverPerms = PermissionsDict.GetOrAdd(server.Id, + new ServerPermissions(server.Id, server.Name)); + if (value == 0) { + int throwaway; + serverPerms.CommandCooldowns.TryRemove(commandName, out throwaway); + } + else { + serverPerms.CommandCooldowns.AddOrUpdate(commandName, value, (str, v) => value); + } + + Task.Run(() => WriteServerToJson(serverPerms)); + } + public static void AddFilteredWord(Server server, string word) { var serverPerms = PermissionsDict.GetOrAdd(server.Id, @@ -537,6 +552,10 @@ namespace NadekoBot.Modules.Permissions.Classes public Dictionary UserPermissions { get; set; } public Dictionary ChannelPermissions { get; set; } public Dictionary RolePermissions { get; set; } + /// + /// Dictionary of command names with their respective cooldowns + /// + public ConcurrentDictionary CommandCooldowns { get; set; } public ServerPermissions(ulong id, string name) { @@ -549,6 +568,7 @@ namespace NadekoBot.Modules.Permissions.Classes UserPermissions = new Dictionary(); ChannelPermissions = new Dictionary(); RolePermissions = new Dictionary(); + CommandCooldowns = new ConcurrentDictionary(); Words = new HashSet(); } } diff --git a/NadekoBot/Modules/Permissions/PermissionsModule.cs b/NadekoBot/Modules/Permissions/PermissionsModule.cs index e210c1e2..82cf1c34 100644 --- a/NadekoBot/Modules/Permissions/PermissionsModule.cs +++ b/NadekoBot/Modules/Permissions/PermissionsModule.cs @@ -776,6 +776,39 @@ namespace NadekoBot.Modules.Permissions await e.Channel.SendMessage($"`Sucessfully blacklisted server {server.Name}`").ConfigureAwait(false); }).ConfigureAwait(false); }); + + cgb.CreateCommand(Prefix + "cmdcooldown") + .Alias(Prefix+ "cmdcd") + .Description($"Sets a cooldown per user for a command. Set 0 to clear. | `{Prefix}cmdcd \"some cmd\" 5`") + .Parameter("command", ParameterType.Required) + .Parameter("secs",ParameterType.Required) + .AddCheck(SimpleCheckers.ManageMessages()) + .Do(async e => + { + try + { + var command = PermissionHelper.ValidateCommand(e.GetArg("command")); + var secsStr = e.GetArg("secs").Trim(); + int secs; + if (!int.TryParse(secsStr, out secs) || secs < 0 || secs > 3600) + throw new ArgumentOutOfRangeException("secs", "Invalid second parameter. (Must be a number between 0 and 3600)"); + + + PermissionsHandler.SetCommandCooldown(e.Server, command, secs); + if(secs == 0) + await e.Channel.SendMessage($"Command **{command}** has no coooldown now.").ConfigureAwait(false); + else + await e.Channel.SendMessage($"Command **{command}** now has a **{secs} {(secs==1 ? "second" : "seconds")}** cooldown.").ConfigureAwait(false); + } + catch (ArgumentException exArg) + { + await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false); + } + catch (Exception ex) + { + await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + } + }); }); } } diff --git a/NadekoBot/NadekoBot.cs b/NadekoBot/NadekoBot.cs index 9a4b804c..ad1b0031 100644 --- a/NadekoBot/NadekoBot.cs +++ b/NadekoBot/NadekoBot.cs @@ -196,7 +196,7 @@ namespace NadekoBot return; } #if NADEKO_RELEASE - await Task.Delay(120000).ConfigureAwait(false); + await Task.Delay(150000).ConfigureAwait(false); #else await Task.Delay(1000).ConfigureAwait(false); #endif From 44ce541abc5d05d9562cc22f0b88cab05184aa47 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 19 Jul 2016 13:37:20 +0200 Subject: [PATCH 11/43] added ~google to get google search link #402 --- NadekoBot/Modules/Searches/SearchesModule.cs | 13 +++++++++++++ NadekoBot/_Models/JSONModels/_JSONModels.cs | 2 +- NadekoBot/bin/Debug/credentials_example.json | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/NadekoBot/Modules/Searches/SearchesModule.cs b/NadekoBot/Modules/Searches/SearchesModule.cs index 466ff12c..e9a30cc8 100644 --- a/NadekoBot/Modules/Searches/SearchesModule.cs +++ b/NadekoBot/Modules/Searches/SearchesModule.cs @@ -15,6 +15,7 @@ using System.Drawing; using System.IO; using System.Linq; using System.Net.Http; +using System.Web; namespace NadekoBot.Modules.Searches { @@ -219,6 +220,18 @@ $@"๐ŸŒ **Weather for** ใ€{obj["target"]}ใ€‘ .ConfigureAwait(false); }); + cgb.CreateCommand(Prefix + "google") + .Description("Get a google search link for some terms.") + .Parameter("terms", ParameterType.Unparsed) + .Do(async e => + { + var terms = e.GetArg("terms")?.Trim().Replace(' ', '+'); + if (string.IsNullOrWhiteSpace(terms)) + return; + await e.Channel.SendMessage($"https://google.com/search?q={ HttpUtility.UrlEncode(terms) }") + .ConfigureAwait(false); + }); + cgb.CreateCommand(Prefix + "hs") .Description("Searches for a Hearthstone card and shows its image. Takes a while to complete. |~hs Ysera") .Parameter("name", ParameterType.Unparsed) diff --git a/NadekoBot/_Models/JSONModels/_JSONModels.cs b/NadekoBot/_Models/JSONModels/_JSONModels.cs index ae7241bd..c60d32d8 100644 --- a/NadekoBot/_Models/JSONModels/_JSONModels.cs +++ b/NadekoBot/_Models/JSONModels/_JSONModels.cs @@ -7,7 +7,7 @@ namespace NadekoBot.Classes.JSONModels public class Credentials { public string Token { get; set; } = ""; - public string ClientId { get; set; } = "116275390695079945"; + public string ClientId { get; set; } = "170254782546575360"; public ulong BotId { get; set; } = 1231231231231; public ulong[] OwnerIds { get; set; } = { 123123123123, 5675675679845 }; public string GoogleAPIKey { get; set; } = ""; diff --git a/NadekoBot/bin/Debug/credentials_example.json b/NadekoBot/bin/Debug/credentials_example.json index 245b1141..e5c9f2dd 100644 --- a/NadekoBot/bin/Debug/credentials_example.json +++ b/NadekoBot/bin/Debug/credentials_example.json @@ -1,6 +1,6 @@ { "Token": "", - "ClientId": "116275390695079945", + "ClientId": "170254782546575360", "BotId": 1231231231231, "OwnerIds": [ 123123123123, From 123b75b7c9ad20936d1e8e89056026d6a9954714 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 19 Jul 2016 16:53:09 +0200 Subject: [PATCH 12/43] ;acmdcds added to benefit ;cmdcd, permission system can now take aliases --- .../Permissions/Classes/PermissionHelper.cs | 4 +++- .../Modules/Permissions/PermissionsModule.cs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/NadekoBot/Modules/Permissions/Classes/PermissionHelper.cs b/NadekoBot/Modules/Permissions/Classes/PermissionHelper.cs index aef62ac8..c972953e 100644 --- a/NadekoBot/Modules/Permissions/Classes/PermissionHelper.cs +++ b/NadekoBot/Modules/Permissions/Classes/PermissionHelper.cs @@ -55,9 +55,11 @@ namespace NadekoBot.Modules.Permissions.Classes if (string.IsNullOrWhiteSpace(commandText)) throw new ArgumentNullException(nameof(commandText)); + var normalizedCmdTxt = commandText.Trim().ToUpperInvariant(); + foreach (var com in NadekoBot.Client.GetService().AllCommands) { - if (com.Text.ToLower().Equals(commandText.Trim().ToLower())) + if (com.Text.ToUpperInvariant().Equals(normalizedCmdTxt) || com.Aliases.Select(c=>c.ToUpperInvariant()).Contains(normalizedCmdTxt)) return com.Text; } throw new NullReferenceException("That command does not exist."); diff --git a/NadekoBot/Modules/Permissions/PermissionsModule.cs b/NadekoBot/Modules/Permissions/PermissionsModule.cs index 82cf1c34..4c13b9ff 100644 --- a/NadekoBot/Modules/Permissions/PermissionsModule.cs +++ b/NadekoBot/Modules/Permissions/PermissionsModule.cs @@ -1,5 +1,6 @@ ๏ปฟusing Discord.Commands; using Discord.Modules; +using NadekoBot.Classes; using NadekoBot.Classes.JSONModels; using NadekoBot.Extensions; using NadekoBot.Modules.Games.Commands; @@ -809,6 +810,24 @@ namespace NadekoBot.Modules.Permissions await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); + + cgb.CreateCommand(Prefix + "allcmdcooldowns") + .Alias(Prefix + "acmdcds") + .Description("Shows a list of all commands and their respective cooldowns.") + .Do(async e => + { + ServerPermissions perms; + PermissionsHandler.PermissionsDict.TryGetValue(e.Server.Id, out perms); + if (perms == null) + return; + + if (!perms.CommandCooldowns.Any()) + { + await e.Channel.SendMessage("`No command cooldowns set.`").ConfigureAwait(false); + return; + } + await e.Channel.SendMessage(SearchHelper.ShowInPrettyCode(perms.CommandCooldowns.Select(c=>c.Key+ ": "+c.Value+" secs"),s=>$"{s,-30}",2)).ConfigureAwait(false); + }); }); } } From 35ed6567c3da48538a801c236d87e782bd6a03fe Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 19 Jul 2016 17:07:19 +0200 Subject: [PATCH 13/43] updated discord.net --- discord.net | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord.net b/discord.net index 80f9d6f2..6bfeaadd 160000 --- a/discord.net +++ b/discord.net @@ -1 +1 @@ -Subproject commit 80f9d6f2de25355a245bf93d4019d16e3fd033ca +Subproject commit 6bfeaaddf0cbc83fe0ca44e6164f61c6f8fdaf27 From 33f8dc87d32362acc043e7288e9281baf33e8a84 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 19 Jul 2016 17:24:57 +0200 Subject: [PATCH 14/43] `.prune` is much faster --- .../Administration/AdministrationModule.cs | 43 +++++-------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/NadekoBot/Modules/Administration/AdministrationModule.cs b/NadekoBot/Modules/Administration/AdministrationModule.cs index 9b2e6c4e..cff95af4 100644 --- a/NadekoBot/Modules/Administration/AdministrationModule.cs +++ b/NadekoBot/Modules/Administration/AdministrationModule.cs @@ -633,22 +633,13 @@ namespace NadekoBot.Modules.Administration .Parameter("num", ParameterType.Optional) .Do(async e => { + Message[] msgs; if (string.IsNullOrWhiteSpace(e.GetArg("user_or_num"))) // if nothing is set, clear nadeko's messages, no permissions required { - await Task.Run(async () => - { - var msgs = (await e.Channel.DownloadMessages(100).ConfigureAwait(false)).Where(m => m.User.Id == e.Server.CurrentUser.Id); - foreach (var m in msgs) - { - try - { - await m.Delete().ConfigureAwait(false); - } - catch { } - await Task.Delay(100).ConfigureAwait(false); - } - - }).ConfigureAwait(false); + msgs = (await e.Channel.DownloadMessages(100).ConfigureAwait(false)).Where(m => m.User.Id == e.Server.CurrentUser.Id).ToArray(); + if (!msgs.Any()) + return; + await e.Channel.DeleteMessages(msgs).ConfigureAwait(false); return; } if (!e.User.GetPermissions(e.Channel).ManageMessages) @@ -665,11 +656,7 @@ namespace NadekoBot.Modules.Administration if (val <= 0) return; val++; - foreach (var msg in await e.Channel.DownloadMessages(val).ConfigureAwait(false)) - { - await msg.Delete().ConfigureAwait(false); - await Task.Delay(100).ConfigureAwait(false); - } + await e.Channel.DeleteMessages((await e.Channel.DownloadMessages(val).ConfigureAwait(false)).ToArray()).ConfigureAwait(false); return; } //else if first argument is user @@ -679,20 +666,10 @@ namespace NadekoBot.Modules.Administration val = 100; if (!int.TryParse(e.GetArg("num"), out val)) val = 100; - await Task.Run(async () => - { - var msgs = (await e.Channel.DownloadMessages(100).ConfigureAwait(false)).Where(m => m.User.Id == usr.Id).Take(val); - foreach (var m in msgs) - { - try - { - await m.Delete().ConfigureAwait(false); - } - catch { } - await Task.Delay(100).ConfigureAwait(false); - } - - }).ConfigureAwait(false); + msgs = (await e.Channel.DownloadMessages(100).ConfigureAwait(false)).Where(m => m.User.Id == usr.Id).Take(val).ToArray(); + if (!msgs.Any()) + return; + await e.Channel.DeleteMessages(msgs).ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "die") From 60bc7d4f7179a951fd115244e9c655b366881ee7 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 19 Jul 2016 18:27:16 +0200 Subject: [PATCH 15/43] changed !m to !!, and there is no space now. This won't apply to people with old configuration.json --- NadekoBot/Modules/Music/MusicModule.cs | 124 +++++++++--------- NadekoBot/_Models/JSONModels/Configuration.cs | 2 +- NadekoBot/bin/Debug/data/config_example.json | 2 +- 3 files changed, 64 insertions(+), 64 deletions(-) diff --git a/NadekoBot/Modules/Music/MusicModule.cs b/NadekoBot/Modules/Music/MusicModule.cs index 8c04a58b..c9900e7c 100644 --- a/NadekoBot/Modules/Music/MusicModule.cs +++ b/NadekoBot/Modules/Music/MusicModule.cs @@ -31,16 +31,16 @@ namespace NadekoBot.Modules.Music { var client = NadekoBot.Client; - manager.CreateCommands(Prefix, cgb => + manager.CreateCommands("", cgb => { cgb.AddCheck(PermissionChecker.Instance); commands.ForEach(cmd => cmd.Init(cgb)); - cgb.CreateCommand("next") - .Alias("n") - .Alias("skip") + cgb.CreateCommand(Prefix + "next") + .Alias(Prefix + "n") + .Alias(Prefix + "skip") .Description("Goes to the next song in the queue. You have to be in the same voice channel as the bot. | `!m n`") .Do(e => { @@ -50,8 +50,8 @@ namespace NadekoBot.Modules.Music musicPlayer.Next(); }); - cgb.CreateCommand("stop") - .Alias("s") + cgb.CreateCommand(Prefix + "stop") + .Alias(Prefix + "s") .Description("Stops the music and clears the playlist. Stays in the channel. | `!m s`") .Do(e => { @@ -64,8 +64,8 @@ namespace NadekoBot.Modules.Music } }); - cgb.CreateCommand("destroy") - .Alias("d") + cgb.CreateCommand(Prefix + "destroy") + .Alias(Prefix + "d") .Description("Completely stops the music and unbinds the bot from the channel. " + "(may cause weird behaviour) | `!m d`") .Do(e => @@ -76,8 +76,8 @@ namespace NadekoBot.Modules.Music musicPlayer.Destroy(); }); - cgb.CreateCommand("pause") - .Alias("p") + cgb.CreateCommand(Prefix + "pause") + .Alias(Prefix + "p") .Description("Pauses or Unpauses the song. | `!m p`") .Do(async e => { @@ -92,9 +92,9 @@ namespace NadekoBot.Modules.Music await e.Channel.SendMessage("๐ŸŽต`Music Player unpaused.`").ConfigureAwait(false); }); - cgb.CreateCommand("queue") - .Alias("q") - .Alias("yq") + cgb.CreateCommand(Prefix + "queue") + .Alias(Prefix + "q") + .Alias(Prefix + "yq") .Description("Queue a song using keywords or a link. Bot will join your voice channel." + "**You must be in a voice channel**. | `!m q Dream Of Venice`") .Parameter("query", ParameterType.Unparsed) @@ -108,8 +108,8 @@ namespace NadekoBot.Modules.Music } }); - cgb.CreateCommand("soundcloudqueue") - .Alias("sq") + cgb.CreateCommand(Prefix + "soundcloudqueue") + .Alias(Prefix + "sq") .Description("Queue a soundcloud song using keywords. Bot will join your voice channel." + "**You must be in a voice channel**. | `!m sq Dream Of Venice`") .Parameter("query", ParameterType.Unparsed) @@ -123,8 +123,8 @@ namespace NadekoBot.Modules.Music } }); - cgb.CreateCommand("listqueue") - .Alias("lq") + cgb.CreateCommand(Prefix + "listqueue") + .Alias(Prefix + "lq") .Description("Lists 15 currently queued songs per page. Default page is 1. | `!m lq` or `!m lq 2`") .Parameter("page", ParameterType.Optional) .Do(async e => @@ -161,8 +161,8 @@ namespace NadekoBot.Modules.Music await e.Channel.SendMessage(toSend + string.Join("\n", musicPlayer.Playlist.Skip(startAt).Take(15).Select(v => $"`{number++}.` {v.PrettyName}"))).ConfigureAwait(false); }); - cgb.CreateCommand("nowplaying") - .Alias("np") + cgb.CreateCommand(Prefix + "nowplaying") + .Alias(Prefix + "np") .Description("Shows the song currently playing. | `!m np`") .Do(async e => { @@ -176,8 +176,8 @@ namespace NadekoBot.Modules.Music $"{currentSong.PrettyCurrentTime()}").ConfigureAwait(false); }); - cgb.CreateCommand("volume") - .Alias("vol") + cgb.CreateCommand(Prefix + "volume") + .Alias(Prefix + "vol") .Description("Sets the music volume 0-100% | `!m vol 50`") .Parameter("val", ParameterType.Required) .Do(async e => @@ -198,8 +198,8 @@ namespace NadekoBot.Modules.Music await e.Channel.SendMessage($"๐ŸŽต `Volume set to {volume}%`").ConfigureAwait(false); }); - cgb.CreateCommand("defvol") - .Alias("dv") + cgb.CreateCommand(Prefix + "defvol") + .Alias(Prefix + "dv") .Description("Sets the default music volume when music playback is started (0-100)." + " Persists through restarts. | `!m dv 80`") .Parameter("val", ParameterType.Required) @@ -217,8 +217,8 @@ namespace NadekoBot.Modules.Music await e.Channel.SendMessage($"๐ŸŽต `Default volume set to {volume}%`").ConfigureAwait(false); }); - cgb.CreateCommand("mute") - .Alias("min") + cgb.CreateCommand(Prefix + "mute") + .Alias(Prefix + "min") .Description("Sets the music volume to 0% | `!m min`") .Do(e => { @@ -230,7 +230,7 @@ namespace NadekoBot.Modules.Music musicPlayer.SetVolume(0); }); - cgb.CreateCommand("max") + cgb.CreateCommand(Prefix + "max") .Description("Sets the music volume to 100%. | `!m max`") .Do(e => { @@ -242,7 +242,7 @@ namespace NadekoBot.Modules.Music musicPlayer.SetVolume(100); }); - cgb.CreateCommand("half") + cgb.CreateCommand(Prefix + "half") .Description("Sets the music volume to 50%. | `!m half`") .Do(e => { @@ -254,8 +254,8 @@ namespace NadekoBot.Modules.Music musicPlayer.SetVolume(50); }); - cgb.CreateCommand("shuffle") - .Alias("sh") + cgb.CreateCommand(Prefix + "shuffle") + .Alias(Prefix + "sh") .Description("Shuffles the current playlist. | `!m sh`") .Do(async e => { @@ -274,8 +274,8 @@ namespace NadekoBot.Modules.Music await e.Channel.SendMessage("๐ŸŽต `Songs shuffled.`").ConfigureAwait(false); }); - cgb.CreateCommand("playlist") - .Alias("pl") + cgb.CreateCommand(Prefix + "playlist") + .Alias(Prefix + "pl") .Description("Queues up to 500 songs from a youtube playlist specified by a link, or keywords. | `!m pl playlist link or name`") .Parameter("playlist", ParameterType.Unparsed) .Do(async e => @@ -318,8 +318,8 @@ namespace NadekoBot.Modules.Music await msg.Edit("๐ŸŽต `Playlist queue complete.`").ConfigureAwait(false); }); - cgb.CreateCommand("soundcloudpl") - .Alias("scpl") + cgb.CreateCommand(Prefix + "soundcloudpl") + .Alias(Prefix + "scpl") .Description("Queue a soundcloud playlist using a link. | `!m scpl https://soundcloud.com/saratology/sets/symphony`") .Parameter("pl", ParameterType.Unparsed) .Do(async e => @@ -353,8 +353,8 @@ namespace NadekoBot.Modules.Music } }); - cgb.CreateCommand("localplaylst") - .Alias("lopl") + cgb.CreateCommand(Prefix + "localplaylst") + .Alias(Prefix + "lopl") .Description("Queues all songs from a directory. **Bot Owner Only!** | `!m lopl C:/music/classical`") .Parameter("directory", ParameterType.Unparsed) .AddCheck(SimpleCheckers.OwnerOnly()) @@ -384,7 +384,7 @@ namespace NadekoBot.Modules.Music catch { } }); - cgb.CreateCommand("radio").Alias("ra") + cgb.CreateCommand(Prefix + "radio").Alias(Prefix + "ra") .Description("Queues a radio stream from a link. It can be a direct mp3 radio stream, .m3u, .pls .asx or .xspf (Usage Video: ) | `!m ra radio link here`") .Parameter("radio_link", ParameterType.Required) .Do(async e => @@ -402,8 +402,8 @@ namespace NadekoBot.Modules.Music } }); - cgb.CreateCommand("local") - .Alias("lo") + cgb.CreateCommand(Prefix + "local") + .Alias(Prefix + "lo") .Description("Queues a local file by specifying a full path. **Bot Owner Only!** | `!m lo C:/music/mysong.mp3`") .Parameter("path", ParameterType.Unparsed) .AddCheck(SimpleCheckers.OwnerOnly()) @@ -415,8 +415,8 @@ namespace NadekoBot.Modules.Music await QueueSong(e.User, e.Channel, e.User.VoiceChannel, e.GetArg("path"), musicType: MusicType.Local).ConfigureAwait(false); }); - cgb.CreateCommand("move") - .Alias("mv") + cgb.CreateCommand(Prefix + "move") + .Alias(Prefix + "mv") .Description("Moves the bot to your voice channel. (works only if music is already playing) | `!m mv`") .Do(e => { @@ -427,8 +427,8 @@ namespace NadekoBot.Modules.Music musicPlayer.MoveToVoiceChannel(voiceChannel); }); - cgb.CreateCommand("remove") - .Alias("rm") + cgb.CreateCommand(Prefix + "remove") + .Alias(Prefix + "rm") .Description("Remove a song by its # in the queue, or 'all' to remove whole queue. | `!m rm 5`") .Parameter("num", ParameterType.Required) .Do(async e => @@ -460,8 +460,8 @@ namespace NadekoBot.Modules.Music }); //var msRegex = new Regex(@"(?\d+)>(?\d+)", RegexOptions.Compiled); - cgb.CreateCommand("movesong") - .Alias("ms") + cgb.CreateCommand(Prefix + "movesong") + .Alias(Prefix + "ms") .Description($"Moves a song from one position to another. | `{Prefix} ms` 5>3") .Parameter("fromto") .Do(async e => @@ -496,8 +496,8 @@ namespace NadekoBot.Modules.Music }); - cgb.CreateCommand("setmaxqueue") - .Alias("smq") + cgb.CreateCommand(Prefix + "setmaxqueue") + .Alias(Prefix + "smq") .Description($"Sets a maximum queue size. Supply 0 or no argument to have no limit. | `{Prefix} smq` 50 or `{Prefix} smq`") .Parameter("size", ParameterType.Unparsed) .Do(async e => @@ -519,7 +519,7 @@ namespace NadekoBot.Modules.Music await e.Channel.SendMessage($"๐ŸŽต `Max queue set to {(size == 0 ? ("unlimited") : size + " tracks")}`"); }); - cgb.CreateCommand("cleanup") + cgb.CreateCommand(Prefix + "cleanup") .Description("Cleans up hanging voice connections. **Bot Owner Only!** | `!m cleanup`") .AddCheck(SimpleCheckers.OwnerOnly()) .Do(e => @@ -537,8 +537,8 @@ namespace NadekoBot.Modules.Music } }); - cgb.CreateCommand("reptcursong") - .Alias("rcs") + cgb.CreateCommand(Prefix + "reptcursong") + .Alias(Prefix + "rcs") .Description("Toggles repeat of current song. | `!m rcs`") .Do(async e => { @@ -555,8 +555,8 @@ namespace NadekoBot.Modules.Music .ConfigureAwait(false); }); - cgb.CreateCommand("rpeatplaylst") - .Alias("rpl") + cgb.CreateCommand(Prefix + "rpeatplaylst") + .Alias(Prefix + "rpl") .Description("Toggles repeat of all songs in the queue (every song that finishes is added to the end of the queue). | `!m rpl`") .Do(async e => { @@ -567,7 +567,7 @@ namespace NadekoBot.Modules.Music await e.Channel.SendMessage($"๐ŸŽต๐Ÿ”`Repeat playlist {(currentValue ? "enabled" : "disabled")}`").ConfigureAwait(false); }); - cgb.CreateCommand("save") + cgb.CreateCommand(Prefix + "save") .Description("Saves a playlist under a certain name. Name must be no longer than 20 characters and mustn't contain dashes. | `!m save classical1`") .Parameter("name", ParameterType.Unparsed) .Do(async e => @@ -620,7 +620,7 @@ namespace NadekoBot.Modules.Music }); - cgb.CreateCommand("load") + cgb.CreateCommand(Prefix + "load") .Description("Loads a playlist under a certain name. | `!m load classical-1`") .Parameter("name", ParameterType.Unparsed) .Do(async e => @@ -679,8 +679,8 @@ namespace NadekoBot.Modules.Music } }); - cgb.CreateCommand("playlists") - .Alias("pls") + cgb.CreateCommand(Prefix + "playlists") + .Alias(Prefix + "pls") .Description("Lists all playlists. Paginated. 20 per page. Default page is 0. |`!m pls 1`") .Parameter("num", ParameterType.Optional) .Do(e => @@ -696,8 +696,8 @@ namespace NadekoBot.Modules.Music e.Channel.SendMessage($"```js\n--- List of saved playlists ---\n\n" + string.Join("\n", result.Select(r => $"'{r.Name}-{r.Id}' by {r.Creator} ({r.SongCnt} songs)")) + $"\n\n --- Page {num} ---```").ConfigureAwait(false); }); - cgb.CreateCommand("deleteplaylist") - .Alias("delpls") + cgb.CreateCommand(Prefix + "deleteplaylist") + .Alias(Prefix + "delpls") .Description("Deletes a saved playlist. Only if you made it or if you are the bot owner. | `!m delpls animu-5`") .Parameter("pl", ParameterType.Required) .Do(async e => @@ -713,7 +713,7 @@ namespace NadekoBot.Modules.Music await e.Channel.SendMessage("`Ok.` :ok:").ConfigureAwait(false); }); - cgb.CreateCommand("goto") + cgb.CreateCommand(Prefix + "goto") .Description("Goes to a specific time in seconds in a song.") .Parameter("time") .Do(async e => @@ -750,8 +750,8 @@ namespace NadekoBot.Modules.Music await e.Channel.SendMessage($"`Skipped to {minutes}:{seconds}`").ConfigureAwait(false); }); - cgb.CreateCommand("getlink") - .Alias("gl") + cgb.CreateCommand(Prefix + "getlink") + .Alias(Prefix + "gl") .Description("Shows a link to the currently playing song.") .Do(async e => { @@ -764,8 +764,8 @@ namespace NadekoBot.Modules.Music await e.Channel.SendMessage($"๐ŸŽถ`Current song:` <{curSong.SongInfo.Query}>").ConfigureAwait(false); }); - cgb.CreateCommand("autoplay") - .Alias("ap") + cgb.CreateCommand(Prefix + "autoplay") + .Alias(Prefix + "ap") .Description("Toggles autoplay - When the song is finished, automatically queue a related youtube song. (Works only for youtube songs and when queue is empty)") .Do(async e => { diff --git a/NadekoBot/_Models/JSONModels/Configuration.cs b/NadekoBot/_Models/JSONModels/Configuration.cs index 93f9ebb9..295134fe 100644 --- a/NadekoBot/_Models/JSONModels/Configuration.cs +++ b/NadekoBot/_Models/JSONModels/Configuration.cs @@ -175,7 +175,7 @@ Nadeko Support Server: "; public string Conversations { get; set; } = "<@{0}>"; public string ClashOfClans { get; set; } = ","; public string Help { get; set; } = "-"; - public string Music { get; set; } = "!m"; + public string Music { get; set; } = "!!"; public string Trello { get; set; } = "trello "; public string Games { get; set; } = ">"; public string Gambling { get; set; } = "$"; diff --git a/NadekoBot/bin/Debug/data/config_example.json b/NadekoBot/bin/Debug/data/config_example.json index 469aa4c0..1ae8a26e 100644 --- a/NadekoBot/bin/Debug/data/config_example.json +++ b/NadekoBot/bin/Debug/data/config_example.json @@ -83,7 +83,7 @@ "Conversations": "<@{0}>", "ClashOfClans": ",", "Help": "-", - "Music": "!m", + "Music": "!!", "Trello": "trello ", "Games": ">", "Gambling": "$", From f08f12b0b20c5d6a736a83f2e2358add342e101a Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 19 Jul 2016 20:47:05 +0200 Subject: [PATCH 16/43] Image and isntruction in planting/picking/generatingcurrency are now deleted when image is deleted #387 --- NadekoBot/Modules/Games/Commands/PlantPick.cs | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/NadekoBot/Modules/Games/Commands/PlantPick.cs b/NadekoBot/Modules/Games/Commands/PlantPick.cs index 6f01c170..c417b129 100644 --- a/NadekoBot/Modules/Games/Commands/PlantPick.cs +++ b/NadekoBot/Modules/Games/Commands/PlantPick.cs @@ -1,9 +1,11 @@ ๏ปฟusing Discord; using Discord.Commands; using NadekoBot.Classes; +using NadekoBot.Extensions; using NadekoBot.Modules.Permissions.Classes; using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Security.Cryptography; @@ -44,21 +46,18 @@ namespace NadekoBot.Modules.Games.Commands if (!plantpickCooldowns.TryGetValue(e.Channel.Id, out lastSpawned) || (lastSpawned + new TimeSpan(0, cd, 0)) < now) { var rnd = Math.Abs(GetRandomNumber()); - if ((rnd % 50) == 0) + if ((rnd % 2) == 0) { - var msg = await e.Channel.SendFile(GetRandomCurrencyImagePath()); - var msg2 = await e.Channel.SendMessage($"โ— A random {NadekoBot.Config.CurrencyName} appeared! Pick it up by typing `>pick`"); - plantedFlowerChannels.AddOrUpdate(e.Channel.Id, msg, (u, m) => { m.Delete().GetAwaiter().GetResult(); return msg; }); + var msgs = new[] { await e.Channel.SendFile(GetRandomCurrencyImagePath()), await e.Channel.SendMessage($"โ— A random {NadekoBot.Config.CurrencyName} appeared! Pick it up by typing `>pick`") }; + plantedFlowerChannels.AddOrUpdate(e.Channel.Id, msgs, (u, m) => { m.ForEach(async msgToDelete => { try { await msgToDelete.Delete(); } catch { } }); return msgs; }); plantpickCooldowns.AddOrUpdate(e.Channel.Id, now, (i, d) => now); - await Task.Delay(5000); - await msg2.Delete(); } } } catch { } } //channelid/messageid pair - ConcurrentDictionary plantedFlowerChannels = new ConcurrentDictionary(); + ConcurrentDictionary> plantedFlowerChannels = new ConcurrentDictionary>(); private object locker = new object(); @@ -68,22 +67,24 @@ namespace NadekoBot.Modules.Games.Commands .Description("Picks a flower planted in this channel.") .Do(async e => { - Message msg; + IEnumerable msgs; await e.Message.Delete().ConfigureAwait(false); - if (!plantedFlowerChannels.TryRemove(e.Channel.Id, out msg)) + if (!plantedFlowerChannels.TryRemove(e.Channel.Id, out msgs)) return; - await msg.Delete().ConfigureAwait(false); + foreach(var msgToDelete in msgs) + await msgToDelete.Delete().ConfigureAwait(false); + await FlowersHandler.AddFlowersAsync(e.User, "Picked a flower.", 1, true).ConfigureAwait(false); - msg = await e.Channel.SendMessage($"**{e.User.Name}** picked a {NadekoBot.Config.CurrencyName}!").ConfigureAwait(false); + var msg = await e.Channel.SendMessage($"**{e.User.Name}** picked a {NadekoBot.Config.CurrencyName}!").ConfigureAwait(false); await Task.Delay(10000).ConfigureAwait(false); await msg.Delete().ConfigureAwait(false); }); cgb.CreateCommand(Module.Prefix + "plant") .Description("Spend a flower to plant it in this channel. (If bot is restarted or crashes, flower will be lost)") - .Do(async e => + .Do(e => { lock (locker) { @@ -92,7 +93,7 @@ namespace NadekoBot.Modules.Games.Commands e.Channel.SendMessage($"There is already a {NadekoBot.Config.CurrencyName} in this channel."); return; } - var removed = FlowersHandler.RemoveFlowers(e.User, "Planted a flower.", 1).GetAwaiter().GetResult(); + var removed = FlowersHandler.RemoveFlowers(e.User, "Planted a flower.", 1, true).GetAwaiter().GetResult(); if (!removed) { e.Channel.SendMessage($"You don't have any {NadekoBot.Config.CurrencyName}s.").Wait(); @@ -106,12 +107,10 @@ namespace NadekoBot.Modules.Games.Commands msg = e.Channel.SendMessage(NadekoBot.Config.CurrencySign).GetAwaiter().GetResult(); else msg = e.Channel.SendFile(file).GetAwaiter().GetResult(); - plantedFlowerChannels.TryAdd(e.Channel.Id, msg); + var vowelFirst = new[] { 'a', 'e', 'i', 'o', 'u' }.Contains(NadekoBot.Config.CurrencyName[0]); + var msg2 = e.Channel.SendMessage($"Oh how Nice! **{e.User.Name}** planted {(vowelFirst ? "an" : "a")} {NadekoBot.Config.CurrencyName}. Pick it using {Module.Prefix}pick").GetAwaiter().GetResult(); + plantedFlowerChannels.TryAdd(e.Channel.Id, new[] { msg, msg2 }); } - var vowelFirst = new[] { 'a', 'e', 'i', 'o', 'u' }.Contains(NadekoBot.Config.CurrencyName[0]); - var msg2 = await e.Channel.SendMessage($"Oh how Nice! **{e.User.Name}** planted {(vowelFirst ? "an" : "a")} {NadekoBot.Config.CurrencyName}. Pick it using {Module.Prefix}pick"); - await Task.Delay(20000).ConfigureAwait(false); - await msg2.Delete().ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "gencurrency") From 90612676d378a4f008394bef78e369d2392fd459 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 19 Jul 2016 23:27:19 +0200 Subject: [PATCH 17/43] >gc reduced to 1% --- NadekoBot/Modules/ClashOfClans/ClashOfClansModule.cs | 3 +-- NadekoBot/Modules/Games/Commands/PlantPick.cs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/NadekoBot/Modules/ClashOfClans/ClashOfClansModule.cs b/NadekoBot/Modules/ClashOfClans/ClashOfClansModule.cs index 532f3cbb..9c383509 100644 --- a/NadekoBot/Modules/ClashOfClans/ClashOfClansModule.cs +++ b/NadekoBot/Modules/ClashOfClans/ClashOfClansModule.cs @@ -27,8 +27,7 @@ namespace NadekoBot.Modules.ClashOfClans cgb.CreateCommand(Prefix + "createwar") .Alias(Prefix + "cw") - .Description( - $"Creates a new war by specifying a size (>10 and multiple of 5) and enemy clan name. |{Prefix}cw 15 The Enemy Clan") + .Description($"Creates a new war by specifying a size (>10 and multiple of 5) and enemy clan name. |{Prefix}cw 15 The Enemy Clan") .Parameter("size") .Parameter("enemy_clan", ParameterType.Unparsed) .Do(async e => diff --git a/NadekoBot/Modules/Games/Commands/PlantPick.cs b/NadekoBot/Modules/Games/Commands/PlantPick.cs index c417b129..ec56fc3c 100644 --- a/NadekoBot/Modules/Games/Commands/PlantPick.cs +++ b/NadekoBot/Modules/Games/Commands/PlantPick.cs @@ -45,8 +45,8 @@ namespace NadekoBot.Modules.Games.Commands if (config.GenerateCurrencyChannels.TryGetValue(e.Channel.Id, out cd)) if (!plantpickCooldowns.TryGetValue(e.Channel.Id, out lastSpawned) || (lastSpawned + new TimeSpan(0, cd, 0)) < now) { - var rnd = Math.Abs(GetRandomNumber()); - if ((rnd % 2) == 0) + var rnd = Math.Abs(rng.Next(0,101)); + if (rnd == 0) { var msgs = new[] { await e.Channel.SendFile(GetRandomCurrencyImagePath()), await e.Channel.SendMessage($"โ— A random {NadekoBot.Config.CurrencyName} appeared! Pick it up by typing `>pick`") }; plantedFlowerChannels.AddOrUpdate(e.Channel.Id, msgs, (u, m) => { m.ForEach(async msgToDelete => { try { await msgToDelete.Delete(); } catch { } }); return msgs; }); From 0ea71eb490de355e38ff2646cb8a22e4709d0349 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 20 Jul 2016 16:39:02 +0200 Subject: [PATCH 18/43] ~g is alias for ~google now --- NadekoBot/Modules/Searches/SearchesModule.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/NadekoBot/Modules/Searches/SearchesModule.cs b/NadekoBot/Modules/Searches/SearchesModule.cs index e9a30cc8..15c1c9be 100644 --- a/NadekoBot/Modules/Searches/SearchesModule.cs +++ b/NadekoBot/Modules/Searches/SearchesModule.cs @@ -221,6 +221,7 @@ $@"๐ŸŒ **Weather for** ใ€{obj["target"]}ใ€‘ }); cgb.CreateCommand(Prefix + "google") + .Alias(Prefix + "g") .Description("Get a google search link for some terms.") .Parameter("terms", ParameterType.Unparsed) .Do(async e => From e54f1b8575c5480dc5bd7f906ee78d694cb293c1 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 20 Jul 2016 16:40:05 +0200 Subject: [PATCH 19/43] reduced global nadeko startup wait, added a callback on when the IsReady flag is set to true --- NadekoBot/NadekoBot.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NadekoBot/NadekoBot.cs b/NadekoBot/NadekoBot.cs index ad1b0031..4a091e3e 100644 --- a/NadekoBot/NadekoBot.cs +++ b/NadekoBot/NadekoBot.cs @@ -41,6 +41,7 @@ namespace NadekoBot public static LocalizedStrings Locale { get; set; } = new LocalizedStrings(); public static string BotMention { get; set; } = ""; public static bool Ready { get; set; } = false; + public static Action OnReady { get; set; } = delegate { }; private static List OwnerPrivateChannels { get; set; } @@ -196,7 +197,7 @@ namespace NadekoBot return; } #if NADEKO_RELEASE - await Task.Delay(150000).ConfigureAwait(false); + await Task.Delay(90000).ConfigureAwait(false); #else await Task.Delay(1000).ConfigureAwait(false); #endif @@ -229,6 +230,7 @@ namespace NadekoBot }; PermissionsHandler.Initialize(); NadekoBot.Ready = true; + NadekoBot.OnReady(); }); Console.WriteLine("Exiting..."); Console.ReadKey(); @@ -277,5 +279,3 @@ namespace NadekoBot } } } - -//95520984584429568 meany From 4a45749ae9c54469834c13a41b2a73a35eb3a5a5 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 20 Jul 2016 17:26:52 +0200 Subject: [PATCH 20/43] commandlist updated to reflect 0.99.9 --- commandlist.md | 103 ++++++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 48 deletions(-) diff --git a/commandlist.md b/commandlist.md index 3a9cce39..6ea01ca6 100644 --- a/commandlist.md +++ b/commandlist.md @@ -1,8 +1,8 @@ ######For more information and how to setup your own NadekoBot, go to: **http://github.com/Kwoth/NadekoBot/** -######You can donate on paypal: `nadekodiscordbot@gmail.com` or Bitcoin `17MZz1JAqME39akMLrVT4XBPffQJ2n1EPa` +######You can donate on paypal: `nadekodiscordbot@gmail.com` #NadekoBot List Of Commands -Version: `NadekoBot v0.9.6036.32870` +Version: `NadekoBot v0.9.6045.31170` ### Help Command and aliases | Description | Usage ----------------|--------------|------- @@ -25,6 +25,7 @@ Command and aliases | Description | Usage `.greetpm` | Toggles whether the greet messages will be sent in a PM or in the text channel. `.spmom` | Toggles whether mentions of other offline users on your server will send a pm to them. `.logserver` | Toggles logging in this channel. Logs every message sent/deleted/edited on the server. **Bot Owner Only!** +`.logignore`, `Toggles whether the .logserver command ignores this channel. Useful if you have hidden admin channel and public log channel.` | `.userpresence` | Starts logging to this channel when someone from the server goes online/offline/idle. `.voicepresence` | Toggles logging to this channel whenever someone joins or leaves a voice channel you are in right now. `.repeatinvoke`, `.repinv` | Immediately shows the repeat message and restarts the timer. @@ -42,6 +43,7 @@ Command and aliases | Description | Usage `.asar` | Adds a role, or list of roles separated by whitespace(use quotations for multiword roles) to the list of self-assignable roles. | .asar Gamer `.rsar` | Removes a specified role from the list of self-assignable roles. `.lsar` | Lists all self-assignable roles. +`.togglexclsar`, `.tesar` | toggle whether the self-assigned roles should be exclusive `.iam` | Adds a role to you that you choose. Role must be on a list of self-assignable roles. | .iam Gamer `.iamnot`, `.iamn` | Removes a role to you that you choose. Role must be on a list of self-assignable roles. | .iamn Gamer `.addcustreact`, `.acr` | Add a custom reaction. Guide here: **Bot Owner Only!** | .acr "hello" I love saying hello to %user% @@ -86,7 +88,6 @@ Command and aliases | Description | Usage `.donators` | List of lovely people who donated to keep this project alive. `.donadd` | Add a donator to the database. `.announce` | Sends a message to all servers' general channel bot is connected to.**Bot Owner Only!** | .announce Useless spam -`.leave` | Leaves a server with a supplied ID. | `.leave 493243292839` `.savechat` | Saves a number of messages to a text file and sends it to you. **Bot Owner Only** | `.chatsave 150` ### Utility @@ -145,6 +146,8 @@ Command and aliases | Description | Usage `;cbl` | Blacklists a mentioned channel (#general for example). | ;cbl #some_channel `;cubl` | Unblacklists a mentioned channel (#general for example). | ;cubl #some_channel `;sbl` | Blacklists a server by a name or id (#general for example). **BOT OWNER ONLY** | ;sbl [servername/serverid] +`;cmdcooldown`, `;cmdcd` | Sets a cooldown per user for a command. Set 0 to clear. | `;cmdcd "some cmd" 5` +`;allcmdcooldowns`, `;acmdcds` | Shows a list of all commands and their respective cooldowns. ### Conversations Command and aliases | Description | Usage @@ -157,7 +160,6 @@ Command and aliases | Description | Usage `@BotName do you love me` | Replies with positive answer only to the bot owner. `@BotName how are you`, `@BotName how are you?` | Replies positive only if bot owner is online. `@BotName fire` | Shows a unicode fire message. Optional parameter [x] tells her how many times to repeat the fire. | @NadekoBot fire [x] -`@BotName slm` | Shows the message where you were last mentioned in this channel (checks last 10k messages) `@BotName dump` | Dumps all of the invites it can to dump.txt.** Owner Only.** `@BotName ab` | Try to get 'abalabahaha' @@ -167,13 +169,16 @@ Command and aliases | Description | Usage `$draw` | Draws a card from the deck.If you supply number [x], she draws up to 5 cards from the deck. | $draw [x] `$shuffle`, `$sh` | Reshuffles all cards back into the deck. `$flip` | Flips coin(s) - heads or tails, and shows an image. | `$flip` or `$flip 3` +`$betflip`, `$bf` | Bet to guess will the result be heads or tails. Guessing award you double flowers you've bet. | `$bf 5 heads` or `$bf 3 t` `$roll` | Rolls 0-100. If you supply a number [x] it rolls up to 30 normal dice. If you split 2 numbers with letter d (xdy) it will roll x dice from 1 to y. | $roll or $roll 7 or $roll 3d5 +`$rolluo` | Rolls 0-100. If you supply a number [x] it rolls up to 30 normal dice (unordered). If you split 2 numbers with letter d (xdy) it will roll x dice from 1 to y. | $roll or $roll 7 or $roll 3d5 `$nroll` | Rolls in a given range. | `$nroll 5` (rolls 0-5) or `$nroll 5-15` `$raffle` | Prints a name and ID of a random user from the online list from the (optional) role. `$$$` | Check how much NadekoFlowers a person has. (Defaults to yourself) | `$$$` or `$$$ @Someone` `$give` | Give someone a certain amount of NadekoFlowers `$award` | Gives someone a certain amount of flowers. **Bot Owner Only!** | `$award 100 @person` `$take` | Takes a certain amount of flowers from someone. **Bot Owner Only!** +`$betroll`, `$br` | Bets a certain amount of NadekoFlowers and rolls a dice. Rolling over 66 yields x2 flowers, over 90 - x3 and 100 x10. | $br 5 `$leaderboard`, `$lb` | ### Games @@ -199,39 +204,39 @@ Command and aliases | Description | Usage ### Music Command and aliases | Description | Usage ----------------|--------------|------- -`!m next`, `!m n`, `!m skip` | Goes to the next song in the queue. You have to be in the same voice channel as the bot. | `!m n` -`!m stop`, `!m s` | Stops the music and clears the playlist. Stays in the channel. | `!m s` -`!m destroy`, `!m d` | Completely stops the music and unbinds the bot from the channel. (may cause weird behaviour) | `!m d` -`!m pause`, `!m p` | Pauses or Unpauses the song. | `!m p` -`!m queue`, `!m q`, `!m yq` | Queue a song using keywords or a link. Bot will join your voice channel.**You must be in a voice channel**. | `!m q Dream Of Venice` -`!m soundcloudqueue`, `!m sq` | Queue a soundcloud song using keywords. Bot will join your voice channel.**You must be in a voice channel**. | `!m sq Dream Of Venice` -`!m listqueue`, `!m lq` | Lists 15 currently queued songs per page. Default page is 1. | `!m lq` or `!m lq 2` -`!m nowplaying`, `!m np` | Shows the song currently playing. | `!m np` -`!m volume`, `!m vol` | Sets the music volume 0-100% | `!m vol 50` -`!m defvol`, `!m dv` | Sets the default music volume when music playback is started (0-100). Persists through restarts. | `!m dv 80` -`!m mute`, `!m min` | Sets the music volume to 0% | `!m min` -`!m max` | Sets the music volume to 100%. | `!m max` -`!m half` | Sets the music volume to 50%. | `!m half` -`!m shuffle`, `!m sh` | Shuffles the current playlist. | `!m sh` -`!m playlist`, `!m pl` | Queues up to 500 songs from a youtube playlist specified by a link, or keywords. | `!m pl playlist link or name` -`!m soundcloudpl`, `!m scpl` | Queue a soundcloud playlist using a link. | `!m scpl https://soundcloud.com/saratology/sets/symphony` -`!m localplaylst`, `!m lopl` | Queues all songs from a directory. **Bot Owner Only!** | `!m lopl C:/music/classical` -`!m radio`, `!m ra` | Queues a radio stream from a link. It can be a direct mp3 radio stream, .m3u, .pls .asx or .xspf | `!m ra radio link here` -`!m local`, `!m lo` | Queues a local file by specifying a full path. **Bot Owner Only!** | `!m lo C:/music/mysong.mp3` -`!m move`, `!m mv` | Moves the bot to your voice channel. (works only if music is already playing) | `!m mv` -`!m remove`, `!m rm` | Remove a song by its # in the queue, or 'all' to remove whole queue. | `!m rm 5` -`!m movesong`, `!m ms` | Moves a song from one position to another. | `!m ms` 5>3 -`!m setmaxqueue`, `!m smq` | Sets a maximum queue size. Supply 0 or no argument to have no limit. | `!m smq` 50 or `!m smq` -`!m cleanup` | Cleans up hanging voice connections. **Bot Owner Only!** | `!m cleanup` -`!m reptcursong`, `!m rcs` | Toggles repeat of current song. | `!m rcs` -`!m rpeatplaylst`, `!m rpl` | Toggles repeat of all songs in the queue (every song that finishes is added to the end of the queue). | `!m rpl` -`!m save` | Saves a playlist under a certain name. Name must be no longer than 20 characters and mustn't contain dashes. | `!m save classical1` -`!m load` | Loads a playlist under a certain name. | `!m load classical-1` -`!m playlists`, `!m pls` | Lists all playlists. Paginated. 20 per page. Default page is 0. | `!m pls 1` -`!m deleteplaylist`, `!m delpls` | Deletes a saved playlist. Only if you made it or if you are the bot owner. | `!m delpls animu-5` -`!m goto` | Goes to a specific time in seconds in a song. -`!m getlink`, `!m gl` | Shows a link to the currently playing song. -`!m autoplay`, `!m ap` | Toggles autoplay - When the song is finished, automatically queue a related youtube song. (Works only for youtube songs and when queue is empty) +`!!next`, `!!n`, `!!skip` | Goes to the next song in the queue. You have to be in the same voice channel as the bot. | `!m n` +`!!stop`, `!!s` | Stops the music and clears the playlist. Stays in the channel. | `!m s` +`!!destroy`, `!!d` | Completely stops the music and unbinds the bot from the channel. (may cause weird behaviour) | `!m d` +`!!pause`, `!!p` | Pauses or Unpauses the song. | `!m p` +`!!queue`, `!!q`, `!!yq` | Queue a song using keywords or a link. Bot will join your voice channel.**You must be in a voice channel**. | `!m q Dream Of Venice` +`!!soundcloudqueue`, `!!sq` | Queue a soundcloud song using keywords. Bot will join your voice channel.**You must be in a voice channel**. | `!m sq Dream Of Venice` +`!!listqueue`, `!!lq` | Lists 15 currently queued songs per page. Default page is 1. | `!m lq` or `!m lq 2` +`!!nowplaying`, `!!np` | Shows the song currently playing. | `!m np` +`!!volume`, `!!vol` | Sets the music volume 0-100% | `!m vol 50` +`!!defvol`, `!!dv` | Sets the default music volume when music playback is started (0-100). Persists through restarts. | `!m dv 80` +`!!mute`, `!!min` | Sets the music volume to 0% | `!m min` +`!!max` | Sets the music volume to 100%. | `!m max` +`!!half` | Sets the music volume to 50%. | `!m half` +`!!shuffle`, `!!sh` | Shuffles the current playlist. | `!m sh` +`!!playlist`, `!!pl` | Queues up to 500 songs from a youtube playlist specified by a link, or keywords. | `!m pl playlist link or name` +`!!soundcloudpl`, `!!scpl` | Queue a soundcloud playlist using a link. | `!m scpl https://soundcloud.com/saratology/sets/symphony` +`!!localplaylst`, `!!lopl` | Queues all songs from a directory. **Bot Owner Only!** | `!m lopl C:/music/classical` +`!!radio`, `!!ra` | Queues a radio stream from a link. It can be a direct mp3 radio stream, .m3u, .pls .asx or .xspf (Usage Video: ) | `!m ra radio link here` +`!!local`, `!!lo` | Queues a local file by specifying a full path. **Bot Owner Only!** | `!m lo C:/music/mysong.mp3` +`!!move`, `!!mv` | Moves the bot to your voice channel. (works only if music is already playing) | `!m mv` +`!!remove`, `!!rm` | Remove a song by its # in the queue, or 'all' to remove whole queue. | `!m rm 5` +`!!movesong`, `!!ms` | Moves a song from one position to another. | `!! ms` 5>3 +`!!setmaxqueue`, `!!smq` | Sets a maximum queue size. Supply 0 or no argument to have no limit. | `!! smq` 50 or `!! smq` +`!!cleanup` | Cleans up hanging voice connections. **Bot Owner Only!** | `!m cleanup` +`!!reptcursong`, `!!rcs` | Toggles repeat of current song. | `!m rcs` +`!!rpeatplaylst`, `!!rpl` | Toggles repeat of all songs in the queue (every song that finishes is added to the end of the queue). | `!m rpl` +`!!save` | Saves a playlist under a certain name. Name must be no longer than 20 characters and mustn't contain dashes. | `!m save classical1` +`!!load` | Loads a playlist under a certain name. | `!m load classical-1` +`!!playlists`, `!!pls` | Lists all playlists. Paginated. 20 per page. Default page is 0. | `!m pls 1` +`!!deleteplaylist`, `!!delpls` | Deletes a saved playlist. Only if you made it or if you are the bot owner. | `!m delpls animu-5` +`!!goto` | Goes to a specific time in seconds in a song. +`!!getlink`, `!!gl` | Shows a link to the currently playing song. +`!!autoplay`, `!!ap` | Toggles autoplay - When the song is finished, automatically queue a related youtube song. (Works only for youtube songs and when queue is empty) ### Searches Command and aliases | Description | Usage @@ -266,6 +271,7 @@ Command and aliases | Description | Usage `~i` | Pulls the first image found using a search parameter. Use ~ir for different results. | ~i cute kitten `~ir` | Pulls a random image using a search parameter. | ~ir cute kitten `~lmgtfy` | Google something for an idiot. +`~google`, `~g` | Get a google search link for some terms. `~hs` | Searches for a Hearthstone card and shows its image. Takes a while to complete. | ~hs Ysera `~ud` | Searches Urban Dictionary for a word. | ~ud Pineapple `~#` | Searches Tagdef.com for a hashtag. | ~# ff @@ -313,7 +319,7 @@ Command and aliases | Description | Usage ----------------|--------------|------- `>attack` | Attacks a target with the given move. Use `>movelist` to see a list of moves your type can use. | `>attack "vine whip" @someguy` `>movelist`, `>ml` | Lists the moves you are able to use -`>heal` | Heals someone. Revives those that fainted. Costs a NadekoFlower | >revive @someone +`>heal` | Heals someone. Revives those who fainted. Costs a NadekoFlower | >heal @someone `>type` | Get the poketype of the target. | >type @someone `>settype` | Set your poketype. Costs a NadekoFlower. | >settype fire @@ -331,16 +337,17 @@ Command and aliases | Description | Usage `moveto` | Custom reaction. | moveto `comeatmebro` | Custom reaction. | comeatmebro `e` | Custom reaction. | e -`@BotName insult`, `<@!119777021319577610> insult` | Custom reaction. | %mention% insult -`@BotName praise`, `<@!119777021319577610> praise` | Custom reaction. | %mention% praise -`@BotName pat`, `<@!119777021319577610> pat` | Custom reaction. | %mention% pat -`@BotName cry`, `<@!119777021319577610> cry` | Custom reaction. | %mention% cry -`@BotName are you real?`, `<@!119777021319577610> are you real?` | Custom reaction. | %mention% are you real? -`@BotName are you there?`, `<@!119777021319577610> are you there?` | Custom reaction. | %mention% are you there? -`@BotName draw`, `<@!119777021319577610> draw` | Custom reaction. | %mention% draw -`@BotName bb`, `<@!119777021319577610> bb` | Custom reaction. | %mention% bb -`@BotName call`, `<@!119777021319577610> call` | Custom reaction. | %mention% call -`@BotName disguise`, `<@!119777021319577610> disguise` | Custom reaction. | %mention% disguise +`@BotName insult`, `<@!116275390695079945> insult` | Custom reaction. | %mention% insult +`@BotName praise`, `<@!116275390695079945> praise` | Custom reaction. | %mention% praise +`@BotName pat`, `<@!116275390695079945> pat` | Custom reaction. | %mention% pat +`@BotName cry`, `<@!116275390695079945> cry` | Custom reaction. | %mention% cry +`@BotName are you real?`, `<@!116275390695079945> are you real?` | Custom reaction. | %mention% are you real? +`@BotName are you there?`, `<@!116275390695079945> are you there?` | Custom reaction. | %mention% are you there? +`@BotName draw`, `<@!116275390695079945> draw` | Custom reaction. | %mention% draw +`@BotName bb`, `<@!116275390695079945> bb` | Custom reaction. | %mention% bb +`@BotName call`, `<@!116275390695079945> call` | Custom reaction. | %mention% call +`@BotName disguise`, `<@!116275390695079945> disguise` | Custom reaction. | %mention% disguise +`~hentai` | Custom reaction. | ~hentai ### Trello Command and aliases | Description | Usage From de70e8c87fa51beb2bb01d97e63df0afaae971ea Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 20 Jul 2016 17:38:02 +0200 Subject: [PATCH 21/43] Don't treat warning as errors --- NadekoBot/NadekoBot.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/NadekoBot/NadekoBot.csproj b/NadekoBot/NadekoBot.csproj index 09bc70ea..b2dc869e 100644 --- a/NadekoBot/NadekoBot.csproj +++ b/NadekoBot/NadekoBot.csproj @@ -44,6 +44,7 @@ prompt 4 true + CS AnyCPU From 14c5aeecf5b2862f027837cfd5a84a69138b16b0 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 20 Jul 2016 17:49:20 +0200 Subject: [PATCH 22/43] maybe? --- NadekoBot/NadekoBot.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NadekoBot/NadekoBot.csproj b/NadekoBot/NadekoBot.csproj index b2dc869e..d3984e55 100644 --- a/NadekoBot/NadekoBot.csproj +++ b/NadekoBot/NadekoBot.csproj @@ -40,11 +40,11 @@ full false bin\Debug\ - TRACE;DEBUG;__DEMO__,__DEMO_EXPERIMENTAL__ + TRACE;DEBUG prompt 4 true - CS + CS0612 AnyCPU From 01970345644ead39d2277ca7f957222a2fb9ec2d Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 20 Jul 2016 17:54:01 +0200 Subject: [PATCH 23/43] ok i give up --- NadekoBot/NadekoBot.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NadekoBot/NadekoBot.csproj b/NadekoBot/NadekoBot.csproj index d3984e55..90802d35 100644 --- a/NadekoBot/NadekoBot.csproj +++ b/NadekoBot/NadekoBot.csproj @@ -42,9 +42,9 @@ bin\Debug\ TRACE;DEBUG prompt - 4 + 0 true - CS0612 + 0612 AnyCPU From 659c751055f7b7e7b25bf58b05aadcf20eaafe2f Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 20 Jul 2016 20:25:10 +0200 Subject: [PATCH 24/43] fixed .logignore description/alias --- NadekoBot/Modules/Administration/Commands/LogCommand.cs | 2 +- NadekoBot/NadekoBot.csproj | 5 +++-- commandlist.md | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/NadekoBot/Modules/Administration/Commands/LogCommand.cs b/NadekoBot/Modules/Administration/Commands/LogCommand.cs index 25107ca0..3bbce6d2 100644 --- a/NadekoBot/Modules/Administration/Commands/LogCommand.cs +++ b/NadekoBot/Modules/Administration/Commands/LogCommand.cs @@ -378,7 +378,7 @@ $@"๐Ÿ•”`{prettyCurrentTime}` **Message** ๐Ÿ“ `#{e.Channel.Name}` cgb.CreateCommand(Prefix + "logignore") - .Alias($"Toggles whether the {Prefix}logserver command ignores this channel. Useful if you have hidden admin channel and public log channel.") + .Description($"Toggles whether the {Prefix}logserver command ignores this channel. Useful if you have hidden admin channel and public log channel.") .AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.ManageServer()) .Do(async e => diff --git a/NadekoBot/NadekoBot.csproj b/NadekoBot/NadekoBot.csproj index 90802d35..7feefb56 100644 --- a/NadekoBot/NadekoBot.csproj +++ b/NadekoBot/NadekoBot.csproj @@ -42,9 +42,10 @@ bin\Debug\ TRACE;DEBUG prompt - 0 + 4 true - 0612 + + AnyCPU diff --git a/commandlist.md b/commandlist.md index 6ea01ca6..48ad48d5 100644 --- a/commandlist.md +++ b/commandlist.md @@ -2,7 +2,7 @@ ######You can donate on paypal: `nadekodiscordbot@gmail.com` #NadekoBot List Of Commands -Version: `NadekoBot v0.9.6045.31170` +Version: `NadekoBot v0.9.6045.36710` ### Help Command and aliases | Description | Usage ----------------|--------------|------- @@ -25,7 +25,7 @@ Command and aliases | Description | Usage `.greetpm` | Toggles whether the greet messages will be sent in a PM or in the text channel. `.spmom` | Toggles whether mentions of other offline users on your server will send a pm to them. `.logserver` | Toggles logging in this channel. Logs every message sent/deleted/edited on the server. **Bot Owner Only!** -`.logignore`, `Toggles whether the .logserver command ignores this channel. Useful if you have hidden admin channel and public log channel.` | +`.logignore` | Toggles whether the .logserver command ignores this channel. Useful if you have hidden admin channel and public log channel. `.userpresence` | Starts logging to this channel when someone from the server goes online/offline/idle. `.voicepresence` | Toggles logging to this channel whenever someone joins or leaves a voice channel you are in right now. `.repeatinvoke`, `.repinv` | Immediately shows the repeat message and restarts the timer. From c5c9e98b516a6ef4aa51999e306be429e803aa9c Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 20 Jul 2016 22:41:02 +0200 Subject: [PATCH 25/43] fix #429 --- NadekoBot/Modules/Searches/SearchesModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NadekoBot/Modules/Searches/SearchesModule.cs b/NadekoBot/Modules/Searches/SearchesModule.cs index 15c1c9be..1a2ed20b 100644 --- a/NadekoBot/Modules/Searches/SearchesModule.cs +++ b/NadekoBot/Modules/Searches/SearchesModule.cs @@ -226,10 +226,10 @@ $@"๐ŸŒ **Weather for** ใ€{obj["target"]}ใ€‘ .Parameter("terms", ParameterType.Unparsed) .Do(async e => { - var terms = e.GetArg("terms")?.Trim().Replace(' ', '+'); + var terms = e.GetArg("terms")?.Trim(); if (string.IsNullOrWhiteSpace(terms)) return; - await e.Channel.SendMessage($"https://google.com/search?q={ HttpUtility.UrlEncode(terms) }") + await e.Channel.SendMessage($"https://google.com/search?q={ HttpUtility.UrlEncode(terms).Replace(' ', '+') }") .ConfigureAwait(false); }); From 2e6bdc9f08d1af46cd5b4cc788b2405cab89a0df Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 20 Jul 2016 22:51:41 +0200 Subject: [PATCH 26/43] woops, fixed #426 , no longer saying queue full when its not --- NadekoBot/Modules/Music/Classes/MusicControls.cs | 2 -- NadekoBot/Modules/Music/MusicModule.cs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/NadekoBot/Modules/Music/Classes/MusicControls.cs b/NadekoBot/Modules/Music/Classes/MusicControls.cs index 41e8c7c1..146ca5ea 100644 --- a/NadekoBot/Modules/Music/Classes/MusicControls.cs +++ b/NadekoBot/Modules/Music/Classes/MusicControls.cs @@ -27,8 +27,6 @@ namespace NadekoBot.Modules.Music.Classes public class MusicPlayer { - public static int MaximumPlaylistSize => 50; - private IAudioClient audioClient { get; set; } private readonly List playlist = new List(); diff --git a/NadekoBot/Modules/Music/MusicModule.cs b/NadekoBot/Modules/Music/MusicModule.cs index c9900e7c..18b8966c 100644 --- a/NadekoBot/Modules/Music/MusicModule.cs +++ b/NadekoBot/Modules/Music/MusicModule.cs @@ -151,7 +151,7 @@ namespace NadekoBot.Modules.Music else if (musicPlayer.RepeatPlaylist) toSend += "๐Ÿ”"; toSend += $" **{musicPlayer.Playlist.Count}** `tracks currently queued. Showing page {page}` "; - if (musicPlayer.Playlist.Count >= MusicPlayer.MaximumPlaylistSize) + if (musicPlayer.Playlist.Count >= musicPlayer.MaxQueueSize) toSend += "**Song queue is full!**\n"; else toSend += "\n"; From ae6deee1db4c6fefaf196b6e77cda8266b6b7cd0 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 20 Jul 2016 22:58:41 +0200 Subject: [PATCH 27/43] ace is the strongest high card #423 --- NadekoBot/Modules/Gambling/Helpers/Cards.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NadekoBot/Modules/Gambling/Helpers/Cards.cs b/NadekoBot/Modules/Gambling/Helpers/Cards.cs index 76dc73a5..1cd4ba95 100644 --- a/NadekoBot/Modules/Gambling/Helpers/Cards.cs +++ b/NadekoBot/Modules/Gambling/Helpers/Cards.cs @@ -226,7 +226,7 @@ namespace NadekoBot.Modules.Gambling.Helpers { return kvp.Key; } - return "High card " + cards.Max().GetName(); + return "High card " + (cards.FirstOrDefault(c => c.Number == 1)?.GetName() ?? cards.Max().GetName()); } } } From c06047b67c670c23aab70d4cc07584875d3880ef Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 21 Jul 2016 01:51:47 +0200 Subject: [PATCH 28/43] reduced per user cooldown to 1 second --- NadekoBot/Modules/Permissions/Classes/PermissionChecker.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NadekoBot/Modules/Permissions/Classes/PermissionChecker.cs b/NadekoBot/Modules/Permissions/Classes/PermissionChecker.cs index 94de43f6..412ce69a 100644 --- a/NadekoBot/Modules/Permissions/Classes/PermissionChecker.cs +++ b/NadekoBot/Modules/Permissions/Classes/PermissionChecker.cs @@ -26,8 +26,8 @@ namespace NadekoBot.Modules.Permissions.Classes { while (true) { - //blacklist is cleared every 1.75 seconds. That is the most time anyone will be blocked - await Task.Delay(1750).ConfigureAwait(false); + //blacklist is cleared every 1.00 seconds. That is the most time anyone will be blocked + await Task.Delay(1000).ConfigureAwait(false); timeBlackList.Clear(); } }); From b506064d37ed837a24acfd9d6927bd80399211b8 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 21 Jul 2016 02:13:16 +0200 Subject: [PATCH 29/43] rewrite started --- .../Modules/Music/Classes/MusicControls.cs | 200 ++++++++++-------- 1 file changed, 111 insertions(+), 89 deletions(-) diff --git a/NadekoBot/Modules/Music/Classes/MusicControls.cs b/NadekoBot/Modules/Music/Classes/MusicControls.cs index 146ca5ea..2f0082ee 100644 --- a/NadekoBot/Modules/Music/Classes/MusicControls.cs +++ b/NadekoBot/Modules/Music/Classes/MusicControls.cs @@ -2,7 +2,9 @@ using Discord.Audio; using NadekoBot.Extensions; using System; +using System.Collections.Concurrent; using System.Collections.Generic; +using System.Linq; using System.Threading; using System.Threading.Tasks; namespace NadekoBot.Modules.Music.Classes @@ -52,6 +54,8 @@ namespace NadekoBot.Modules.Music.Classes public bool Autoplay { get; set; } = false; public uint MaxQueueSize { get; set; } = 0; + private ConcurrentQueue actionQueue { get; set; } = new ConcurrentQueue(); + public MusicPlayer(Channel startingVoiceChannel, float? defaultVolume) { if (startingVoiceChannel == null) @@ -66,65 +70,92 @@ namespace NadekoBot.Modules.Music.Classes Task.Run(async () => { - while (!Destroyed) + try { - try - { - if (audioClient?.State != ConnectionState.Connected) - audioClient = await PlaybackVoiceChannel.JoinAudio().ConfigureAwait(false); - } - catch - { - await Task.Delay(1000).ConfigureAwait(false); - continue; - } - CurrentSong = GetNextSong(); - var curSong = CurrentSong; - if (curSong != null) + while (!Destroyed) { try { - OnStarted(this, curSong); - await curSong.Play(audioClient, cancelToken).ConfigureAwait(false); + Action action; + if (actionQueue.TryDequeue(out action)) + { + action(); + } } - catch (OperationCanceledException) + finally { - Console.WriteLine("Song canceled"); + await Task.Delay(100).ConfigureAwait(false); } - catch (Exception ex) - { - Console.WriteLine($"Exception in PlaySong: {ex}"); - } - OnCompleted(this, curSong); - curSong = CurrentSong; //to check if its null now - if (curSong != null) - if (RepeatSong) - playlist.Insert(0, curSong); - else if (RepeatPlaylist) - playlist.Insert(playlist.Count, curSong); - SongCancelSource = new CancellationTokenSource(); - cancelToken = SongCancelSource.Token; } - await Task.Delay(1000).ConfigureAwait(false); } - }); + catch (Exception ex) + { + Console.WriteLine("Action queue crashed"); + Console.WriteLine(ex); + } + }).ConfigureAwait(false); + + var t = new Thread(new ThreadStart(async () => + { + try + { + while (!Destroyed) + { + try + { + if (audioClient.State != ConnectionState.Connected) + { + audioClient = await PlaybackVoiceChannel.JoinAudio(); + continue; + } + + var song = CurrentSong; + + if (song == null) + continue; + + try + { + await song.Play(audioClient, cancelToken); + } + catch (OperationCanceledException) + { + Console.WriteLine("Song canceled"); + SongCancelSource = new CancellationTokenSource(); + cancelToken = SongCancelSource.Token; + } + OnCompleted(this, song); + + if (RepeatPlaylist) + AddSong(song, song.QueuerName); + + if (RepeatSong) + AddSong(song, 0); + } + finally + { + await Task.Delay(300).ConfigureAwait(false); + } + } + } + catch (Exception ex) { + Console.WriteLine("Music thread crashed."); + Console.WriteLine(ex); + } + })); + + t.Start(); } public void Next() { - lock (playlistLock) - { - if (!SongCancelSource.IsCancellationRequested) - { - Paused = false; - SongCancelSource.Cancel(); - } - } + Paused = false; + SongCancelSource.Cancel(); } public void Stop() { - lock (playlistLock) + actionQueue.Enqueue(() => { playlist.Clear(); CurrentSong = null; @@ -132,19 +163,11 @@ namespace NadekoBot.Modules.Music.Classes RepeatSong = false; if (!SongCancelSource.IsCancellationRequested) SongCancelSource.Cancel(); - } + }); } public void TogglePause() => Paused = !Paused; - public void Shuffle() - { - lock (playlistLock) - { - playlist.Shuffle(); - } - } - public int SetVolume(int volume) { if (volume < 0) @@ -156,16 +179,15 @@ namespace NadekoBot.Modules.Music.Classes return volume; } - private Song GetNextSong() + private Song GetNextSong() => + playlist.FirstOrDefault(); + + public void Shuffle() { - lock (playlistLock) + actionQueue.Enqueue(() => { - if (playlist.Count == 0) - return null; - var toReturn = playlist[0]; - playlist.RemoveAt(0); - return toReturn; - } + playlist.Shuffle(); + }); } public void AddSong(Song s, string username) @@ -173,42 +195,63 @@ namespace NadekoBot.Modules.Music.Classes if (s == null) throw new ArgumentNullException(nameof(s)); ThrowIfQueueFull(); - lock (playlistLock) + actionQueue.Enqueue(() => { s.MusicPlayer = this; s.QueuerName = username.TrimTo(10); playlist.Add(s); - } + }); } public void AddSong(Song s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); - lock (playlistLock) + actionQueue.Enqueue(() => { playlist.Insert(index, s); - } + }); } public void RemoveSong(Song s) { if (s == null) throw new ArgumentNullException(nameof(s)); - lock (playlistLock) + actionQueue.Enqueue(() => { playlist.Remove(s); - } + }); } public void RemoveSongAt(int index) { - lock (playlistLock) + actionQueue.Enqueue(() => { if (index < 0 || index >= playlist.Count) - throw new ArgumentException("Invalid index"); + return; playlist.RemoveAt(index); - } + }); + } + + internal void ClearQueue() + { + actionQueue.Enqueue(() => + { + playlist.Clear(); + }); + } + + public void Destroy() + { + actionQueue.Enqueue(() => + { + playlist.Clear(); + Destroyed = true; + CurrentSong = null; + if (!SongCancelSource.IsCancellationRequested) + SongCancelSource.Cancel(); + audioClient.Disconnect(); + }); } internal Task MoveToVoiceChannel(Channel voiceChannel) @@ -219,27 +262,6 @@ namespace NadekoBot.Modules.Music.Classes return PlaybackVoiceChannel.JoinAudio(); } - internal void ClearQueue() - { - lock (playlistLock) - { - playlist.Clear(); - } - } - - public void Destroy() - { - lock (playlistLock) - { - playlist.Clear(); - Destroyed = true; - CurrentSong = null; - if (!SongCancelSource.IsCancellationRequested) - SongCancelSource.Cancel(); - audioClient.Disconnect(); - } - } - internal bool ToggleRepeatSong() => this.RepeatSong = !this.RepeatSong; internal bool ToggleRepeatPlaylist() => this.RepeatPlaylist = !this.RepeatPlaylist; From c6af3a6c3eccb58c5f378aa09e50ec3ac405152f Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 21 Jul 2016 12:42:17 +0200 Subject: [PATCH 30/43] more musicplayer fixes/rewrites --- .../Modules/Music/Classes/MusicControls.cs | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/NadekoBot/Modules/Music/Classes/MusicControls.cs b/NadekoBot/Modules/Music/Classes/MusicControls.cs index 2f0082ee..7cc43771 100644 --- a/NadekoBot/Modules/Music/Classes/MusicControls.cs +++ b/NadekoBot/Modules/Music/Classes/MusicControls.cs @@ -22,7 +22,6 @@ namespace NadekoBot.Modules.Music.Classes { Resolving, Queued, - Buffering, //not using it atm Playing, Completed } @@ -35,7 +34,7 @@ namespace NadekoBot.Modules.Music.Classes public IReadOnlyCollection Playlist => playlist; private readonly object playlistLock = new object(); - public Song CurrentSong { get; set; } = default(Song); + public Song CurrentSong { get; private set; } private CancellationTokenSource SongCancelSource { get; set; } private CancellationToken cancelToken { get; set; } @@ -103,20 +102,22 @@ namespace NadekoBot.Modules.Music.Classes { try { - if (audioClient.State != ConnectionState.Connected) + if (audioClient?.State != ConnectionState.Connected) { audioClient = await PlaybackVoiceChannel.JoinAudio(); continue; } - var song = CurrentSong; + CurrentSong = GetNextSong(); + RemoveSongAt(0); - if (song == null) + if (CurrentSong == null) continue; try { - await song.Play(audioClient, cancelToken); + OnStarted(this, CurrentSong); + await CurrentSong.Play(audioClient, cancelToken); } catch (OperationCanceledException) { @@ -124,17 +125,19 @@ namespace NadekoBot.Modules.Music.Classes SongCancelSource = new CancellationTokenSource(); cancelToken = SongCancelSource.Token; } - OnCompleted(this, song); + OnCompleted(this, CurrentSong); if (RepeatPlaylist) - AddSong(song, song.QueuerName); + AddSong(CurrentSong, CurrentSong.QueuerName); if (RepeatSong) - AddSong(song, 0); + AddSong(CurrentSong, 0); + } finally { await Task.Delay(300).ConfigureAwait(false); + CurrentSong = null; } } } @@ -149,18 +152,20 @@ namespace NadekoBot.Modules.Music.Classes public void Next() { - Paused = false; - SongCancelSource.Cancel(); + actionQueue.Enqueue(() => + { + Paused = false; + SongCancelSource.Cancel(); + }); } public void Stop() { actionQueue.Enqueue(() => { - playlist.Clear(); - CurrentSong = null; RepeatPlaylist = false; RepeatSong = false; + playlist.Clear(); if (!SongCancelSource.IsCancellationRequested) SongCancelSource.Cancel(); }); @@ -245,9 +250,10 @@ namespace NadekoBot.Modules.Music.Classes { actionQueue.Enqueue(() => { - playlist.Clear(); + RepeatPlaylist = false; + RepeatSong = false; Destroyed = true; - CurrentSong = null; + playlist.Clear(); if (!SongCancelSource.IsCancellationRequested) SongCancelSource.Cancel(); audioClient.Disconnect(); From a8f33e56656ba15de910cead14a0c51d59747876 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 21 Jul 2016 12:42:48 +0200 Subject: [PATCH 31/43] song queue full real fix --- NadekoBot/Modules/Games/Commands/PlantPick.cs | 1 - NadekoBot/Modules/Games/Commands/SpeedTyping.cs | 2 -- NadekoBot/Modules/Music/MusicModule.cs | 3 +-- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/NadekoBot/Modules/Games/Commands/PlantPick.cs b/NadekoBot/Modules/Games/Commands/PlantPick.cs index ec56fc3c..6af69857 100644 --- a/NadekoBot/Modules/Games/Commands/PlantPick.cs +++ b/NadekoBot/Modules/Games/Commands/PlantPick.cs @@ -102,7 +102,6 @@ namespace NadekoBot.Modules.Games.Commands var file = GetRandomCurrencyImagePath(); Message msg; - //todo send message after, not in lock if (file == null) msg = e.Channel.SendMessage(NadekoBot.Config.CurrencySign).GetAwaiter().GetResult(); else diff --git a/NadekoBot/Modules/Games/Commands/SpeedTyping.cs b/NadekoBot/Modules/Games/Commands/SpeedTyping.cs index 8a807208..c224de1d 100644 --- a/NadekoBot/Modules/Games/Commands/SpeedTyping.cs +++ b/NadekoBot/Modules/Games/Commands/SpeedTyping.cs @@ -190,8 +190,6 @@ namespace NadekoBot.Modules.Games.Commands await e.Channel.SendMessage("Added new article for typing game.").ConfigureAwait(false); }); - - //todo add user submissions } } } diff --git a/NadekoBot/Modules/Music/MusicModule.cs b/NadekoBot/Modules/Music/MusicModule.cs index 18b8966c..9148c6b9 100644 --- a/NadekoBot/Modules/Music/MusicModule.cs +++ b/NadekoBot/Modules/Music/MusicModule.cs @@ -151,7 +151,7 @@ namespace NadekoBot.Modules.Music else if (musicPlayer.RepeatPlaylist) toSend += "๐Ÿ”"; toSend += $" **{musicPlayer.Playlist.Count}** `tracks currently queued. Showing page {page}` "; - if (musicPlayer.Playlist.Count >= musicPlayer.MaxQueueSize) + if (musicPlayer.MaxQueueSize != 0 && musicPlayer.Playlist.Count >= musicPlayer.MaxQueueSize) toSend += "**Song queue is full!**\n"; else toSend += "\n"; @@ -300,7 +300,6 @@ namespace NadekoBot.Modules.Music await e.Channel.SendMessage($"๐ŸŽต `Failed to find any songs.`").ConfigureAwait(false); return; } - //todo TEMPORARY SOLUTION, USE RESOLVE QUEUE IN THE FUTURE var idArray = ids as string[] ?? ids.ToArray(); var count = idArray.Length; var msg = From f1cf11ae8e6703880f29aea277ca396b024cfbd6 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 21 Jul 2016 12:50:33 +0200 Subject: [PATCH 32/43] ~trans now correctly translates multiple sentences at once. Thanks @Myoshu --- NadekoBot/Modules/Translator/Helpers/GoogleTranslator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NadekoBot/Modules/Translator/Helpers/GoogleTranslator.cs b/NadekoBot/Modules/Translator/Helpers/GoogleTranslator.cs index 1743af45..e6abf475 100644 --- a/NadekoBot/Modules/Translator/Helpers/GoogleTranslator.cs +++ b/NadekoBot/Modules/Translator/Helpers/GoogleTranslator.cs @@ -60,7 +60,7 @@ namespace NadekoBot.Modules.Translator.Helpers text = await http.GetStringAsync(url).ConfigureAwait(false); } - return JArray.Parse(text)[0][0][0].ToString(); + return (string.Join("", JArray.Parse(text)[0].Select(x => x[0]))); } #endregion From ee415d166eee0175481a5fefc04bbff82cce1fbb Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 21 Jul 2016 12:57:57 +0200 Subject: [PATCH 33/43] string.join("" -> string.concat --- NadekoBot/Classes/Extensions.cs | 6 +++--- NadekoBot/Classes/SearchHelper.cs | 2 +- NadekoBot/Modules/Gambling/Helpers/Cards.cs | 2 +- NadekoBot/Modules/Searches/Commands/MemegenCommands.cs | 2 +- NadekoBot/Modules/Translator/Helpers/GoogleTranslator.cs | 2 +- NadekoBot/Modules/Utility/UtilityModule.cs | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/NadekoBot/Classes/Extensions.cs b/NadekoBot/Classes/Extensions.cs index 1b162209..a4071ded 100644 --- a/NadekoBot/Classes/Extensions.cs +++ b/NadekoBot/Classes/Extensions.cs @@ -46,10 +46,10 @@ namespace NadekoBot.Extensions if (num == 0) return string.Empty; if (num <= 3) - return string.Join("", str.Select(c => '.')); + return string.Concat(str.Select(c => '.')); if (str.Length < num) return str; - return string.Join("", str.Take(num - 3)) + (hideDots ? "" : "..."); + return string.Concat(str.Take(num - 3)) + (hideDots ? "" : "..."); } /// /// Removes trailing S or ES (if specified) on the given string if the num is 1 @@ -237,7 +237,7 @@ namespace NadekoBot.Extensions public static string Matrix(this string s) => - string.Join("", s.Select(c => c.ToString() + " ฬฌอ‹ฬ‰ฬœอ‰ฬžฬŽฬญฬตอฌฬ”ฬ‡ฬ–ฬŒฬฐฬขอ€".TrimTo(rng.Next(0, 12), true))); + string.Concat(s.Select(c => c.ToString() + " ฬฌอ‹ฬ‰ฬœอ‰ฬžฬŽฬญฬตอฌฬ”ฬ‡ฬ–ฬŒฬฐฬขอ€".TrimTo(rng.Next(0, 12), true))); //.Replace("`", ""); public static void ForEach(this IEnumerable source, Action action) diff --git a/NadekoBot/Classes/SearchHelper.cs b/NadekoBot/Classes/SearchHelper.cs index 77c46151..43bfbe37 100644 --- a/NadekoBot/Classes/SearchHelper.cs +++ b/NadekoBot/Classes/SearchHelper.cs @@ -384,7 +384,7 @@ namespace NadekoBot.Classes { var i = 0; return "```xl\n" + string.Join("\n", items.GroupBy(item => (i++) / cols) - .Select(ig => string.Join("", ig.Select(el => howToPrint(el))))) + .Select(ig => string.Concat(ig.Select(el => howToPrint(el))))) + $"\n```"; } } diff --git a/NadekoBot/Modules/Gambling/Helpers/Cards.cs b/NadekoBot/Modules/Gambling/Helpers/Cards.cs index 1cd4ba95..8408535e 100644 --- a/NadekoBot/Modules/Gambling/Helpers/Cards.cs +++ b/NadekoBot/Modules/Gambling/Helpers/Cards.cs @@ -146,7 +146,7 @@ namespace NadekoBot.Modules.Gambling.Helpers var orderedPool = cardPool.OrderBy(x => r.Next()); cardPool = cardPool as List ?? orderedPool.ToList(); } - public override string ToString() => string.Join("", cardPool.Select(c => c.ToString())) + Environment.NewLine; + public override string ToString() => string.Concat(cardPool.Select(c => c.ToString())) + Environment.NewLine; private static void InitHandValues() { diff --git a/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs b/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs index ebbdbf34..5eff7c78 100644 --- a/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs +++ b/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs @@ -25,7 +25,7 @@ namespace NadekoBot.Modules.Searches.Commands string.Join("\n", JsonConvert.DeserializeObject>(await SearchHelper.GetResponseStringAsync("http://memegen.link/templates/")) .Select(kvp => Path.GetFileName(kvp.Value)) .GroupBy(item => (i++) / 4) - .Select(ig => string.Join("", ig.Select(el => $"{el,-17}")))) + .Select(ig => string.Concat(ig.Select(el => $"{el,-17}")))) + $"\n```").ConfigureAwait(false); }); diff --git a/NadekoBot/Modules/Translator/Helpers/GoogleTranslator.cs b/NadekoBot/Modules/Translator/Helpers/GoogleTranslator.cs index e6abf475..b1a10a8c 100644 --- a/NadekoBot/Modules/Translator/Helpers/GoogleTranslator.cs +++ b/NadekoBot/Modules/Translator/Helpers/GoogleTranslator.cs @@ -60,7 +60,7 @@ namespace NadekoBot.Modules.Translator.Helpers text = await http.GetStringAsync(url).ConfigureAwait(false); } - return (string.Join("", JArray.Parse(text)[0].Select(x => x[0]))); + return (string.Concat(JArray.Parse(text)[0].Select(x => x[0]))); } #endregion diff --git a/NadekoBot/Modules/Utility/UtilityModule.cs b/NadekoBot/Modules/Utility/UtilityModule.cs index c85348aa..380e5acf 100644 --- a/NadekoBot/Modules/Utility/UtilityModule.cs +++ b/NadekoBot/Modules/Utility/UtilityModule.cs @@ -48,7 +48,7 @@ namespace NadekoBot.Modules.Utility if (arr.Length == 0) await e.Channel.SendMessage("Nobody. (not 100% sure)").ConfigureAwait(false); else - await e.Channel.SendMessage("```xl\n" + string.Join("\n", arr.GroupBy(item => (i++) / 3).Select(ig => string.Join("", ig.Select(el => $"• {el,-35}")))) + "\n```").ConfigureAwait(false); + await e.Channel.SendMessage("```xl\n" + string.Join("\n", arr.GroupBy(item => (i++) / 3).Select(ig => string.Concat(ig.Select(el => $"• {el,-35}")))) + "\n```").ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "inrole") From d69c783f3fdb294ea542745fb7b93cbd886e4c6a Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 21 Jul 2016 13:23:22 +0200 Subject: [PATCH 34/43] `@nadeko fire` makes more sense now. --- .../Modules/Conversations/Conversations.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/NadekoBot/Modules/Conversations/Conversations.cs b/NadekoBot/Modules/Conversations/Conversations.cs index cdc6eb26..328be562 100644 --- a/NadekoBot/Modules/Conversations/Conversations.cs +++ b/NadekoBot/Modules/Conversations/Conversations.cs @@ -9,13 +9,14 @@ using System; using System.Diagnostics; using System.IO; using System.Linq; +using System.Text; using System.Threading.Tasks; namespace NadekoBot.Modules.Conversations { internal class Conversations : DiscordModule { - private const string firestr = "๐Ÿ”ฅ เธ”เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‡เน‡เธ”เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เธ”เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰ ๐Ÿ”ฅ"; + private const string firestr = "๐Ÿ”ฅ เธ”เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‡เธ”เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เธ”เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰เน‰เน‡เน‡เน‡เน‡เน‡เน‰เน‰เน‰เน‰ ๐Ÿ”ฅ"; public Conversations() { commands.Add(new RipCommand(this)); @@ -153,22 +154,23 @@ namespace NadekoBot.Modules.Conversations .Parameter("times", ParameterType.Optional) .Do(async e => { - var count = 1; - int.TryParse(e.Args[0], out count); - if (count == 0) + int count; + if (string.IsNullOrWhiteSpace(e.Args[0])) count = 1; + else + int.TryParse(e.Args[0], out count); if (count < 1 || count > 12) { - await e.Channel.SendMessage("Number must be between 0 and 12").ConfigureAwait(false); + await e.Channel.SendMessage("Number must be between 1 and 12").ConfigureAwait(false); return; } - var str = ""; + var str = new StringBuilder(); for (var i = 0; i < count; i++) { - str += firestr; + str.Append(firestr); } - await e.Channel.SendMessage(str).ConfigureAwait(false); + await e.Channel.SendMessage(str.ToString()).ConfigureAwait(false); }); cgb.CreateCommand("dump") From 1195a4c9c8ecee1657eb4c19a97cf54c8f035b54 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 21 Jul 2016 14:07:26 +0200 Subject: [PATCH 35/43] resetting buffer? --- NadekoBot/Modules/Music/Classes/Song.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/NadekoBot/Modules/Music/Classes/Song.cs b/NadekoBot/Modules/Music/Classes/Song.cs index e718302e..025863e0 100644 --- a/NadekoBot/Modules/Music/Classes/Song.cs +++ b/NadekoBot/Modules/Music/Classes/Song.cs @@ -31,7 +31,7 @@ namespace NadekoBot.Modules.Music.Classes public SongInfo SongInfo { get; } public string QueuerName { get; set; } - private PoopyBuffer songBuffer { get; } = new PoopyBuffer(NadekoBot.Config.BufferSize); + private PoopyBuffer songBuffer { get; set; } private bool prebufferingComplete { get; set; } = false; public MusicPlayer MusicPlayer { get; set; } @@ -137,6 +137,9 @@ namespace NadekoBot.Modules.Music.Classes internal async Task Play(IAudioClient voiceClient, CancellationToken cancelToken) { + // initialize the buffer here because if this song was playing before (requeued), we must delete old buffer data + songBuffer = new PoopyBuffer(NadekoBot.Config.BufferSize); + var bufferTask = BufferSong(cancelToken).ConfigureAwait(false); var bufferAttempts = 0; const int waitPerAttempt = 500; @@ -145,7 +148,6 @@ namespace NadekoBot.Modules.Music.Classes { await Task.Delay(waitPerAttempt, cancelToken).ConfigureAwait(false); } - cancelToken.ThrowIfCancellationRequested(); Console.WriteLine($"Prebuffering done? in {waitPerAttempt * bufferAttempts}"); const int blockSize = 3840; var attempt = 0; From dfc710cb86df58b16e6830a76288bc2c617bc632 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 21 Jul 2016 14:07:58 +0200 Subject: [PATCH 36/43] fixed "-h command name" when there is no alias --- NadekoBot/Modules/Help/Commands/HelpCommand.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/NadekoBot/Modules/Help/Commands/HelpCommand.cs b/NadekoBot/Modules/Help/Commands/HelpCommand.cs index 3bf86435..623490e4 100644 --- a/NadekoBot/Modules/Help/Commands/HelpCommand.cs +++ b/NadekoBot/Modules/Help/Commands/HelpCommand.cs @@ -24,8 +24,13 @@ namespace NadekoBot.Classes.Help.Commands var com = NadekoBot.Client.GetService().AllCommands .FirstOrDefault(c => c.Text.ToLowerInvariant().Equals(comToFind) || c.Aliases.Select(a => a.ToLowerInvariant()).Contains(comToFind)); + + var str = ""; + var alias = com.Aliases.FirstOrDefault(); + if (alias != null) + str = $" / `{ com.Aliases.FirstOrDefault()}`"; if (com != null) - await e.Channel.SendMessage($"**__Help for `{com.Text}`__ / __`{("" + com.Aliases.FirstOrDefault() + "" ?? "")}`__**\n**Desc:** {com.Description.Replace("|", "\n**Usage:**")}").ConfigureAwait(false); + await e.Channel.SendMessage($@"**__Help for:__ `{com.Text}`**" + str + $"\n**Desc:** {com.Description.Replace("|", "\n**Usage:**")}").ConfigureAwait(false); }).ConfigureAwait(false); }; public static string HelpString { From 1437f60d75f7b284c949d61bc330f28d605a41bb Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 21 Jul 2016 22:35:49 +0200 Subject: [PATCH 37/43] fixed -h for .send --- NadekoBot/Modules/Help/Commands/HelpCommand.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NadekoBot/Modules/Help/Commands/HelpCommand.cs b/NadekoBot/Modules/Help/Commands/HelpCommand.cs index 623490e4..4d3fa441 100644 --- a/NadekoBot/Modules/Help/Commands/HelpCommand.cs +++ b/NadekoBot/Modules/Help/Commands/HelpCommand.cs @@ -5,6 +5,7 @@ using NadekoBot.Modules.Permissions.Classes; using System; using System.IO; using System.Linq; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace NadekoBot.Classes.Help.Commands @@ -30,7 +31,7 @@ namespace NadekoBot.Classes.Help.Commands if (alias != null) str = $" / `{ com.Aliases.FirstOrDefault()}`"; if (com != null) - await e.Channel.SendMessage($@"**__Help for:__ `{com.Text}`**" + str + $"\n**Desc:** {com.Description.Replace("|", "\n**Usage:**")}").ConfigureAwait(false); + await e.Channel.SendMessage($@"**__Help for:__ `{com.Text}`**" + str + $"\n**Desc:** {new Regex(@"\|").Replace(com.Description, "\n**Usage:**",1)}").ConfigureAwait(false); }).ConfigureAwait(false); }; public static string HelpString { From bd2d0098e03ccbc2ecadbde7f4c78b65464104bb Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 22 Jul 2016 13:11:49 +0200 Subject: [PATCH 38/43] Print error to console when .iam throws an exception --- .../Administration/Commands/SelfAssignedRolesCommand.cs | 4 +++- NadekoBot/Modules/Music/Classes/MusicControls.cs | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs b/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs index 51bf8859..d5855eb4 100644 --- a/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs +++ b/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs @@ -1,6 +1,7 @@ ๏ปฟusing Discord.Commands; using NadekoBot.Classes; using NadekoBot.Modules.Permissions.Classes; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -144,9 +145,10 @@ namespace NadekoBot.Modules.Administration.Commands { await e.User.AddRoles(role).ConfigureAwait(false); } - catch + catch (Exception ex) { await e.Channel.SendMessage($":anger:`I am unable to add that role to you. I can't add roles to owners or other roles higher than my role in the role hierarchy.`").ConfigureAwait(false); + Console.WriteLine(ex); } var msg = await e.Channel.SendMessage($":ok:You now have {role.Name} role.").ConfigureAwait(false); await Task.Delay(3000).ConfigureAwait(false); diff --git a/NadekoBot/Modules/Music/Classes/MusicControls.cs b/NadekoBot/Modules/Music/Classes/MusicControls.cs index 7cc43771..bcd661f8 100644 --- a/NadekoBot/Modules/Music/Classes/MusicControls.cs +++ b/NadekoBot/Modules/Music/Classes/MusicControls.cs @@ -32,7 +32,6 @@ namespace NadekoBot.Modules.Music.Classes private readonly List playlist = new List(); public IReadOnlyCollection Playlist => playlist; - private readonly object playlistLock = new object(); public Song CurrentSong { get; private set; } private CancellationTokenSource SongCancelSource { get; set; } From 9a6695cc90778560103c64cd55bc826608040008 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 22 Jul 2016 13:26:05 +0200 Subject: [PATCH 39/43] changed submodule to point to my fork of discord.net --- .gitmodules | 2 +- discord.net | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 9ff1a297..1fa69c2d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "discord.net"] path = discord.net - url = git://github.com/rogueexception/discord.net.git + url = git://github.com/kwoth/discord.net.git diff --git a/discord.net b/discord.net index 6bfeaadd..3e519b5e 160000 --- a/discord.net +++ b/discord.net @@ -1 +1 @@ -Subproject commit 6bfeaaddf0cbc83fe0ca44e6164f61c6f8fdaf27 +Subproject commit 3e519b5e0b33175e5a5ca247322b7082de484e15 From 8a9f6f4e2677c97ca5b8569fe34a36f017ab4d1e Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 22 Jul 2016 13:41:41 +0200 Subject: [PATCH 40/43] .send is now correctly splitting on "|", not "-" (fixed .send) --- NadekoBot/Modules/Administration/AdministrationModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NadekoBot/Modules/Administration/AdministrationModule.cs b/NadekoBot/Modules/Administration/AdministrationModule.cs index cff95af4..ab6dafae 100644 --- a/NadekoBot/Modules/Administration/AdministrationModule.cs +++ b/NadekoBot/Modules/Administration/AdministrationModule.cs @@ -738,7 +738,7 @@ namespace NadekoBot.Modules.Administration if (string.IsNullOrWhiteSpace(msg)) return; - var ids = e.GetArg("ids").Split('-'); + var ids = e.GetArg("ids").Split('|'); if (ids.Length != 2) return; var sid = ulong.Parse(ids[0]); From 68a66e281e367b3e0fa1ca67140935e96f3a1b11 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 22 Jul 2016 15:17:19 +0200 Subject: [PATCH 41/43] fixed error message when doing `.iam`, thanks PeaceLord<3 for debugging --- .../Administration/Commands/SelfAssignedRolesCommand.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs b/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs index d5855eb4..2ef54772 100644 --- a/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs +++ b/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs @@ -1,4 +1,5 @@ ๏ปฟusing Discord.Commands; +using Discord.Net; using NadekoBot.Classes; using NadekoBot.Modules.Permissions.Classes; using System; @@ -145,10 +146,12 @@ namespace NadekoBot.Modules.Administration.Commands { await e.User.AddRoles(role).ConfigureAwait(false); } - catch (Exception ex) + catch(HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.InternalServerError) + { + } + catch (Exception) { await e.Channel.SendMessage($":anger:`I am unable to add that role to you. I can't add roles to owners or other roles higher than my role in the role hierarchy.`").ConfigureAwait(false); - Console.WriteLine(ex); } var msg = await e.Channel.SendMessage($":ok:You now have {role.Name} role.").ConfigureAwait(false); await Task.Delay(3000).ConfigureAwait(false); From c3bd1f5986099f3bb5d539ace48d177f94715371 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 22 Jul 2016 20:50:57 +0200 Subject: [PATCH 42/43] music usages fixed, 64bit release test --- NadekoBot.sln | 44 +++++++++++++++++++ NadekoBot/Classes/DBHandler.cs | 4 +- NadekoBot/Modules/Music/MusicModule.cs | 58 +++++++++++++------------- NadekoBot/NadekoBot.csproj | 40 ++++++++++++++++++ 4 files changed, 114 insertions(+), 32 deletions(-) diff --git a/NadekoBot.sln b/NadekoBot.sln index 155512c4..eb9860d0 100644 --- a/NadekoBot.sln +++ b/NadekoBot.sln @@ -22,51 +22,95 @@ Global EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 FullDebug|Any CPU = FullDebug|Any CPU + FullDebug|x64 = FullDebug|x64 NadekoRelease|Any CPU = NadekoRelease|Any CPU + NadekoRelease|x64 = NadekoRelease|x64 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.Debug|x64.ActiveCfg = Debug|x64 + {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.Debug|x64.Build.0 = Debug|x64 {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.FullDebug|Any CPU.ActiveCfg = Debug|Any CPU {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.FullDebug|Any CPU.Build.0 = Debug|Any CPU + {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.FullDebug|x64.ActiveCfg = Debug|x64 + {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.FullDebug|x64.Build.0 = Debug|x64 {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.NadekoRelease|Any CPU.ActiveCfg = NadekoRelease|Any CPU {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.NadekoRelease|Any CPU.Build.0 = NadekoRelease|Any CPU + {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.NadekoRelease|x64.ActiveCfg = NadekoRelease|x64 + {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.NadekoRelease|x64.Build.0 = NadekoRelease|x64 {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.Release|Any CPU.ActiveCfg = Release|Any CPU {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.Release|Any CPU.Build.0 = Release|Any CPU + {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.Release|x64.ActiveCfg = Release|x64 + {27A886F5-CDDA-4F4A-81EE-6DAFCCE9DE46}.Release|x64.Build.0 = Release|x64 {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.Debug|x64.ActiveCfg = Debug|x64 + {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.Debug|x64.Build.0 = Debug|x64 {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.FullDebug|Any CPU.ActiveCfg = Debug|Any CPU {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.FullDebug|Any CPU.Build.0 = Debug|Any CPU + {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.FullDebug|x64.ActiveCfg = Debug|x64 + {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.FullDebug|x64.Build.0 = Debug|x64 {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.NadekoRelease|Any CPU.ActiveCfg = Release|Any CPU {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.NadekoRelease|Any CPU.Build.0 = Release|Any CPU + {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.NadekoRelease|x64.ActiveCfg = Release|x64 + {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.NadekoRelease|x64.Build.0 = Release|x64 {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.Release|Any CPU.ActiveCfg = Release|Any CPU {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.Release|Any CPU.Build.0 = Release|Any CPU + {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.Release|x64.ActiveCfg = Release|x64 + {7BFEF748-B934-4621-9B11-6302E3A9F6B3}.Release|x64.Build.0 = Release|x64 {8D71A857-879A-4A10-859E-5FF824ED6688}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8D71A857-879A-4A10-859E-5FF824ED6688}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8D71A857-879A-4A10-859E-5FF824ED6688}.Debug|x64.ActiveCfg = Debug|x64 + {8D71A857-879A-4A10-859E-5FF824ED6688}.Debug|x64.Build.0 = Debug|x64 {8D71A857-879A-4A10-859E-5FF824ED6688}.FullDebug|Any CPU.ActiveCfg = Debug|Any CPU {8D71A857-879A-4A10-859E-5FF824ED6688}.FullDebug|Any CPU.Build.0 = Debug|Any CPU + {8D71A857-879A-4A10-859E-5FF824ED6688}.FullDebug|x64.ActiveCfg = Debug|x64 + {8D71A857-879A-4A10-859E-5FF824ED6688}.FullDebug|x64.Build.0 = Debug|x64 {8D71A857-879A-4A10-859E-5FF824ED6688}.NadekoRelease|Any CPU.ActiveCfg = Release|Any CPU {8D71A857-879A-4A10-859E-5FF824ED6688}.NadekoRelease|Any CPU.Build.0 = Release|Any CPU + {8D71A857-879A-4A10-859E-5FF824ED6688}.NadekoRelease|x64.ActiveCfg = Release|x64 + {8D71A857-879A-4A10-859E-5FF824ED6688}.NadekoRelease|x64.Build.0 = Release|x64 {8D71A857-879A-4A10-859E-5FF824ED6688}.Release|Any CPU.ActiveCfg = Release|Any CPU {8D71A857-879A-4A10-859E-5FF824ED6688}.Release|Any CPU.Build.0 = Release|Any CPU + {8D71A857-879A-4A10-859E-5FF824ED6688}.Release|x64.ActiveCfg = Release|x64 + {8D71A857-879A-4A10-859E-5FF824ED6688}.Release|x64.Build.0 = Release|x64 {3091164F-66AE-4543-A63D-167C1116241D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3091164F-66AE-4543-A63D-167C1116241D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3091164F-66AE-4543-A63D-167C1116241D}.Debug|x64.ActiveCfg = Debug|x64 + {3091164F-66AE-4543-A63D-167C1116241D}.Debug|x64.Build.0 = Debug|x64 {3091164F-66AE-4543-A63D-167C1116241D}.FullDebug|Any CPU.ActiveCfg = Debug|Any CPU {3091164F-66AE-4543-A63D-167C1116241D}.FullDebug|Any CPU.Build.0 = Debug|Any CPU + {3091164F-66AE-4543-A63D-167C1116241D}.FullDebug|x64.ActiveCfg = Debug|x64 + {3091164F-66AE-4543-A63D-167C1116241D}.FullDebug|x64.Build.0 = Debug|x64 {3091164F-66AE-4543-A63D-167C1116241D}.NadekoRelease|Any CPU.ActiveCfg = Release|Any CPU {3091164F-66AE-4543-A63D-167C1116241D}.NadekoRelease|Any CPU.Build.0 = Release|Any CPU + {3091164F-66AE-4543-A63D-167C1116241D}.NadekoRelease|x64.ActiveCfg = Release|x64 + {3091164F-66AE-4543-A63D-167C1116241D}.NadekoRelease|x64.Build.0 = Release|x64 {3091164F-66AE-4543-A63D-167C1116241D}.Release|Any CPU.ActiveCfg = Release|Any CPU {3091164F-66AE-4543-A63D-167C1116241D}.Release|Any CPU.Build.0 = Release|Any CPU + {3091164F-66AE-4543-A63D-167C1116241D}.Release|x64.ActiveCfg = Release|x64 + {3091164F-66AE-4543-A63D-167C1116241D}.Release|x64.Build.0 = Release|x64 {1B5603B4-6F8F-4289-B945-7BAAE523D740}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1B5603B4-6F8F-4289-B945-7BAAE523D740}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1B5603B4-6F8F-4289-B945-7BAAE523D740}.Debug|x64.ActiveCfg = Debug|x64 + {1B5603B4-6F8F-4289-B945-7BAAE523D740}.Debug|x64.Build.0 = Debug|x64 {1B5603B4-6F8F-4289-B945-7BAAE523D740}.FullDebug|Any CPU.ActiveCfg = Debug|Any CPU {1B5603B4-6F8F-4289-B945-7BAAE523D740}.FullDebug|Any CPU.Build.0 = Debug|Any CPU + {1B5603B4-6F8F-4289-B945-7BAAE523D740}.FullDebug|x64.ActiveCfg = Debug|x64 + {1B5603B4-6F8F-4289-B945-7BAAE523D740}.FullDebug|x64.Build.0 = Debug|x64 {1B5603B4-6F8F-4289-B945-7BAAE523D740}.NadekoRelease|Any CPU.ActiveCfg = Release|Any CPU {1B5603B4-6F8F-4289-B945-7BAAE523D740}.NadekoRelease|Any CPU.Build.0 = Release|Any CPU + {1B5603B4-6F8F-4289-B945-7BAAE523D740}.NadekoRelease|x64.ActiveCfg = Release|x64 + {1B5603B4-6F8F-4289-B945-7BAAE523D740}.NadekoRelease|x64.Build.0 = Release|x64 {1B5603B4-6F8F-4289-B945-7BAAE523D740}.Release|Any CPU.ActiveCfg = Release|Any CPU {1B5603B4-6F8F-4289-B945-7BAAE523D740}.Release|Any CPU.Build.0 = Release|Any CPU + {1B5603B4-6F8F-4289-B945-7BAAE523D740}.Release|x64.ActiveCfg = Release|x64 + {1B5603B4-6F8F-4289-B945-7BAAE523D740}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/NadekoBot/Classes/DBHandler.cs b/NadekoBot/Classes/DBHandler.cs index 9fb664f9..3f2963cc 100644 --- a/NadekoBot/Classes/DBHandler.cs +++ b/NadekoBot/Classes/DBHandler.cs @@ -161,9 +161,7 @@ namespace NadekoBot.Classes using (var conn = new SQLiteConnection(FilePath)) { foreach (var o in ocol) - { - conn.InsertOrReplace(o, typeof(T)); - } + conn.InsertOrReplace(o); } } diff --git a/NadekoBot/Modules/Music/MusicModule.cs b/NadekoBot/Modules/Music/MusicModule.cs index 9148c6b9..ba04d598 100644 --- a/NadekoBot/Modules/Music/MusicModule.cs +++ b/NadekoBot/Modules/Music/MusicModule.cs @@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "next") .Alias(Prefix + "n") .Alias(Prefix + "skip") - .Description("Goes to the next song in the queue. You have to be in the same voice channel as the bot. | `!m n`") + .Description($"Goes to the next song in the queue. You have to be in the same voice channel as the bot. | `{Prefix}n`") .Do(e => { MusicPlayer musicPlayer; @@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "stop") .Alias(Prefix + "s") - .Description("Stops the music and clears the playlist. Stays in the channel. | `!m s`") + .Description($"Stops the music and clears the playlist. Stays in the channel. | `{Prefix}s`") .Do(e => { MusicPlayer musicPlayer; @@ -67,7 +67,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "destroy") .Alias(Prefix + "d") .Description("Completely stops the music and unbinds the bot from the channel. " + - "(may cause weird behaviour) | `!m d`") + $"(may cause weird behaviour) | `{Prefix}d`") .Do(e => { MusicPlayer musicPlayer; @@ -78,7 +78,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "pause") .Alias(Prefix + "p") - .Description("Pauses or Unpauses the song. | `!m p`") + .Description($"Pauses or Unpauses the song. | `{Prefix}p`") .Do(async e => { MusicPlayer musicPlayer; @@ -96,7 +96,7 @@ namespace NadekoBot.Modules.Music .Alias(Prefix + "q") .Alias(Prefix + "yq") .Description("Queue a song using keywords or a link. Bot will join your voice channel." + - "**You must be in a voice channel**. | `!m q Dream Of Venice`") + $"**You must be in a voice channel**. | `{Prefix}q Dream Of Venice`") .Parameter("query", ParameterType.Unparsed) .Do(async e => { @@ -111,7 +111,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "soundcloudqueue") .Alias(Prefix + "sq") .Description("Queue a soundcloud song using keywords. Bot will join your voice channel." + - "**You must be in a voice channel**. | `!m sq Dream Of Venice`") + $"**You must be in a voice channel**. | `{Prefix}sq Dream Of Venice`") .Parameter("query", ParameterType.Unparsed) .Do(async e => { @@ -125,7 +125,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "listqueue") .Alias(Prefix + "lq") - .Description("Lists 15 currently queued songs per page. Default page is 1. | `!m lq` or `!m lq 2`") + .Description($"Lists 15 currently queued songs per page. Default page is 1. | `{Prefix}lq` or `{Prefix}lq 2`") .Parameter("page", ParameterType.Optional) .Do(async e => { @@ -163,7 +163,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "nowplaying") .Alias(Prefix + "np") - .Description("Shows the song currently playing. | `!m np`") + .Description($"Shows the song currently playing. | `{Prefix}np`") .Do(async e => { MusicPlayer musicPlayer; @@ -178,7 +178,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "volume") .Alias(Prefix + "vol") - .Description("Sets the music volume 0-100% | `!m vol 50`") + .Description($"Sets the music volume 0-100% | `{Prefix}vol 50`") .Parameter("val", ParameterType.Required) .Do(async e => { @@ -201,7 +201,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "defvol") .Alias(Prefix + "dv") .Description("Sets the default music volume when music playback is started (0-100)." + - " Persists through restarts. | `!m dv 80`") + $" Persists through restarts. | `{Prefix}dv 80`") .Parameter("val", ParameterType.Required) .Do(async e => { @@ -219,7 +219,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "mute") .Alias(Prefix + "min") - .Description("Sets the music volume to 0% | `!m min`") + .Description($"Sets the music volume to 0% | `{Prefix}min`") .Do(e => { MusicPlayer musicPlayer; @@ -231,7 +231,7 @@ namespace NadekoBot.Modules.Music }); cgb.CreateCommand(Prefix + "max") - .Description("Sets the music volume to 100%. | `!m max`") + .Description($"Sets the music volume to 100%. | `{Prefix}max`") .Do(e => { MusicPlayer musicPlayer; @@ -243,7 +243,7 @@ namespace NadekoBot.Modules.Music }); cgb.CreateCommand(Prefix + "half") - .Description("Sets the music volume to 50%. | `!m half`") + .Description($"Sets the music volume to 50%. | `{Prefix}half`") .Do(e => { MusicPlayer musicPlayer; @@ -256,7 +256,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "shuffle") .Alias(Prefix + "sh") - .Description("Shuffles the current playlist. | `!m sh`") + .Description($"Shuffles the current playlist. | `{Prefix}sh`") .Do(async e => { MusicPlayer musicPlayer; @@ -276,7 +276,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "playlist") .Alias(Prefix + "pl") - .Description("Queues up to 500 songs from a youtube playlist specified by a link, or keywords. | `!m pl playlist link or name`") + .Description($"Queues up to 500 songs from a youtube playlist specified by a link, or keywords. | `{Prefix}pl playlist link or name`") .Parameter("playlist", ParameterType.Unparsed) .Do(async e => { @@ -319,7 +319,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "soundcloudpl") .Alias(Prefix + "scpl") - .Description("Queue a soundcloud playlist using a link. | `!m scpl https://soundcloud.com/saratology/sets/symphony`") + .Description($"Queue a soundcloud playlist using a link. | `{Prefix}scpl https://soundcloud.com/saratology/sets/symphony`") .Parameter("pl", ParameterType.Unparsed) .Do(async e => { @@ -354,7 +354,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "localplaylst") .Alias(Prefix + "lopl") - .Description("Queues all songs from a directory. **Bot Owner Only!** | `!m lopl C:/music/classical`") + .Description($"Queues all songs from a directory. **Bot Owner Only!** | `{Prefix}lopl C:/music/classical`") .Parameter("directory", ParameterType.Unparsed) .AddCheck(SimpleCheckers.OwnerOnly()) .Do(async e => @@ -384,7 +384,7 @@ namespace NadekoBot.Modules.Music }); cgb.CreateCommand(Prefix + "radio").Alias(Prefix + "ra") - .Description("Queues a radio stream from a link. It can be a direct mp3 radio stream, .m3u, .pls .asx or .xspf (Usage Video: ) | `!m ra radio link here`") + .Description($"Queues a radio stream from a link. It can be a direct mp3 radio stream, .m3u, .pls .asx or .xspf (Usage Video: ) | `{Prefix}ra radio link here`") .Parameter("radio_link", ParameterType.Required) .Do(async e => { @@ -403,7 +403,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "local") .Alias(Prefix + "lo") - .Description("Queues a local file by specifying a full path. **Bot Owner Only!** | `!m lo C:/music/mysong.mp3`") + .Description($"Queues a local file by specifying a full path. **Bot Owner Only!** | `{Prefix}lo C:/music/mysong.mp3`") .Parameter("path", ParameterType.Unparsed) .AddCheck(SimpleCheckers.OwnerOnly()) .Do(async e => @@ -416,7 +416,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "move") .Alias(Prefix + "mv") - .Description("Moves the bot to your voice channel. (works only if music is already playing) | `!m mv`") + .Description($"Moves the bot to your voice channel. (works only if music is already playing) | `{Prefix}mv`") .Do(e => { MusicPlayer musicPlayer; @@ -428,7 +428,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "remove") .Alias(Prefix + "rm") - .Description("Remove a song by its # in the queue, or 'all' to remove whole queue. | `!m rm 5`") + .Description($"Remove a song by its # in the queue, or 'all' to remove whole queue. | `{Prefix}rm 5`") .Parameter("num", ParameterType.Required) .Do(async e => { @@ -497,7 +497,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "setmaxqueue") .Alias(Prefix + "smq") - .Description($"Sets a maximum queue size. Supply 0 or no argument to have no limit. | `{Prefix} smq` 50 or `{Prefix} smq`") + .Description($"Sets a maximum queue size. Supply 0 or no argument to have no limit. | `{Prefix}smq` 50 or `{Prefix}smq`") .Parameter("size", ParameterType.Unparsed) .Do(async e => { @@ -519,7 +519,7 @@ namespace NadekoBot.Modules.Music }); cgb.CreateCommand(Prefix + "cleanup") - .Description("Cleans up hanging voice connections. **Bot Owner Only!** | `!m cleanup`") + .Description($"Cleans up hanging voice connections. **Bot Owner Only!** | `{Prefix}cleanup`") .AddCheck(SimpleCheckers.OwnerOnly()) .Do(e => { @@ -538,7 +538,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "reptcursong") .Alias(Prefix + "rcs") - .Description("Toggles repeat of current song. | `!m rcs`") + .Description($"Toggles repeat of current song. | `{Prefix}rcs`") .Do(async e => { MusicPlayer musicPlayer; @@ -556,7 +556,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "rpeatplaylst") .Alias(Prefix + "rpl") - .Description("Toggles repeat of all songs in the queue (every song that finishes is added to the end of the queue). | `!m rpl`") + .Description($"Toggles repeat of all songs in the queue (every song that finishes is added to the end of the queue). | `{Prefix}rpl`") .Do(async e => { MusicPlayer musicPlayer; @@ -567,7 +567,7 @@ namespace NadekoBot.Modules.Music }); cgb.CreateCommand(Prefix + "save") - .Description("Saves a playlist under a certain name. Name must be no longer than 20 characters and mustn't contain dashes. | `!m save classical1`") + .Description($"Saves a playlist under a certain name. Name must be no longer than 20 characters and mustn't contain dashes. | `{Prefix}save classical1`") .Parameter("name", ParameterType.Unparsed) .Do(async e => { @@ -620,7 +620,7 @@ namespace NadekoBot.Modules.Music }); cgb.CreateCommand(Prefix + "load") - .Description("Loads a playlist under a certain name. | `!m load classical-1`") + .Description($"Loads a playlist under a certain name. | `{Prefix}load classical-1`") .Parameter("name", ParameterType.Unparsed) .Do(async e => { @@ -680,7 +680,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "playlists") .Alias(Prefix + "pls") - .Description("Lists all playlists. Paginated. 20 per page. Default page is 0. |`!m pls 1`") + .Description($"Lists all playlists. Paginated. 20 per page. Default page is 0. |`{Prefix}pls 1`") .Parameter("num", ParameterType.Optional) .Do(e => { @@ -697,7 +697,7 @@ namespace NadekoBot.Modules.Music cgb.CreateCommand(Prefix + "deleteplaylist") .Alias(Prefix + "delpls") - .Description("Deletes a saved playlist. Only if you made it or if you are the bot owner. | `!m delpls animu-5`") + .Description($"Deletes a saved playlist. Only if you made it or if you are the bot owner. | `{Prefix}delpls animu-5`") .Parameter("pl", ParameterType.Required) .Do(async e => { diff --git a/NadekoBot/NadekoBot.csproj b/NadekoBot/NadekoBot.csproj index 7feefb56..cd467b7f 100644 --- a/NadekoBot/NadekoBot.csproj +++ b/NadekoBot/NadekoBot.csproj @@ -76,6 +76,46 @@ MinimumRecommendedRules.ruleset true + + true + bin\x64\Debug\ + TRACE;DEBUG + full + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + true + bin\x64\PRIVATE\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\Release\ + TRACE;NADEKO_RELEASE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + true + ..\packages\VideoLibrary.1.3.3\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\libvideo.dll From 106a779552b7cfc5a81ea2d182126b24f6904dea Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sat, 23 Jul 2016 01:40:44 +0200 Subject: [PATCH 43/43] music commandlist updated --- commandlist.md | 60 +++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/commandlist.md b/commandlist.md index 48ad48d5..50cb13cc 100644 --- a/commandlist.md +++ b/commandlist.md @@ -2,7 +2,7 @@ ######You can donate on paypal: `nadekodiscordbot@gmail.com` #NadekoBot List Of Commands -Version: `NadekoBot v0.9.6045.36710` +Version: `NadekoBot v0.9.6048.2992` ### Help Command and aliases | Description | Usage ----------------|--------------|------- @@ -204,36 +204,36 @@ Command and aliases | Description | Usage ### Music Command and aliases | Description | Usage ----------------|--------------|------- -`!!next`, `!!n`, `!!skip` | Goes to the next song in the queue. You have to be in the same voice channel as the bot. | `!m n` -`!!stop`, `!!s` | Stops the music and clears the playlist. Stays in the channel. | `!m s` -`!!destroy`, `!!d` | Completely stops the music and unbinds the bot from the channel. (may cause weird behaviour) | `!m d` -`!!pause`, `!!p` | Pauses or Unpauses the song. | `!m p` -`!!queue`, `!!q`, `!!yq` | Queue a song using keywords or a link. Bot will join your voice channel.**You must be in a voice channel**. | `!m q Dream Of Venice` -`!!soundcloudqueue`, `!!sq` | Queue a soundcloud song using keywords. Bot will join your voice channel.**You must be in a voice channel**. | `!m sq Dream Of Venice` -`!!listqueue`, `!!lq` | Lists 15 currently queued songs per page. Default page is 1. | `!m lq` or `!m lq 2` -`!!nowplaying`, `!!np` | Shows the song currently playing. | `!m np` -`!!volume`, `!!vol` | Sets the music volume 0-100% | `!m vol 50` -`!!defvol`, `!!dv` | Sets the default music volume when music playback is started (0-100). Persists through restarts. | `!m dv 80` -`!!mute`, `!!min` | Sets the music volume to 0% | `!m min` -`!!max` | Sets the music volume to 100%. | `!m max` -`!!half` | Sets the music volume to 50%. | `!m half` -`!!shuffle`, `!!sh` | Shuffles the current playlist. | `!m sh` -`!!playlist`, `!!pl` | Queues up to 500 songs from a youtube playlist specified by a link, or keywords. | `!m pl playlist link or name` -`!!soundcloudpl`, `!!scpl` | Queue a soundcloud playlist using a link. | `!m scpl https://soundcloud.com/saratology/sets/symphony` -`!!localplaylst`, `!!lopl` | Queues all songs from a directory. **Bot Owner Only!** | `!m lopl C:/music/classical` -`!!radio`, `!!ra` | Queues a radio stream from a link. It can be a direct mp3 radio stream, .m3u, .pls .asx or .xspf (Usage Video: ) | `!m ra radio link here` -`!!local`, `!!lo` | Queues a local file by specifying a full path. **Bot Owner Only!** | `!m lo C:/music/mysong.mp3` -`!!move`, `!!mv` | Moves the bot to your voice channel. (works only if music is already playing) | `!m mv` -`!!remove`, `!!rm` | Remove a song by its # in the queue, or 'all' to remove whole queue. | `!m rm 5` +`!!next`, `!!n`, `!!skip` | Goes to the next song in the queue. You have to be in the same voice channel as the bot. | `!!n` +`!!stop`, `!!s` | Stops the music and clears the playlist. Stays in the channel. | `!!s` +`!!destroy`, `!!d` | Completely stops the music and unbinds the bot from the channel. (may cause weird behaviour) | `!!d` +`!!pause`, `!!p` | Pauses or Unpauses the song. | `!!p` +`!!queue`, `!!q`, `!!yq` | Queue a song using keywords or a link. Bot will join your voice channel.**You must be in a voice channel**. | `!!q Dream Of Venice` +`!!soundcloudqueue`, `!!sq` | Queue a soundcloud song using keywords. Bot will join your voice channel.**You must be in a voice channel**. | `!!sq Dream Of Venice` +`!!listqueue`, `!!lq` | Lists 15 currently queued songs per page. Default page is 1. | `!!lq` or `!!lq 2` +`!!nowplaying`, `!!np` | Shows the song currently playing. | `!!np` +`!!volume`, `!!vol` | Sets the music volume 0-100% | `!!vol 50` +`!!defvol`, `!!dv` | Sets the default music volume when music playback is started (0-100). Persists through restarts. | `!!dv 80` +`!!mute`, `!!min` | Sets the music volume to 0% | `!!min` +`!!max` | Sets the music volume to 100%. | `!!max` +`!!half` | Sets the music volume to 50%. | `!!half` +`!!shuffle`, `!!sh` | Shuffles the current playlist. | `!!sh` +`!!playlist`, `!!pl` | Queues up to 500 songs from a youtube playlist specified by a link, or keywords. | `!!pl playlist link or name` +`!!soundcloudpl`, `!!scpl` | Queue a soundcloud playlist using a link. | `!!scpl https://soundcloud.com/saratology/sets/symphony` +`!!localplaylst`, `!!lopl` | Queues all songs from a directory. **Bot Owner Only!** | `!!lopl C:/music/classical` +`!!radio`, `!!ra` | Queues a radio stream from a link. It can be a direct mp3 radio stream, .m3u, .pls .asx or .xspf (Usage Video: ) | `!!ra radio link here` +`!!local`, `!!lo` | Queues a local file by specifying a full path. **Bot Owner Only!** | `!!lo C:/music/mysong.mp3` +`!!move`, `!!mv` | Moves the bot to your voice channel. (works only if music is already playing) | `!!mv` +`!!remove`, `!!rm` | Remove a song by its # in the queue, or 'all' to remove whole queue. | `!!rm 5` `!!movesong`, `!!ms` | Moves a song from one position to another. | `!! ms` 5>3 -`!!setmaxqueue`, `!!smq` | Sets a maximum queue size. Supply 0 or no argument to have no limit. | `!! smq` 50 or `!! smq` -`!!cleanup` | Cleans up hanging voice connections. **Bot Owner Only!** | `!m cleanup` -`!!reptcursong`, `!!rcs` | Toggles repeat of current song. | `!m rcs` -`!!rpeatplaylst`, `!!rpl` | Toggles repeat of all songs in the queue (every song that finishes is added to the end of the queue). | `!m rpl` -`!!save` | Saves a playlist under a certain name. Name must be no longer than 20 characters and mustn't contain dashes. | `!m save classical1` -`!!load` | Loads a playlist under a certain name. | `!m load classical-1` -`!!playlists`, `!!pls` | Lists all playlists. Paginated. 20 per page. Default page is 0. | `!m pls 1` -`!!deleteplaylist`, `!!delpls` | Deletes a saved playlist. Only if you made it or if you are the bot owner. | `!m delpls animu-5` +`!!setmaxqueue`, `!!smq` | Sets a maximum queue size. Supply 0 or no argument to have no limit. | `!!smq` 50 or `!!smq` +`!!cleanup` | Cleans up hanging voice connections. **Bot Owner Only!** | `!!cleanup` +`!!reptcursong`, `!!rcs` | Toggles repeat of current song. | `!!rcs` +`!!rpeatplaylst`, `!!rpl` | Toggles repeat of all songs in the queue (every song that finishes is added to the end of the queue). | `!!rpl` +`!!save` | Saves a playlist under a certain name. Name must be no longer than 20 characters and mustn't contain dashes. | `!!save classical1` +`!!load` | Loads a playlist under a certain name. | `!!load classical-1` +`!!playlists`, `!!pls` | Lists all playlists. Paginated. 20 per page. Default page is 0. | `!!pls 1` +`!!deleteplaylist`, `!!delpls` | Deletes a saved playlist. Only if you made it or if you are the bot owner. | `!!delpls animu-5` `!!goto` | Goes to a specific time in seconds in a song. `!!getlink`, `!!gl` | Shows a link to the currently playing song. `!!autoplay`, `!!ap` | Toggles autoplay - When the song is finished, automatically queue a related youtube song. (Works only for youtube songs and when queue is empty)