new libs, prune is back, fixed conversation perms, fixed "general"

This commit is contained in:
Master Kwoth 2016-02-14 00:57:52 +01:00
parent ca52c29559
commit 5fbd4c9f1a
13 changed files with 26 additions and 17 deletions

View File

@ -65,7 +65,7 @@ namespace NadekoBot.Classes.Music {
if (VoiceClient == null) {
Console.WriteLine($"Joining voice channel [{DateTime.Now.Second}]");
//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}]");
}
await Task.Factory.StartNew(async () => await CurrentSong?.Start(), TaskCreationOptions.LongRunning).Unwrap();

View File

@ -264,7 +264,7 @@ namespace NadekoBot.Classes.Music {
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];
if (parent.OnStarted != null)

View File

@ -28,7 +28,7 @@ namespace NadekoBot
static NadekoStats() { }
private NadekoStats() {
_service = NadekoBot.client.Commands();
_service = NadekoBot.client.Services.Get<CommandService>();
_client = NadekoBot.client;
_statsSW = new Stopwatch();

View File

@ -51,7 +51,7 @@ namespace NadekoBot.Classes {
if (string.IsNullOrWhiteSpace(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()))
return com.Text;
}
@ -73,7 +73,7 @@ namespace NadekoBot.Classes {
internal static Channel ValidateChannel(Server server, string channelName) {
if (string.IsNullOrWhiteSpace(channelName))
throw new ArgumentNullException(nameof(channelName));
var channel = server.FindChannels(channelName).FirstOrDefault();
var channel = server.FindChannels(channelName, ChannelType.Text).FirstOrDefault();
if (channel == null)
throw new NullReferenceException("That channel does not exist.");
return channel;

View File

@ -13,7 +13,7 @@ namespace NadekoBot
string helpstr = "**COMMANDS DO NOT WORK IN PERSONAL MESSAGES**\nOfficial repo: **github.com/Kwoth/NadekoBot/**";
string lastCategory = "";
foreach (var com in client.Commands().AllCommands)
foreach (var com in client.Services.Get<CommandService>().AllCommands)
{
if (com.Category != lastCategory)
{
@ -37,7 +37,7 @@ namespace NadekoBot
string helpstr = "Official repo: **github.com/Kwoth/NadekoBot/** \n";
string lastCategory = "";
foreach (var com in client.Commands().AllCommands) {
foreach (var com in client.Services.Get<CommandService>().AllCommands) {
if (com.Category != lastCategory) {
helpstr += "\n### " + com.Category + " \n";
helpstr += "Command and aliases | Description | Usage\n";

View File

@ -166,7 +166,7 @@ namespace NadekoBot.Modules {
.Description("List all of the bot's commands from a certain module.")
.Parameter("module", ParameterType.Unparsed)
.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());
if (commands == null || commands.Count() == 0) {
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")
.Do(async e => {
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")

View File

@ -47,6 +47,8 @@ namespace NadekoBot.Modules {
manager.CreateCommands(NadekoBot.botMention, cgb => {
var client = manager.Client;
cgb.AddCheck(Classes.Permissions.PermissionChecker.Instance);
commands.ForEach(cmd => cmd.Init(cgb));
cgb.CreateCommand("uptime")

View File

@ -312,7 +312,7 @@ namespace NadekoBot.Modules {
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
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);
}
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"));
string module = PermissionHelper.ValidateModule(e.GetArg("module"));
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);
}
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"));
string module = PermissionHelper.ValidateModule(e.GetArg("module"));
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);
}
await e.Send($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");

View File

@ -61,14 +61,15 @@ namespace NadekoBot {
}
//create new discord client
client = new DiscordClient(new DiscordConfig {
client = new DiscordClient(new DiscordConfigBuilder() {
MessageCacheSize = 0
});
//create a command service
var commandService = new CommandService(new CommandServiceConfig {
CommandChar = null,
HelpMode = HelpMode.Disable
var commandService = new CommandService(new CommandServiceConfigBuilder {
AllowMentionPrefix = false,
CustomPrefixHandler = m => 0,
HelpMode = HelpMode.Disabled
});
//reply to personal messages and forward if enabled.
@ -81,7 +82,7 @@ namespace NadekoBot {
var modules = client.Services.Add<ModuleService>(new ModuleService());
//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,
EnableEncryption = false,
EnableMultiserver = true,

Binary file not shown.