Added buffer size to config. Added ConfigureAwait(false) to a lot of awaits. -commands is far prettier.
This commit is contained in:
parent
b8e90fd6c9
commit
2081afdd2a
@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -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);
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -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<string>() { 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);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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 { }
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -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; }
|
||||
|
@ -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<Quote> Quotes { get; set; } = new List<Quote>();
|
||||
|
@ -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\\": [
|
||||
|
Loading…
Reference in New Issue
Block a user