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();
|
var roleToEdit = e.Server.FindRoles(r1).FirstOrDefault();
|
||||||
if (roleToEdit == null)
|
if (roleToEdit == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Can't find that role.");
|
await e.Channel.SendMessage("Can't find that role.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,15 +158,15 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
if (roleToEdit.Position > e.Server.CurrentUser.Roles.Max(r => r.Position))
|
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;
|
return;
|
||||||
}
|
}
|
||||||
await roleToEdit.Edit(r2);
|
await roleToEdit.Edit(r2);
|
||||||
await e.Channel.SendMessage("Role renamed.");
|
await e.Channel.SendMessage("Role renamed.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
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,
|
UserName = donator.Name,
|
||||||
UserId = (long)donator.Id
|
UserId = (long)donator.Id
|
||||||
});
|
});
|
||||||
e.Channel.SendMessage("Successfuly added a new donator. 👑");
|
e.Channel.SendMessage("Successfuly added a new donator. 👑").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
@ -981,10 +981,10 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
foreach (var ch in NadekoBot.Client.Servers.Select(s => s.DefaultChannel))
|
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")
|
cgb.CreateCommand(Prefix + "whoplays")
|
||||||
@ -1003,9 +1003,9 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if (arr.Length == 0)
|
if (arr.Length == 0)
|
||||||
await e.Channel.SendMessage("Nobody. (not 100% sure)");
|
await e.Channel.SendMessage("Nobody. (not 100% sure)").ConfigureAwait(false);
|
||||||
else
|
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")
|
cgb.CreateCommand(Prefix + "leave")
|
||||||
@ -1019,8 +1019,8 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await srvr.Leave();
|
await srvr.Leave().ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage("`Done.`");
|
await e.Channel.SendMessage("`Done.`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
{
|
{
|
||||||
if (!e.Server.CurrentUser.ServerPermissions.ManageRoles)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
var r = e.GetArg("role")?.Trim();
|
var r = e.GetArg("role")?.Trim();
|
||||||
@ -52,19 +52,19 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
{
|
{
|
||||||
config.AutoAssignedRole = 0;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
var role = e.Server.FindRoles(r).FirstOrDefault();
|
var role = e.Server.FindRoles(r).FirstOrDefault();
|
||||||
|
|
||||||
if (role == null)
|
if (role == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 `Role not found.`");
|
await e.Channel.SendMessage("💢 `Role not found.`").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
config.AutoAssignedRole = role.Id;
|
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);
|
NadekoBot.Config.CustomReactions[name].Add(message);
|
||||||
else
|
else
|
||||||
NadekoBot.Config.CustomReactions.Add(name, new System.Collections.Generic.List<string>() { message });
|
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);
|
await e.Channel.SendMessage($"Added {name} : {message}").ConfigureAwait(false);
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
int num;
|
int num;
|
||||||
if (!int.TryParse(e.GetArg("num"), out num) || num <= 0) return;
|
if (!int.TryParse(e.GetArg("num"), out num) || num <= 0) return;
|
||||||
string result = GetCustomsOnPage(num - 1); //People prefer starting with 1
|
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")
|
cgb.CreateCommand(Prefix + "deletecustomreaction")
|
||||||
@ -68,7 +68,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
return;
|
return;
|
||||||
if (!NadekoBot.Config.CustomReactions.ContainsKey(name))
|
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;
|
return;
|
||||||
}
|
}
|
||||||
string message = "";
|
string message = "";
|
||||||
@ -94,8 +94,8 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
NadekoBot.Config.CustomReactions.Remove(name);
|
NadekoBot.Config.CustomReactions.Remove(name);
|
||||||
message = $"Deleted custom reaction: `{name}`";
|
message = $"Deleted custom reaction: `{name}`";
|
||||||
}
|
}
|
||||||
await Task.Run(() => Classes.JSONModels.ConfigHandler.SaveConfig());
|
await Task.Run(() => Classes.JSONModels.ConfigHandler.SaveConfig()).ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage(message);
|
await e.Channel.SendMessage(message).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,14 +127,14 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
}
|
}
|
||||||
catch
|
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);
|
var msg = await e.Channel.SendMessage($":ok:You now have {role.Name} role.").ConfigureAwait(false);
|
||||||
await Task.Delay(3000);
|
await Task.Delay(3000);
|
||||||
await msg.Delete();
|
await msg.Delete();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await e.Message.Delete();
|
await e.Message.Delete().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
});
|
});
|
||||||
|
@ -29,13 +29,13 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
}
|
}
|
||||||
if (!server.IsOwner)
|
if (!server.IsOwner)
|
||||||
{
|
{
|
||||||
await server.Leave();
|
await server.Leave().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
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);
|
await e.Channel.SendMessage("That module does not exist.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("`List of commands:` \n• " + string.Join("\n• ", cmdsArray.Select(c => c.Text)))
|
var i = 0;
|
||||||
.ConfigureAwait(false);
|
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 ?? "-")}`";
|
$"**【 {SongInfo.Title.TrimTo(55)} 】**`{(SongInfo.Provider ?? "-")}`";
|
||||||
public SongInfo SongInfo { get; }
|
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;
|
private bool prebufferingComplete { get; set; } = false;
|
||||||
public MusicPlayer MusicPlayer { get; set; }
|
public MusicPlayer MusicPlayer { get; set; }
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
|
using NadekoBot.Extensions;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -10,6 +11,7 @@ namespace NadekoBot.Classes.JSONModels
|
|||||||
public bool DontJoinServers { get; set; } = false;
|
public bool DontJoinServers { get; set; } = false;
|
||||||
public bool ForwardMessages { get; set; } = true;
|
public bool ForwardMessages { get; set; } = true;
|
||||||
public bool IsRotatingStatus { get; set; } = false;
|
public bool IsRotatingStatus { get; set; } = false;
|
||||||
|
public int BufferSize { get; set; } = 4.MiB();
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public List<Quote> Quotes { get; set; } = new List<Quote>();
|
public List<Quote> Quotes { get; set; } = new List<Quote>();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
"DontJoinServers": false,
|
"DontJoinServers": false,
|
||||||
"ForwardMessages": true,
|
"ForwardMessages": true,
|
||||||
"IsRotatingStatus": false,
|
"IsRotatingStatus": false,
|
||||||
|
"BufferSize": 4194304,
|
||||||
"RemindMessageFormat": "❗⏰**I've been told to remind you to '%message%' now by %user%.**⏰❗",
|
"RemindMessageFormat": "❗⏰**I've been told to remind you to '%message%' now by %user%.**⏰❗",
|
||||||
"CustomReactions": {
|
"CustomReactions": {
|
||||||
"\\o\\": [
|
"\\o\\": [
|
||||||
|
Loading…
Reference in New Issue
Block a user