diff --git a/NadekoBot/Modules/Administration/AdministrationModule.cs b/NadekoBot/Modules/Administration/AdministrationModule.cs index 6d6ffacf..445f8bf1 100644 --- a/NadekoBot/Modules/Administration/AdministrationModule.cs +++ b/NadekoBot/Modules/Administration/AdministrationModule.cs @@ -150,7 +150,7 @@ namespace NadekoBot.Modules.Administration var roleToEdit = e.Server.FindRoles(r1).FirstOrDefault(); if (roleToEdit == null) { - await e.Channel.SendMessage("Can't find that role."); + await e.Channel.SendMessage("Can't find that role.").ConfigureAwait(false); return; } @@ -158,15 +158,15 @@ namespace NadekoBot.Modules.Administration { if (roleToEdit.Position > e.Server.CurrentUser.Roles.Max(r => r.Position)) { - await e.Channel.SendMessage("I can't edit roles higher than my highest role."); + await e.Channel.SendMessage("I can't edit roles higher than my highest role.").ConfigureAwait(false); return; } await roleToEdit.Edit(r2); - await e.Channel.SendMessage("Role renamed."); + await e.Channel.SendMessage("Role renamed.").ConfigureAwait(false); } catch (Exception) { - await e.Channel.SendMessage("Failed to rename role. Probably insufficient permissions."); + await e.Channel.SendMessage("Failed to rename role. Probably insufficient permissions.").ConfigureAwait(false); } }); @@ -945,7 +945,7 @@ namespace NadekoBot.Modules.Administration UserName = donator.Name, UserId = (long)donator.Id }); - e.Channel.SendMessage("Successfuly added a new donator. πŸ‘‘"); + e.Channel.SendMessage("Successfuly added a new donator. πŸ‘‘").ConfigureAwait(false); } catch { } }).ConfigureAwait(false); @@ -981,10 +981,10 @@ namespace NadekoBot.Modules.Administration { foreach (var ch in NadekoBot.Client.Servers.Select(s => s.DefaultChannel)) { - await ch.SendMessage(e.GetArg("msg")); + await ch.SendMessage(e.GetArg("msg")).ConfigureAwait(false); } - await e.Channel.SendMessage(":ok:"); + await e.Channel.SendMessage(":ok:").ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "whoplays") @@ -1003,9 +1003,9 @@ namespace NadekoBot.Modules.Administration int i = 0; if (arr.Length == 0) - await e.Channel.SendMessage("Nobody. (not 100% sure)"); + 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```"); + 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); }); cgb.CreateCommand(Prefix + "leave") @@ -1019,8 +1019,8 @@ namespace NadekoBot.Modules.Administration { return; } - await srvr.Leave(); - await e.Channel.SendMessage("`Done.`"); + await srvr.Leave().ConfigureAwait(false); + await e.Channel.SendMessage("`Done.`").ConfigureAwait(false); }); }); diff --git a/NadekoBot/Modules/Administration/Commands/AutoAssignRole.cs b/NadekoBot/Modules/Administration/Commands/AutoAssignRole.cs index c6a5ab9a..c368aa0b 100644 --- a/NadekoBot/Modules/Administration/Commands/AutoAssignRole.cs +++ b/NadekoBot/Modules/Administration/Commands/AutoAssignRole.cs @@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Administration.Commands { if (!e.Server.CurrentUser.ServerPermissions.ManageRoles) { - await e.Channel.SendMessage("I do not have the permission to manage roles."); + await e.Channel.SendMessage("I do not have the permission to manage roles.").ConfigureAwait(false); return; } var r = e.GetArg("role")?.Trim(); @@ -52,19 +52,19 @@ namespace NadekoBot.Modules.Administration.Commands { config.AutoAssignedRole = 0; - await e.Channel.SendMessage("`Auto assign role on user join is now disabled.`"); + await e.Channel.SendMessage("`Auto assign role on user join is now disabled.`").ConfigureAwait(false); return; } var role = e.Server.FindRoles(r).FirstOrDefault(); if (role == null) { - await e.Channel.SendMessage("πŸ’’ `Role not found.`"); + await e.Channel.SendMessage("πŸ’’ `Role not found.`").ConfigureAwait(false); return; } config.AutoAssignedRole = role.Id; - await e.Channel.SendMessage("`Auto assigned role is set.`"); + await e.Channel.SendMessage("`Auto assigned role is set.`").ConfigureAwait(false); }); } diff --git a/NadekoBot/Modules/Administration/Commands/CustomReactionsCommands.cs b/NadekoBot/Modules/Administration/Commands/CustomReactionsCommands.cs index dcda6459..81f9ab40 100644 --- a/NadekoBot/Modules/Administration/Commands/CustomReactionsCommands.cs +++ b/NadekoBot/Modules/Administration/Commands/CustomReactionsCommands.cs @@ -38,7 +38,7 @@ namespace NadekoBot.Modules.Administration.Commands NadekoBot.Config.CustomReactions[name].Add(message); else NadekoBot.Config.CustomReactions.Add(name, new System.Collections.Generic.List() { message }); - await Task.Run(() => Classes.JSONModels.ConfigHandler.SaveConfig()); + await Task.Run(() => Classes.JSONModels.ConfigHandler.SaveConfig()).ConfigureAwait(false); await e.Channel.SendMessage($"Added {name} : {message}").ConfigureAwait(false); }); @@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Administration.Commands int num; if (!int.TryParse(e.GetArg("num"), out num) || num <= 0) return; string result = GetCustomsOnPage(num - 1); //People prefer starting with 1 - await e.Channel.SendMessage(result); + await e.Channel.SendMessage(result).ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "deletecustomreaction") @@ -68,7 +68,7 @@ namespace NadekoBot.Modules.Administration.Commands return; if (!NadekoBot.Config.CustomReactions.ContainsKey(name)) { - await e.Channel.SendMessage("Could not find given commandname"); + await e.Channel.SendMessage("Could not find given commandname").ConfigureAwait(false); return; } string message = ""; @@ -94,8 +94,8 @@ namespace NadekoBot.Modules.Administration.Commands NadekoBot.Config.CustomReactions.Remove(name); message = $"Deleted custom reaction: `{name}`"; } - await Task.Run(() => Classes.JSONModels.ConfigHandler.SaveConfig()); - await e.Channel.SendMessage(message); + await Task.Run(() => Classes.JSONModels.ConfigHandler.SaveConfig()).ConfigureAwait(false); + await e.Channel.SendMessage(message).ConfigureAwait(false); }); } diff --git a/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs b/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs index 1f5c06bb..6b87b55f 100644 --- a/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs +++ b/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs @@ -127,14 +127,14 @@ namespace NadekoBot.Modules.Administration.Commands } catch { - 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.`"); + 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); } var msg = await e.Channel.SendMessage($":ok:You now have {role.Name} role.").ConfigureAwait(false); await Task.Delay(3000); await msg.Delete(); try { - await e.Message.Delete(); + await e.Message.Delete().ConfigureAwait(false); } catch { } }); diff --git a/NadekoBot/Modules/Administration/Commands/SelfCommands.cs b/NadekoBot/Modules/Administration/Commands/SelfCommands.cs index d6e3acd7..e905d807 100644 --- a/NadekoBot/Modules/Administration/Commands/SelfCommands.cs +++ b/NadekoBot/Modules/Administration/Commands/SelfCommands.cs @@ -29,13 +29,13 @@ namespace NadekoBot.Modules.Administration.Commands } if (!server.IsOwner) { - await server.Leave(); + await server.Leave().ConfigureAwait(false); } else { - await server.Delete(); + await server.Delete().ConfigureAwait(false); } - await NadekoBot.SendMessageToOwner("Left server " + server.Name); + await NadekoBot.SendMessageToOwner("Left server " + server.Name).ConfigureAwait(false); }); } } diff --git a/NadekoBot/Modules/Help/HelpModule.cs b/NadekoBot/Modules/Help/HelpModule.cs index f4fa618e..e1597d66 100644 --- a/NadekoBot/Modules/Help/HelpModule.cs +++ b/NadekoBot/Modules/Help/HelpModule.cs @@ -49,8 +49,8 @@ namespace NadekoBot.Modules.Help await e.Channel.SendMessage("That module does not exist.").ConfigureAwait(false); return; } - await e.Channel.SendMessage("`List of commands:` \nβ€’ " + string.Join("\nβ€’ ", cmdsArray.Select(c => c.Text))) - .ConfigureAwait(false); + var i = 0; + await e.Channel.SendMessage("`List Of Commands:`\n```xl\n" + string.Join("\n", cmdsArray.GroupBy(item => (i++) / 3).Select(ig => string.Join("", ig.Select(el => $"{el.Text,-22}")))) + "\n``` `You can type \"-h command name\" to see the help about that specific command.`").ConfigureAwait(false); }); }); } diff --git a/NadekoBot/Modules/Music/Classes/Song.cs b/NadekoBot/Modules/Music/Classes/Song.cs index 976867e0..520ab3d8 100644 --- a/NadekoBot/Modules/Music/Classes/Song.cs +++ b/NadekoBot/Modules/Music/Classes/Song.cs @@ -30,7 +30,7 @@ namespace NadekoBot.Modules.Music.Classes $"**【 {SongInfo.Title.TrimTo(55)} 】**`{(SongInfo.Provider ?? "-")}`"; public SongInfo SongInfo { get; } - private PoopyBuffer songBuffer { get; } = new PoopyBuffer(4.MiB()); + private PoopyBuffer songBuffer { get; } = new PoopyBuffer(NadekoBot.Config.BufferSize); private bool prebufferingComplete { get; set; } = false; public MusicPlayer MusicPlayer { get; set; } diff --git a/NadekoBot/_Models/JSONModels/Configuration.cs b/NadekoBot/_Models/JSONModels/Configuration.cs index 7bd638a0..1b58871a 100644 --- a/NadekoBot/_Models/JSONModels/Configuration.cs +++ b/NadekoBot/_Models/JSONModels/Configuration.cs @@ -1,4 +1,5 @@ ο»Ώusing Discord; +using NadekoBot.Extensions; using Newtonsoft.Json; using System.Collections.Generic; using System.IO; @@ -10,6 +11,7 @@ namespace NadekoBot.Classes.JSONModels public bool DontJoinServers { get; set; } = false; public bool ForwardMessages { get; set; } = true; public bool IsRotatingStatus { get; set; } = false; + public int BufferSize { get; set; } = 4.MiB(); [JsonIgnore] public List Quotes { get; set; } = new List(); diff --git a/NadekoBot/bin/Debug/data/config_example.json b/NadekoBot/bin/Debug/data/config_example.json index ffbe7121..10f0b6c5 100644 --- a/NadekoBot/bin/Debug/data/config_example.json +++ b/NadekoBot/bin/Debug/data/config_example.json @@ -2,6 +2,7 @@ "DontJoinServers": false, "ForwardMessages": true, "IsRotatingStatus": false, + "BufferSize": 4194304, "RemindMessageFormat": "❗⏰**I've been told to remind you to '%message%' now by %user%.**⏰❗", "CustomReactions": { "\\o\\": [