new libs, prune is back, fixed conversation perms, fixed "general"
This commit is contained in:
parent
ca52c29559
commit
5fbd4c9f1a
@ -65,7 +65,7 @@ namespace NadekoBot.Classes.Music {
|
|||||||
if (VoiceClient == null) {
|
if (VoiceClient == null) {
|
||||||
Console.WriteLine($"Joining voice channel [{DateTime.Now.Second}]");
|
Console.WriteLine($"Joining voice channel [{DateTime.Now.Second}]");
|
||||||
//todo add a new event, to tell people nadeko is trying to join
|
//todo add a new event, to tell people nadeko is trying to join
|
||||||
VoiceClient = await NadekoBot.client.Audio().Join(VoiceChannel);
|
VoiceClient = await VoiceChannel.JoinAudio();
|
||||||
Console.WriteLine($"Joined voicechannel [{DateTime.Now.Second}]");
|
Console.WriteLine($"Joined voicechannel [{DateTime.Now.Second}]");
|
||||||
}
|
}
|
||||||
await Task.Factory.StartNew(async () => await CurrentSong?.Start(), TaskCreationOptions.LongRunning).Unwrap();
|
await Task.Factory.StartNew(async () => await CurrentSong?.Start(), TaskCreationOptions.LongRunning).Unwrap();
|
||||||
|
@ -264,7 +264,7 @@ namespace NadekoBot.Classes.Music {
|
|||||||
Console.WriteLine("Nothing was buffered, try another song and check your GoogleApikey.");
|
Console.WriteLine("Nothing was buffered, try another song and check your GoogleApikey.");
|
||||||
}
|
}
|
||||||
|
|
||||||
int blockSize = 1920 * NadekoBot.client.Audio().Config.Channels;
|
int blockSize = 1920 * NadekoBot.client.Services.Get<AudioService>().Config.Channels;
|
||||||
byte[] voiceBuffer = new byte[blockSize];
|
byte[] voiceBuffer = new byte[blockSize];
|
||||||
|
|
||||||
if (parent.OnStarted != null)
|
if (parent.OnStarted != null)
|
||||||
|
@ -28,7 +28,7 @@ namespace NadekoBot
|
|||||||
static NadekoStats() { }
|
static NadekoStats() { }
|
||||||
|
|
||||||
private NadekoStats() {
|
private NadekoStats() {
|
||||||
_service = NadekoBot.client.Commands();
|
_service = NadekoBot.client.Services.Get<CommandService>();
|
||||||
_client = NadekoBot.client;
|
_client = NadekoBot.client;
|
||||||
|
|
||||||
_statsSW = new Stopwatch();
|
_statsSW = new Stopwatch();
|
||||||
|
@ -51,7 +51,7 @@ namespace NadekoBot.Classes {
|
|||||||
if (string.IsNullOrWhiteSpace(commandText))
|
if (string.IsNullOrWhiteSpace(commandText))
|
||||||
throw new ArgumentNullException(nameof(commandText));
|
throw new ArgumentNullException(nameof(commandText));
|
||||||
|
|
||||||
foreach (var com in NadekoBot.client.Commands().AllCommands) {
|
foreach (var com in NadekoBot.client.Services.Get<CommandService>().AllCommands) {
|
||||||
if (com.Text.ToLower().Equals(commandText.ToLower()))
|
if (com.Text.ToLower().Equals(commandText.ToLower()))
|
||||||
return com.Text;
|
return com.Text;
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ namespace NadekoBot.Classes {
|
|||||||
internal static Channel ValidateChannel(Server server, string channelName) {
|
internal static Channel ValidateChannel(Server server, string channelName) {
|
||||||
if (string.IsNullOrWhiteSpace(channelName))
|
if (string.IsNullOrWhiteSpace(channelName))
|
||||||
throw new ArgumentNullException(nameof(channelName));
|
throw new ArgumentNullException(nameof(channelName));
|
||||||
var channel = server.FindChannels(channelName).FirstOrDefault();
|
var channel = server.FindChannels(channelName, ChannelType.Text).FirstOrDefault();
|
||||||
if (channel == null)
|
if (channel == null)
|
||||||
throw new NullReferenceException("That channel does not exist.");
|
throw new NullReferenceException("That channel does not exist.");
|
||||||
return channel;
|
return channel;
|
||||||
|
@ -13,7 +13,7 @@ namespace NadekoBot
|
|||||||
string helpstr = "**COMMANDS DO NOT WORK IN PERSONAL MESSAGES**\nOfficial repo: **github.com/Kwoth/NadekoBot/**";
|
string helpstr = "**COMMANDS DO NOT WORK IN PERSONAL MESSAGES**\nOfficial repo: **github.com/Kwoth/NadekoBot/**";
|
||||||
|
|
||||||
string lastCategory = "";
|
string lastCategory = "";
|
||||||
foreach (var com in client.Commands().AllCommands)
|
foreach (var com in client.Services.Get<CommandService>().AllCommands)
|
||||||
{
|
{
|
||||||
if (com.Category != lastCategory)
|
if (com.Category != lastCategory)
|
||||||
{
|
{
|
||||||
@ -37,7 +37,7 @@ namespace NadekoBot
|
|||||||
string helpstr = "Official repo: **github.com/Kwoth/NadekoBot/** \n";
|
string helpstr = "Official repo: **github.com/Kwoth/NadekoBot/** \n";
|
||||||
|
|
||||||
string lastCategory = "";
|
string lastCategory = "";
|
||||||
foreach (var com in client.Commands().AllCommands) {
|
foreach (var com in client.Services.Get<CommandService>().AllCommands) {
|
||||||
if (com.Category != lastCategory) {
|
if (com.Category != lastCategory) {
|
||||||
helpstr += "\n### " + com.Category + " \n";
|
helpstr += "\n### " + com.Category + " \n";
|
||||||
helpstr += "Command and aliases | Description | Usage\n";
|
helpstr += "Command and aliases | Description | Usage\n";
|
||||||
|
@ -166,7 +166,7 @@ namespace NadekoBot.Modules {
|
|||||||
.Description("List all of the bot's commands from a certain module.")
|
.Description("List all of the bot's commands from a certain module.")
|
||||||
.Parameter("module", ParameterType.Unparsed)
|
.Parameter("module", ParameterType.Unparsed)
|
||||||
.Do(async e => {
|
.Do(async e => {
|
||||||
var commands = NadekoBot.client.Commands().AllCommands
|
var commands = NadekoBot.client.Services.Get<CommandService>().AllCommands
|
||||||
.Where(c => c.Category.ToLower() == e.GetArg("module").Trim().ToLower());
|
.Where(c => c.Category.ToLower() == e.GetArg("module").Trim().ToLower());
|
||||||
if (commands == null || commands.Count() == 0) {
|
if (commands == null || commands.Count() == 0) {
|
||||||
await e.Send("That module does not exist.");
|
await e.Send("That module does not exist.");
|
||||||
@ -403,8 +403,14 @@ namespace NadekoBot.Modules {
|
|||||||
.Description("Prunes a number of messages from the current channel.\n**Usage**: .prune 5")
|
.Description("Prunes a number of messages from the current channel.\n**Usage**: .prune 5")
|
||||||
.Do(async e => {
|
.Do(async e => {
|
||||||
if (!e.User.ServerPermissions.ManageMessages) return;
|
if (!e.User.ServerPermissions.ManageMessages) return;
|
||||||
|
int val;
|
||||||
|
if (string.IsNullOrWhiteSpace(e.GetArg("num")) || !int.TryParse(e.GetArg("num"), out val) || val < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
await e.Send("This feature is being reconstructed.");
|
foreach (var msg in await e.Channel.DownloadMessages(val)) {
|
||||||
|
await msg.Delete();
|
||||||
|
await Task.Delay(100);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(".die")
|
cgb.CreateCommand(".die")
|
||||||
|
@ -47,6 +47,8 @@ namespace NadekoBot.Modules {
|
|||||||
manager.CreateCommands(NadekoBot.botMention, cgb => {
|
manager.CreateCommands(NadekoBot.botMention, cgb => {
|
||||||
var client = manager.Client;
|
var client = manager.Client;
|
||||||
|
|
||||||
|
cgb.AddCheck(Classes.Permissions.PermissionChecker.Instance);
|
||||||
|
|
||||||
commands.ForEach(cmd => cmd.Init(cgb));
|
commands.ForEach(cmd => cmd.Init(cgb));
|
||||||
|
|
||||||
cgb.CreateCommand("uptime")
|
cgb.CreateCommand("uptime")
|
||||||
|
@ -312,7 +312,7 @@ namespace NadekoBot.Modules {
|
|||||||
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||||
string module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
string module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
||||||
|
|
||||||
foreach (var command in NadekoBot.client.Commands().AllCommands.Where(c => c.Category == module)) {
|
foreach (var command in NadekoBot.client.Services.Get<CommandService>().AllCommands.Where(c => c.Category == module)) {
|
||||||
PermsHandler.SetServerCommandPermission(e.Server, command.Text, state);
|
PermsHandler.SetServerCommandPermission(e.Server, command.Text, state);
|
||||||
}
|
}
|
||||||
await e.Send($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** on this server.");
|
await e.Send($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** on this server.");
|
||||||
@ -353,7 +353,7 @@ namespace NadekoBot.Modules {
|
|||||||
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||||
string module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
string module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
||||||
Discord.Channel channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
|
Discord.Channel channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
|
||||||
foreach (var command in NadekoBot.client.Commands().AllCommands.Where(c => c.Category == module)) {
|
foreach (var command in NadekoBot.client.Services.Get<CommandService>().AllCommands.Where(c => c.Category == module)) {
|
||||||
PermsHandler.SetChannelCommandPermission(channel, command.Text, state);
|
PermsHandler.SetChannelCommandPermission(channel, command.Text, state);
|
||||||
}
|
}
|
||||||
await e.Send($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.");
|
await e.Send($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.");
|
||||||
@ -394,7 +394,7 @@ namespace NadekoBot.Modules {
|
|||||||
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||||
string module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
string module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
||||||
Discord.Role role = PermissionHelper.ValidateRole(e.Server, e.GetArg("channel"));
|
Discord.Role role = PermissionHelper.ValidateRole(e.Server, e.GetArg("channel"));
|
||||||
foreach (var command in NadekoBot.client.Commands().AllCommands.Where(c => c.Category == module)) {
|
foreach (var command in NadekoBot.client.Services.Get<CommandService>().AllCommands.Where(c => c.Category == module)) {
|
||||||
PermsHandler.SetRoleCommandPermission(role, command.Text, state);
|
PermsHandler.SetRoleCommandPermission(role, command.Text, state);
|
||||||
}
|
}
|
||||||
await e.Send($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");
|
await e.Send($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");
|
||||||
|
@ -61,14 +61,15 @@ namespace NadekoBot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//create new discord client
|
//create new discord client
|
||||||
client = new DiscordClient(new DiscordConfig {
|
client = new DiscordClient(new DiscordConfigBuilder() {
|
||||||
MessageCacheSize = 0
|
MessageCacheSize = 0
|
||||||
});
|
});
|
||||||
|
|
||||||
//create a command service
|
//create a command service
|
||||||
var commandService = new CommandService(new CommandServiceConfig {
|
var commandService = new CommandService(new CommandServiceConfigBuilder {
|
||||||
CommandChar = null,
|
AllowMentionPrefix = false,
|
||||||
HelpMode = HelpMode.Disable
|
CustomPrefixHandler = m => 0,
|
||||||
|
HelpMode = HelpMode.Disabled
|
||||||
});
|
});
|
||||||
|
|
||||||
//reply to personal messages and forward if enabled.
|
//reply to personal messages and forward if enabled.
|
||||||
@ -81,7 +82,7 @@ namespace NadekoBot {
|
|||||||
var modules = client.Services.Add<ModuleService>(new ModuleService());
|
var modules = client.Services.Add<ModuleService>(new ModuleService());
|
||||||
|
|
||||||
//add audio service
|
//add audio service
|
||||||
var audio = client.Services.Add<AudioService>(new AudioService(new AudioServiceConfig() {
|
var audio = client.Services.Add<AudioService>(new AudioService(new AudioServiceConfigBuilder() {
|
||||||
Channels = 2,
|
Channels = 2,
|
||||||
EnableEncryption = false,
|
EnableEncryption = false,
|
||||||
EnableMultiserver = true,
|
EnableMultiserver = true,
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user