Ejemplo n.º 1
0
        public bool FinishLoading(DiscordClient client)
        {
            Channel channel = client.GetChannel(ChannelId);
            if (channel == null)
                return false;

            Channel = channel;
            return true;
        }
Ejemplo n.º 2
0
        void IModule.Install(ModuleManager manager)
        {
            _manager = manager;
            _client = manager.Client;
            _http = _client.Services.Get<HttpService>();
            _settings = _client.Services.Get<SettingsService>()
                .AddModule<TwitchModule, Settings>(manager);

            manager.CreateCommands("streams", group =>
            {
                group.MinPermissions((int)PermissionLevel.BotOwner);

                group.CreateCommand("list")
                    .Do(async e =>
                    {
                        StringBuilder builder = new StringBuilder();
                        var settings = _settings.Load(e.Server);
                        foreach (var channel in settings.Channels)
                            builder.AppendLine($"{_client.GetChannel(channel.Key)}:\n   {string.Join(", ", channel.Value.Streams.Select(x => x.Key))}");
                        await _client.Reply(e, "Linked Streams", builder.ToString());
                    });

                group.CreateCommand("add")
                    .Parameter("twitchuser")
                    .Parameter("channel", ParameterType.Optional)
                    .Do(async e =>
                    {
                        var settings = _settings.Load(e.Server);

                        Channel channel;
                        if (e.Args[1] != "")
                            channel = await _client.FindChannel(e, e.Args[1], ChannelType.Text);
                        else
                            channel = e.Channel;
                        if (channel == null) return;

                        var channelSettings = settings.GetOrAddChannel(channel.Id);
                        if (channelSettings.AddStream(e.Args[0]))
                        {
                            await _settings.Save(e.Server, settings);
                            await _client.Reply(e, $"Linked stream {e.Args[0]} to {channel.Name}.");
                        }
                        else
                            await _client.Reply(e, $"Stream {e.Args[0]} is already linked to {channel.Name}.");
                    });

                group.CreateCommand("remove")
                    .Parameter("twitchuser")
                    .Parameter("channel", ParameterType.Optional)
                    .Do(async e =>
                    {
                        var settings = _settings.Load(e.Server);
                        Channel channel;
                        if (e.Args[1] != "")
                            channel = await _client.FindChannel(e, e.Args[1], ChannelType.Text);
                        else
                            channel = e.Channel;
                        if (channel == null) return;

                        var channelSettings = settings.GetOrAddChannel(channel.Id);
                        if (channelSettings.RemoveStream(e.Args[0]))
                        {
                            await _settings.Save(e.Server.Id, settings);
                            await _client.Reply(e, $"Unlinked stream {e.Args[0]} from {channel.Name}.");
                        }
                        else
                            await _client.Reply(e, $"Stream {e.Args[0]} is not currently linked to {channel.Name}.");
                    });

                group.CreateGroup("set", set =>
                {
                    set.CreateCommand("sticky")
                        .Parameter("value")
                        .Parameter("channel", ParameterType.Optional)
                        .Do(async e =>
                        {
                            bool value = false;
                            bool.TryParse(e.Args[0], out value);

                            Channel channel;
                            if (e.Args[1] != "")
                                channel = await _client.FindChannel(e, e.Args[1], ChannelType.Text);
                            else
                                channel = e.Channel;
                            if (channel == null) return;

                            var settings = _settings.Load(e.Server);
                            var channelSettings = settings.GetOrAddChannel(channel.Id);
                            if (channelSettings.UseSticky && !value && channelSettings.StickyMessageId != null)
                            {
                                var msg = channel.GetMessage(channelSettings.StickyMessageId.Value);
                                try { await msg.Delete(); }
                                catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { }
                            }
                            channelSettings.UseSticky = value;
                            await _settings.Save(e.Server, settings);
                            await _client.Reply(e, $"Stream sticky for {channel.Name} set to {value}.");
                        });
                });
            });

            _client.Connected += (s, e) =>
            {
                if (!_isRunning)
                {
                    Task.Run(Run);
                    _isRunning = true;
                }
            };
        }
Ejemplo n.º 3
0
		void IModule.Install(ModuleManager manager)
		{
			_manager = manager;
			_client = manager.Client;
			_http = _client.Services.Get<HttpService>();
			_settings = _client.Services.Get<SettingsService>()
				.AddModule<GithubModule, Settings>(manager);

			manager.CreateCommands("repos", group =>
			{
				group.MinPermissions((int)PermissionLevel.BotOwner);

				group.CreateCommand("list")
					.Do(async e =>
					{
						StringBuilder builder = new StringBuilder();
						var settings = _settings.Load(e.Server);
						foreach (var repo in settings.Repos.OrderBy(x => x.Key))
							builder.AppendLine($"{repo.Key} [{string.Join(",", repo.Value.Branches)}] => {_client.GetChannel(repo.Value.ChannelId)?.Name ?? "Unknown"}");
						await _client.Reply(e, "Linked Repos", builder.ToString());
					});

				group.CreateCommand("add")
					.Parameter("githubrepo")
					.Parameter("channel", ParameterType.Optional)
					.Do(async e =>
					{
						var settings = _settings.Load(e.Server);
						Channel channel;
						if (e.Args[1] != "")
							channel = await _client.FindChannel(e, e.Args[1], ChannelType.Text);
						else
							channel = e.Channel;
						if (channel == null) return;

						string url = FilterUrl(e.Args[0]);
						if (settings.AddRepo(url, channel.Id))
						{
							await _settings.Save(e.Server.Id, settings);
							await _client.Reply(e, $"Linked repo {url} to {channel.Name}.");
						}
						else
							await _client.Reply(e, $"Error: Repo {url} is already being watched.");
					});

				group.CreateCommand("remove")
					.Parameter("githubrepo")
					.Do(async e =>
					{
						var settings = _settings.Load(e.Server);
						string url = FilterUrl(e.Args[0]);
						if (settings.RemoveRepo(url))
						{
							await _settings.Save(e.Server.Id, settings);
							await _client.Reply(e, $"Unlinked repo {url}.");
						}
						else
							await _client.Reply(e, $"Error: Repo {url} is not currently being watched.");
					});

				group.CreateCommand("addbranch")
					.Parameter("githubrepo")
					.Parameter("branch")
					.Do(async e =>
					{
						var settings = _settings.Load(e.Server);
						string url = FilterUrl(e.Args[0]);
						var repo = settings.Repos[url];
						if (repo != null)
						{
							if (repo.AddBranch(e.Args[1]))
							{
								await _settings.Save(e.Server.Id, settings);
								await _client.Reply(e, $"Added branch {url}/{e.Args[1]}.");
							}
							else
								await _client.Reply(e, $"Error: Branch {url}/{e.Args[1]} is already being watched.");
						}
						else
							await _client.Reply(e, $"Error: Repo {url} is not currently being watched.");
					});

				group.CreateCommand("removebranch")
					.Parameter("githubrepo")
					.Parameter("branch")
					.Do(async e =>
					{
						var settings = _settings.Load(e.Server);
						string url = FilterUrl(e.Args[0]);
						var repo = settings.Repos[url];
						if (repo != null)
						{
							if (repo.RemoveBranch(e.Args[1]))
							{
								await _settings.Save(e.Server.Id, settings);
								await _client.Reply(e, $"Removed branch {url}/{e.Args[1]}.");
							}
							else
								await _client.Reply(e, $"Error: Branch {url}/{e.Args[1]} is not being watched.");
						}
						else
							await _client.Reply(e, $"Error: Repo {url} is not currently being watched.");
					});
			});

			_client.Connected += (s, e) =>
			{
				if (!_isRunning)
				{
					Task.Run(Run);
					_isRunning = true;
				}
			};
		}
Ejemplo n.º 4
0
        void IModule.Install(ModuleManager manager)
        {
            _manager = manager;
            _client = manager.Client;
            _http = _client.Services.Get<HttpService>();
            _settings = _client.Services.Get<SettingsService>()
                .AddModule<FeedModule, Settings>(manager);

            manager.CreateCommands("feeds", group =>
            {
                group.MinPermissions((int)PermissionLevel.BotOwner);

                group.CreateCommand("list")
                    .Do(async e =>
                    {
                        var settings = _settings.Load(e.Server);
                        var response = settings.Feeds
                            .OrderBy(x => x.Key)
                            .Select(x => $"{x.Key} => {_client.GetChannel(x.Value.ChannelId)?.Name ?? "Unknown"}");
                        await _client.Reply(e, "Linked Feeds", response);
                    });

                group.CreateCommand("add")
                    .Parameter("url")
                    .Parameter("channel", ParameterType.Optional)
                    .Do(async e =>
                    {
                        var settings = _settings.Load(e.Server);
                        Channel channel;
                        if (e.Args[1] != "")
                            channel = await _client.FindChannel(e, e.Args[1], ChannelType.Text);
                        else
                            channel = e.Channel;
                        if (channel == null) return;

                        if (settings.AddFeed(e.Args[0], channel.Id))
                        {
                            await _settings.Save(e.Server, settings);
                            await _client.Reply(e, $"Linked feed {e.Args[0]} to {channel.Name}");
                        }
                        else
                            await _client.Reply(e, $"Feed {e.Args[0]} is already linked to a channel.");
                    });

                group.CreateCommand("remove")
                    .Parameter("url")
                    .Do(async e =>
                    {
                        var settings = _settings.Load(e.Server);
                        if (settings.RemoveFeed(e.Args[0]))
                        {
                            await _settings.Save(e.Server, settings);
                            await _client.Reply(e, $"Unlinked feed {e.Args[0]}.");
                        }
                        else
                            await _client.Reply(e, $"Feed {e.Args[0]} is not currently linked to a channel.");
                    });
            });

            _client.Connected += (s, e) =>
            {
                if (!_isRunning)
                {
                    Task.Run(Run);
                    _isRunning = true;
                }
            };
        }
Ejemplo n.º 5
0
        public void Start()
        {

            _client = new DiscordClient(x=> {
                x.AppName = "CancerBot";
                x.MessageCacheSize = 10;
                x.EnablePreUpdateEvents = true;
            });
            _client.UsingPermissionLevels((u,c)=>  (int)CheckPermLevel(u,c));
            _client.UsingCommands(x => {
                x.PrefixChar = '>';
                x.HelpMode = HelpMode.Public;
                x.ErrorHandler += HandleError;
                x.AllowMentionPrefix = false;
            });

            var doc = new XmlDocument();
            try
            {
                doc.Load("commands.xml");
            }
            catch (FileNotFoundException e)
            {
                StreamWriter stream = new StreamWriter("commands.xml");
                XmlSerializer xml1 = new XmlSerializer(typeof(List<CustomCommand>));
                xml1.Serialize(stream, new List<CustomCommand>());
                stream.Close();
            }

            catch (XmlException e)
            {

                StreamWriter stream = new StreamWriter("commands.xml");
                XmlSerializer xml1 = new XmlSerializer(typeof(List<CustomCommand>));
                xml1.Serialize(stream, new List<CustomCommand>());
                stream.Close();
            }
            CommandService commandService = _client.GetService<CommandService>();
            List<CustomCommand> commands = new List<CustomCommand>();
            XmlSerializer xml = new XmlSerializer(typeof(List<CustomCommand>));

            FileStream file = new FileStream("commands.xml", FileMode.OpenOrCreate);

            List<CustomCommand> list = (List<CustomCommand>)xml.Deserialize(file);
            file.Close();
            foreach(CustomCommand x in list)
            {
                if (forbodens.Contains<string>(x.Name)) { continue; }
                CommandBuilder b = _client.GetService<CommandService>().CreateCommand(x.Name.ToLower()). Description(x.Contents).Parameter("Cuntents", ParameterType.Unparsed); b.Do(async e =>
                {
                    
                    double deltatime = 5;
                    if (LastCommandTime.ContainsKey(e.User.Id))
                    {
                        deltatime = (DateTime.Now.Second - LastCommandTime[e.User.Id]);
                    }
                    if (deltatime >= 5)
                    {
                        await e.Channel.SendMessage(x.Contents);
                       
                    }
                    if (LastCommandTime.ContainsKey(e.User.Id))
                    {
                        LastCommandTime[e.User.Id] = DateTime.Now.Second;
                    }
                    else
                    {
                        LastCommandTime[e.User.Id] = DateTime.Now.Second;
                    }
                });
                try
                {
                    b._command.IsCustom = true;
                    commandBuilders.Add(x.Name.ToLower(), b);

                }

                catch { Console.WriteLine($"Command with name {x.Name} already exists!"); };
            }
            _client.GetService<CommandService>().CreateCommand("test23").Description("Test Command").Do(async e =>
            {
                await e.Channel.SendMessage("test");
            });
            //_client.Ready += (s, e) =>
            //{
            //    _client.FindServers("Discord Bots").First().FindChannels("testing-aloha").First().SendMessage("I'm alive!");
            //};
            commandService.CreateCommand("changename").Description("Changes Name").Parameter("Name", ParameterType.Unparsed).MinPermissions((int)PermissionLevel.ServerOwner)
            .Do(async e =>
            {

                await _client.CurrentUser.Edit("", e.GetArg("Name"));
                
            });
            
           // _client.UserBanned += async (s, e) =>
           // {

                //await e.Server.DefaultChannel.SendMessage(e.User.Name + " was banned forever LUUL");
            //};
           // _client.UserLeft += async (s, e) =>
           // {

                //await e.Server.DefaultChannel.SendMessage(e.User.Name + " left FeelsBadMan");
          //  };
            _client.GetService<CommandService>().CreateCommand("8ball").Description("Simple 8ball command").Parameter("memes", ParameterType.Unparsed).Do(async e => {
                Random rand = new Random();
                string output = "";
                switch (rand.Next(6))
                {
                    case 0:
                        output = "I don't know f****t";
                        break;
                    case 1:
                        output = "Yes";
                        break;
                    case 2:
                        output = "No";
                        break;
                    case 3:
                        output = "Kys";
                        break;
                    case 4:
                        output = "Ask me later";
                        break;
                    case 5:
                        output = "Maybe";
                        break;
                    default: break;
                }
                await e.Channel.SendMessage(output);
            });
            Channel Log = _client.GetChannel(192699690473488384);
            _client.MessageReceived += async (s, e) => {
              //  if (!e.Message.IsAuthor)
              //  {
              //      if (e.Message.Attachments.Length == 0)
                 //   {
                      //  await e.Channel.SendMessage(DateTime.Now + " UTC - " + e.User.Name + " (" + e.User.Id + "): " + e.Message.Text);
                 //   }
                 //   else {
                      //  await e.Channel.SendMessage(DateTime.Now + " UTC - " + e.User.Name + " (" + e.User.Id + "): " + e.Message.Text+" | Message Contained Attachment: "+e.Message.Attachments[0].Filename+" "+e.Message.Attachments[0].Size+" "+e.Message.Attachments[0].ProxyUrl);
                  //  }
                //}
                
                if (e.Message.IsMentioningMe()&&!e.Message.IsAuthor)
                {
                    if(e.Message.RawText.ToLower().Contains("hi")|| e.Message.RawText.ToLower().Contains("hello"))
                    {
                        await e.Channel.SendMessage($"Hello, <@{e.User.Id}>!");
                    }
                    if (e.Message.RawText.ToLower().Contains("kys"))
                    {
                        if (e.User.Id == 142291646824841217)
                        {
                            await e.Channel.SendMessage("ok");
                            System.Threading.Thread.Sleep(1000);
                            _client.Disconnect();
                            System.Environment.Exit(0);
                            
                        }
                        else
                        {
                            await e.Channel.SendMessage("no u");
                        }
                    }
                }
            };
            _client.GetService<CommandService>().CreateCommand("addcustomcommand").Description("Adds Custom Command").Parameter("Name").Parameter("Contents",ParameterType.Unparsed).Do(async e =>
            {
                if (e.Message.RawText.Contains("@everyone")|| e.Message.RawText.Contains("@here"))
                {
                    await e.Channel.SendMessage("Don't ping everyone you f****t");
                    return;
                }
                if (e.Message.Attachments.Length > 0)
                {
                    await e.Channel.SendMessage("I don't support files you retard.");
                    return;
                }
                XmlSerializer xml1 = new XmlSerializer(typeof(List<CustomCommand>));
                FileStream file1 = new FileStream("commands.xml", FileMode.OpenOrCreate);
                List<CustomCommand> list1 = (List<CustomCommand>)xml1.Deserialize(file1);
                file1.Close();
                if (list1.Contains(new CustomCommand(e.GetArg("Name").ToLower(), e.GetArg("Contents"))) || forbodens.Contains<string>(e.GetArg("Name")))
                {
                    await e.Channel.SendMessage("That already exists.");
                    return;
                }
                if (commandBuilders.ContainsKey(e.GetArg("Name").ToLower()))
                {
                    List<CustomCommand> list2 = list1.Where<CustomCommand>(t => t.Name.ToLower() == e.GetArg("Name").ToLower()).ToList<CustomCommand>();
                    foreach (CustomCommand g in list2)
                    {
                        list1.Remove(g);
                        list1.Add(new CustomCommand(e.GetArg("Name").ToLower(), e.GetArg("Contents")));
                    }
                }
                else
                {
                    list1.Add(new CustomCommand(e.GetArg("Name").ToLower(), e.GetArg("Contents")));
                }
                StreamWriter stream = new StreamWriter("commands.xml");
                xml1.Serialize(stream, list1);
                stream.Close();

                if (commandBuilders.ContainsKey(e.GetArg("Name").ToLower())) {
                    commandBuilders[e.GetArg("Name").ToLower()].Hide();
                    Command test = commandBuilders[e.GetArg("Name").ToLower()]._command;//(Command)typeof(CommandBuilder).GetField("_command", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(commandBuilders[e.GetArg("Name").ToLower()]);
                    Action<CommandEventArgs> tes1 = (x =>
                    {
                    });
                    typeof(Command).GetField("_runFunc", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(test, TaskHelper.ToAsync(tes1));
                    test.IsHidden = true;
                    _client.GetService<CommandService>()._map._items.Remove(e.GetArg("Name").ToLower());
                    _client.GetService<CommandService>()._categories.FirstOrDefault().Value._items.ToList().ForEach(t => {
                        if (t.Value.Name == test.Text)
                        {
                            _client.GetService<CommandService>()._categories.FirstOrDefault().Value._items.Remove(t.Value.Name);
                        }
                    });
                    commandBuilders[e.GetArg("Name").ToLower()].Description(e.GetArg("Contents"));
                    Command test1 = commandBuilders[e.GetArg("Name").ToLower()]._command;//(Command)typeof(CommandBuilder).GetField("_command", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(commandBuilders[e.GetArg("Name").ToLower()]);
                    Func<CommandEventArgs,Task> tes11 = (async x =>
                    {
                        double deltatime = 5;
                        if (LastCommandTime.ContainsKey(e.User.Id))
                        {
                            deltatime = (DateTime.Now.Second - LastCommandTime[e.User.Id]);
                        }
                        if (deltatime >= 5) { 
                        await x.Channel.SendMessage(e.GetArg("Contents"));
                       
                    }
                        if (LastCommandTime.ContainsKey(e.User.Id))
                        {
                            LastCommandTime[e.User.Id] = DateTime.Now.Second;
                        }
                        else
                        {
                            LastCommandTime[e.User.Id] = DateTime.Now.Second;
                        }
                    });
                    commandBuilders[e.GetArg("Name").ToLower()].Do(tes11);
                }
                else
                {
                    CommandBuilder b = _client.GetService<CommandService>().CreateCommand(e.GetArg("Name")).Description(e.GetArg("Contents")).Parameter("Cuntents", ParameterType.Unparsed); b.Do(async x =>
                     {
                         await x.Channel.SendMessage(e.GetArg("Contents"));
                     });
                    b._command.IsCustom = true;
                    commandBuilders.Add(e.GetArg("Name").ToLower(), b);

                }
                await e.Channel.SendMessage("Command Made Successfully!");
            });
            _client.GetService<CommandService>().CreateCommand("delcustomcommand").Description("Deletes a Custom Command").Parameter("Name").Do(async e =>
            {

                XmlSerializer xml1 = new XmlSerializer(typeof(List<CustomCommand>));
                FileStream file1 = new FileStream("commands.xml", FileMode.OpenOrCreate);
                List<CustomCommand> list1 = (List<CustomCommand>)xml1.Deserialize(file1);
                file1.Close();

                List<CustomCommand> list2 = list1.Where<CustomCommand>(t => t.Name.ToLower() == e.GetArg("Name").ToLower()).ToList<CustomCommand>();
                if (list2.Count == 0)
                {
                    await e.Channel.SendMessage("Command does not exist!");
                    return;
                }
                foreach(CustomCommand x in list2)
                {
                    list1.Remove(x);
                }
                StreamWriter stream = new StreamWriter("commands.xml");
                xml1.Serialize(stream, list1);
                stream.Close();
                foreach (Server s in _client.Servers)
                {
                    ServerConfig config = ServerConfig.GetServerConfig(s.Id);
                    if (config.commandPerms.Where(i => i.Command == e.GetArg("Name")).ToList().Count > 0)
                    {
                        config.commandPerms.Remove(config.commandPerms.Where(i => i.Command == e.GetArg("Name")).FirstOrDefault());
                        ServerConfig.WriteServerConfig(config);
                    }
                }
                commandBuilders[e.GetArg("Name").ToLower()].Hide();
                Command test = commandBuilders[e.GetArg("Name").ToLower()]._command;//(Command)typeof(CommandBuilder).GetField("_command", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(commandBuilders[e.GetArg("Name").ToLower()]);
                Action<CommandEventArgs> tes1 = (x =>
                {
                });
                typeof(Command).GetField("_runFunc", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(test, TaskHelper.ToAsync(tes1));
                test.IsHidden = true;
                _client.GetService<CommandService>()._map._items.Remove(e.GetArg("Name").ToLower());
                _client.GetService<CommandService>()._categories.FirstOrDefault().Value._items.ToList().ForEach(t=> {
                    if (t.Value.Name == test.Text) { _client.GetService<CommandService>()._categories.FirstOrDefault().Value._items.Remove(t.Value.Name); 
                }
                });
                commandBuilders.Remove(e.GetArg("Name"));
                //Console.WriteLine(_client.GetService<CommandService>()._categories.FirstOrDefault().Value._items.FirstOrDefault().);
                await e.Channel.SendMessage("Command removed Successfully!");
            });
            _client.GetService<CommandService>().CreateGroup("permissions",e=> {
                e.CreateGroup("editserver", t => {
                    t.CreateCommand("command").Description("Sets Permission Level for Command").Parameter("Command").Parameter("Level").Do(async u => {

                        ServerConfig config = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.CommandPermission commandperm;
                        if (config.commandPerms.Where(i => i.Command == u.GetArg("Command")).ToList().Count > 0)
                        {
                            commandperm = config.commandPerms.Where(i => i.Command == u.GetArg("Command")).FirstOrDefault();
                            commandperm.Level = Int32.Parse(u.GetArg("Level"));
                            config.commandPerms[config.commandPerms.IndexOf(config.commandPerms.Where(i => i.Command == u.GetArg("Command")).FirstOrDefault())] = commandperm;
                        }
                        else
                        {
                            config.commandPerms.Add(new ServerConfig.CommandPermission(u.GetArg("Command"), Int32.Parse(u.GetArg("Level"))));

                        }
                        ServerConfig.WriteServerConfig(config);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("removecommand").Description("Removes Permission Level for Command").Parameter("Command").Do(async u => {

                        ServerConfig config = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.CommandPermission commandperm;
                        if (config.commandPerms.Where(i => i.Command == u.GetArg("Command")).ToList().Count > 0)
                        {
                            //commandperm = config.commandPerms.Where(i => i.Command == u.GetArg("Command")).FirstOrDefault();
                            //commandperm.Level = Int32.Parse(u.GetArg("Level"));
                            config.commandPerms.Remove(config.commandPerms.Where(i => i.Command == u.GetArg("Command")).FirstOrDefault());
                        }
                        else
                        {
                            //config.commandPerms.Add(new ServerConfig.CommandPermission(u.GetArg("Command"), Int32.Parse(u.GetArg("Level"))));
                            await u.Channel.SendMessage("Permissions UnSucksecksful");
                        }
                        ServerConfig.WriteServerConfig(config);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("role").Description("Sets Permission Level for Role (has to be EXACT name of role)").Parameter("Command").Parameter("Level").Do(async u => {

                        ServerConfig config = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.RolePermission commandperm;
                        if (config.rolePerms.Where(i => i.Role == u.GetArg("Command")).ToList().Count > 0)
                        {
                            commandperm = config.rolePerms.Where(i => i.Role == u.GetArg("Command")).FirstOrDefault();
                            commandperm.Level = Int32.Parse(u.GetArg("Level"));
                            config.rolePerms[config.rolePerms.IndexOf(config.rolePerms.Where(i => i.Role == u.GetArg("Command")).FirstOrDefault())] = commandperm;

                        }
                        else
                        {
                            config.rolePerms.Add(new ServerConfig.RolePermission(u.GetArg("Command"), Int32.Parse(u.GetArg("Level"))));

                        }
                        ServerConfig.WriteServerConfig(config);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("removerole").Description("Removes Permission Level for Role (has to be EXACT name of role)").Parameter("Command").Do(async u => {

                        ServerConfig config = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.RolePermission commandperm;
                        if (config.rolePerms.Where(i => i.Role == u.GetArg("Command")).ToList().Count > 0)
                        {

                            config.rolePerms.Remove(config.rolePerms.Where(i => i.Role == u.GetArg("Command")).FirstOrDefault());

                        }
                        else
                        {
                            //config.rolePerms.Add(new ServerConfig.RolePermission(u.GetArg("Command"), Int32.Parse(u.GetArg("Level"))));
                            await u.Channel.SendMessage("Permissions UnSucksecksful");
                        }
                        ServerConfig.WriteServerConfig(config);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("user").Description("Sets Permission Level for User (has to be mention)").Parameter("Command").Parameter("Level").Do(async u => {
                        List<char> input = u.GetArg("Command").ToCharArray().ToList();
                        input.RemoveAt(0);
                        input.RemoveAt(0);

                        input.RemoveAt(input.Count - 1);
                        ulong id = ulong.Parse(String.Concat(input));
                        ServerConfig config = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.UserPermission commandperm;
                        if (config.userPerms.Where(i => i.UserID == id).ToList().Count > 0)
                        {
                            commandperm = config.userPerms.Where(i => i.UserID == id).FirstOrDefault();
                            commandperm.Level = Int32.Parse(u.GetArg("Level"));
                            config.userPerms[config.userPerms.IndexOf(config.userPerms.Where(i => i.UserID == id).FirstOrDefault())] = commandperm;

                        }
                        else
                        {
                            config.userPerms.Add(new ServerConfig.UserPermission(id, Int32.Parse(u.GetArg("Level"))));

                        }
                        ServerConfig.WriteServerConfig(config);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("removeuser").Description("Remove Permission Level for User (has to be mention)").Parameter("Command").Do(async u => {
                        List<char> input = u.GetArg("Command").ToCharArray().ToList();
                        input.RemoveAt(0);
                        input.RemoveAt(0);

                        input.RemoveAt(input.Count - 1);
                        ulong id = ulong.Parse(String.Concat(input));
                        ServerConfig config = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.UserPermission commandperm;
                        if (config.userPerms.Where(i => i.UserID == id).ToList().Count > 0)
                        {
                            commandperm = config.userPerms.Where(i => i.UserID == id).FirstOrDefault();

                            config.userPerms.Remove(commandperm);

                        }
                        else
                        {
                            //config.userPerms.Add(new ServerConfig.UserPermission(id, Int32.Parse(u.GetArg("Level"))));
                            await u.Channel.SendMessage("Permissions UnSucksecksful");
                        }
                        ServerConfig.WriteServerConfig(config);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("commanduser").Description("Blacklists/Whitelists commands for certain user").Parameter("User").Parameter("Command").Parameter("Enabled").Do(async u => {
                        List<char> input = u.GetArg("User").ToCharArray().ToList();
                        input.RemoveAt(0);
                        input.RemoveAt(0);

                        input.RemoveAt(input.Count - 1);
                        ulong id = ulong.Parse(String.Concat(input));
                        ServerConfig config = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.UserCommandPermission commandperm;
                        if (config.userCommandPerms.Where(i => (i.Command == u.GetArg("Command") && i.UserID == id)).ToList().Count > 0)
                        {
                            commandperm = config.userCommandPerms.Where(i => i.Command == u.GetArg("Command") && i.UserID == id).FirstOrDefault();
                            commandperm.UserID = id;
                            commandperm.enabled = bool.Parse(u.GetArg("Enabled"));
                            config.userCommandPerms[config.userCommandPerms.IndexOf(config.userCommandPerms.Where(i => i.Command == u.GetArg("Command") && i.UserID == id).FirstOrDefault())] = commandperm;
                        }
                        else
                        {
                            config.userCommandPerms.Add(new ServerConfig.UserCommandPermission(id, u.GetArg("Command"), bool.Parse(u.GetArg("Enabled"))));

                        }
                        ServerConfig.WriteServerConfig(config);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("removecommanduser").Description("Removes a Blacklist/Whitelist command for certain user").Parameter("User").Parameter("Command").Do(async u => {
                        List<char> input = u.GetArg("User").ToCharArray().ToList();
                        input.RemoveAt(0);
                        input.RemoveAt(0);

                        input.RemoveAt(input.Count - 1);
                        ulong id = ulong.Parse(String.Concat(input));
                        ServerConfig config = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.UserCommandPermission commandperm;
                        if (config.userCommandPerms.Where(i => (i.Command == u.GetArg("Command") && i.UserID == id)).ToList().Count > 0)
                        {
                            commandperm = config.userCommandPerms.Where(i => i.Command == u.GetArg("Command") && i.UserID == id).FirstOrDefault();

                            config.userCommandPerms.Remove(commandperm);
                        }
                        else
                        {

                            await u.Channel.SendMessage("Permissions UnSucksecksful");
                        }
                        ServerConfig.WriteServerConfig(config);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("commandrole").Description("Blacklists/Whitelists commands for certain role").Parameter("User").Parameter("Command").Parameter("Enabled").Do(async u => {
                    //    List<char> input = u.GetArg("User").ToCharArray().ToList();
                     //   input.RemoveAt(0);
                     //   input.RemoveAt(0);

                     //   input.RemoveAt(input.Count - 1);
                     //   ulong id = ulong.Parse(String.Concat(input));
                        ServerConfig config = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.RoleCommandPermission commandperm;
                        if (config.roleCommandPerms.Where(i => (i.Command == u.GetArg("Command")&&i.Role==u.GetArg("User"))).ToList().Count > 0)
                        {
                            commandperm = config.roleCommandPerms.Where(i => i.Command == u.GetArg("Command") && i.Role == u.GetArg("User")).FirstOrDefault();
                            commandperm.Role = u.GetArg("User");
                            commandperm.enabled = bool.Parse(u.GetArg("Enabled"));
                            config.roleCommandPerms[config.roleCommandPerms.IndexOf(config.roleCommandPerms.Where(i => i.Command == u.GetArg("Command") && i.Role == u.GetArg("User")).FirstOrDefault())] = commandperm;
                        }
                        else
                        {
                            config.roleCommandPerms.Add(new ServerConfig.RoleCommandPermission(u.GetArg("User"), u.GetArg("Command"), bool.Parse(u.GetArg("Enabled"))));

                        }
                        ServerConfig.WriteServerConfig(config);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("removecommandrole").Description("Remove a Blacklist/Whitelist command for certain role").Parameter("User").Parameter("Command").Do(async u => {
                        //    List<char> input = u.GetArg("User").ToCharArray().ToList();
                        //   input.RemoveAt(0);
                        //   input.RemoveAt(0);

                        //   input.RemoveAt(input.Count - 1);
                        //   ulong id = ulong.Parse(String.Concat(input));
                        ServerConfig config = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.RoleCommandPermission commandperm;
                        if (config.roleCommandPerms.Where(i => (i.Command == u.GetArg("Command") && i.Role == u.GetArg("User"))).ToList().Count > 0)
                        {
                            commandperm = config.roleCommandPerms.Where(i => i.Command == u.GetArg("Command") && i.Role == u.GetArg("User")).FirstOrDefault();
                            config.roleCommandPerms.Remove(commandperm);
                        }
                        else
                        {
                            await u.Channel.SendMessage("Permissions UnSucksecksful");

                        }
                        ServerConfig.WriteServerConfig(config);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                });
                
                
                e.CreateGroup("editchannel", t => {
                    t.CreateCommand("command").Description("Sets Permission Level for Command").Parameter("Command").Parameter("Level").Do(async u => {

                        ServerConfig config1 = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.ChannelPermission config = config1.channelPerms.Where(i => i.ChannelID==u.Channel.Id).FirstOrDefault();
                        if (config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).ToList().Count == 0)
                        {
                            config = new ServerConfig.ChannelPermission(u.Channel.Id);
                            config1.channelPerms.Add(config);
                        }
                        ServerConfig.CommandPermission commandperm;
                        if (config.commandPerms.Where(i => i.Command == u.GetArg("Command")).ToList().Count > 0)
                        {
                            commandperm = config.commandPerms.Where(i => i.Command == u.GetArg("Command")).FirstOrDefault();
                            commandperm.Level = Int32.Parse(u.GetArg("Level"));
                            config.commandPerms[config.commandPerms.IndexOf(config.commandPerms.Where(i => i.Command == u.GetArg("Command")).FirstOrDefault())] = commandperm;
                        }
                        else
                        {
                            config.commandPerms.Add(new ServerConfig.CommandPermission(u.GetArg("Command"), Int32.Parse(u.GetArg("Level"))));

                        }
                        config1.channelPerms[config1.channelPerms.FindIndex(y => y.ChannelID == u.Channel.Id)] = config;
                        ServerConfig.WriteServerConfig(config1);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("removecommand").Description("Removes Permission Level for Command").Parameter("Command").Do(async u => {

                        ServerConfig config1 = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.ChannelPermission config = config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).FirstOrDefault();
                        if (config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).ToList().Count == 0)
                        {
                            config = new ServerConfig.ChannelPermission(u.Channel.Id);
                            config1.channelPerms.Add(config);
                        }
                        ServerConfig.CommandPermission commandperm;
                        if (config.commandPerms.Where(i => i.Command == u.GetArg("Command")).ToList().Count > 0)
                        {
                            commandperm = config.commandPerms.Where(i => i.Command == u.GetArg("Command")).FirstOrDefault();

                            config.commandPerms.Remove(commandperm);
                        }
                        else
                        {
                            await u.Channel.SendMessage("Permissions UnSucksecksful");

                        }
                        config1.channelPerms[config1.channelPerms.FindIndex(y => y.ChannelID == u.Channel.Id)] = config;
                        ServerConfig.WriteServerConfig(config1);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("role").Description("Sets Permission Level for Role (has to be EXACT name of role)").Parameter("Command").Parameter("Level").Do(async u => {

                        ServerConfig config1 = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.ChannelPermission config = config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).FirstOrDefault();
                        if (config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).ToList().Count == 0)
                        {
                            config = new ServerConfig.ChannelPermission(u.Channel.Id);
                            config1.channelPerms.Add(config);
                        }
                        ServerConfig.RolePermission commandperm;
                        if (config.rolePerms.Where(i => i.Role == u.GetArg("Command")).ToList().Count > 0)
                        {
                            commandperm = config.rolePerms.Where(i => i.Role == u.GetArg("Command")).FirstOrDefault();
                            commandperm.Level = Int32.Parse(u.GetArg("Level"));
                            config.rolePerms[config.rolePerms.IndexOf(config.rolePerms.Where(i => i.Role == u.GetArg("Command")).FirstOrDefault())] = commandperm;

                        }
                        else
                        {
                            config.rolePerms.Add(new ServerConfig.RolePermission(u.GetArg("Command"), Int32.Parse(u.GetArg("Level"))));

                        }
                        config1.channelPerms[config1.channelPerms.FindIndex(y => y.ChannelID == u.Channel.Id)] = config;
                        ServerConfig.WriteServerConfig(config1);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("removerole").Description("Removes Permission Level for Role (has to be EXACT name of role)").Parameter("Command").Do(async u => {

                        ServerConfig config1 = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.ChannelPermission config = config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).FirstOrDefault();
                        if (config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).ToList().Count == 0)
                        {
                            config = new ServerConfig.ChannelPermission(u.Channel.Id);
                            config1.channelPerms.Add(config);
                        }
                        ServerConfig.RolePermission commandperm;
                        if (config.rolePerms.Where(i => i.Role == u.GetArg("Command")).ToList().Count > 0)
                        {
                            commandperm = config.rolePerms.Where(i => i.Role == u.GetArg("Command")).FirstOrDefault();

                            config.rolePerms.Remove(commandperm);

                        }
                        else
                        {
                            await u.Channel.SendMessage("Permissions UnSucksecksful");

                        }
                        config1.channelPerms[config1.channelPerms.FindIndex(y => y.ChannelID == u.Channel.Id)] = config;
                        ServerConfig.WriteServerConfig(config1);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("user").Description("Sets Permission Level for User (has to be mention)").Parameter("Command").Parameter("Level").Do(async u => {
                        List<char> input = u.GetArg("Command").ToCharArray().ToList();
                        input.RemoveAt(0);
                        input.RemoveAt(0);

                        input.RemoveAt(input.Count - 1);
                        ulong id = ulong.Parse(String.Concat(input));
                        ServerConfig config1 = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.ChannelPermission config = config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).FirstOrDefault();
                        if (config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).ToList().Count == 0)
                        {
                            config = new ServerConfig.ChannelPermission(u.Channel.Id);
                            config1.channelPerms.Add(config);
                        }
                        ServerConfig.UserPermission commandperm;
                        if (config.userPerms.Where(i => i.UserID == id).ToList().Count > 0)
                        {
                            commandperm = config.userPerms.Where(i => i.UserID == id).FirstOrDefault();
                            commandperm.Level = Int32.Parse(u.GetArg("Level"));
                            config.userPerms[config.userPerms.IndexOf(config.userPerms.Where(i => i.UserID == id).FirstOrDefault())] = commandperm;

                        }
                        else
                        {
                            config.userPerms.Add(new ServerConfig.UserPermission(id, Int32.Parse(u.GetArg("Level"))));

                        }
                        config1.channelPerms[config1.channelPerms.FindIndex(y => y.ChannelID == u.Channel.Id)] = config;
                        ServerConfig.WriteServerConfig(config1);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });

                    t.CreateCommand("removeuser").Description("Removes Permission Level for User (has to be mention)").Parameter("Command").Do(async u => {
                        List<char> input = u.GetArg("Command").ToCharArray().ToList();
                        input.RemoveAt(0);
                        input.RemoveAt(0);

                        input.RemoveAt(input.Count - 1);
                        ulong id = ulong.Parse(String.Concat(input));
                        ServerConfig config1 = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.ChannelPermission config = config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).FirstOrDefault();
                        if (config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).ToList().Count == 0)
                        {
                            config = new ServerConfig.ChannelPermission(u.Channel.Id);
                            config1.channelPerms.Add(config);
                        }
                        ServerConfig.UserPermission commandperm;
                        if (config.userPerms.Where(i => i.UserID == id).ToList().Count > 0)
                        {
                            commandperm = config.userPerms.Where(i => i.UserID == id).FirstOrDefault();
                            config.userPerms.Remove(commandperm);

                        }
                        else
                        {
                            await u.Channel.SendMessage("Permissions UnSucksecksful");

                        }
                        config1.channelPerms[config1.channelPerms.FindIndex(y => y.ChannelID == u.Channel.Id)] = config;
                        ServerConfig.WriteServerConfig(config1);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("commanduser").Description("Blacklists/Whitelists commands for certain user").Parameter("User").Parameter("Command").Parameter("Enabled").Do(async u => {
                        List<char> input = u.GetArg("User").ToCharArray().ToList();
                        input.RemoveAt(0);
                        input.RemoveAt(0);

                        input.RemoveAt(input.Count - 1);
                        ulong id = ulong.Parse(String.Concat(input));
                        ServerConfig config1 = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.ChannelPermission config = config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).FirstOrDefault();
                        if (config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).ToList().Count == 0)
                        {
                            config = new ServerConfig.ChannelPermission(u.Channel.Id);
                            config1.channelPerms.Add(config);
                        }
                        ServerConfig.UserCommandPermission commandperm;
                        if (config.userCommandPerms.Where(i => (i.Command == u.GetArg("Command") && i.UserID == id)).ToList().Count > 0)
                        {
                            commandperm = config.userCommandPerms.Where(i => i.Command == u.GetArg("Command") && i.UserID == id).FirstOrDefault();
                            commandperm.UserID = id;
                            commandperm.enabled = bool.Parse(u.GetArg("Enabled"));
                            config.userCommandPerms[config.userCommandPerms.IndexOf(config.userCommandPerms.Where(i => i.Command == u.GetArg("Command") && i.UserID == id).FirstOrDefault())] = commandperm;
                        }
                        else
                        {
                            config.userCommandPerms.Add(new ServerConfig.UserCommandPermission(id, u.GetArg("Command"), bool.Parse(u.GetArg("Enabled"))));

                        }
                        config1.channelPerms[config1.channelPerms.FindIndex(y => y.ChannelID == u.Channel.Id)] = config;
                        ServerConfig.WriteServerConfig(config1);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("removecommanduser").Description("Removes a Blacklist/Whitelist command for certain user").Parameter("User").Parameter("Command").Do(async u => {
                        List<char> input = u.GetArg("User").ToCharArray().ToList();
                        input.RemoveAt(0);
                        input.RemoveAt(0);

                        input.RemoveAt(input.Count - 1);
                        ulong id = ulong.Parse(String.Concat(input));
                        ServerConfig config1 = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.ChannelPermission config = config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).FirstOrDefault();
                        if (config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).ToList().Count == 0)
                        {
                            config = new ServerConfig.ChannelPermission(u.Channel.Id);
                            config1.channelPerms.Add(config);
                        }
                        ServerConfig.UserCommandPermission commandperm;
                        if (config.userCommandPerms.Where(i => (i.Command == u.GetArg("Command") && i.UserID == id)).ToList().Count > 0)
                        {
                            commandperm = config.userCommandPerms.Where(i => i.Command == u.GetArg("Command") && i.UserID == id).FirstOrDefault();

                            config.userCommandPerms.Remove(commandperm);
                        }
                        else
                        {
                            await u.Channel.SendMessage("Permissions UnSucksecksful");

                        }
                        config1.channelPerms[config1.channelPerms.FindIndex(y => y.ChannelID == u.Channel.Id)] = config;
                        ServerConfig.WriteServerConfig(config1);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("commandrole").Description("Blacklists/Whitelists commands for certain role").Parameter("User").Parameter("Command").Parameter("Enabled").Do(async u => {
                        //    List<char> input = u.GetArg("User").ToCharArray().ToList();
                        //   input.RemoveAt(0);
                        //   input.RemoveAt(0);

                        //   input.RemoveAt(input.Count - 1);
                        //   ulong id = ulong.Parse(String.Concat(input));
                        ServerConfig config1 = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.ChannelPermission config = config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).FirstOrDefault();
                        if(config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).ToList().Count == 0)
                        {
                            config = new ServerConfig.ChannelPermission(u.Channel.Id);
                            config1.channelPerms.Add(config);
                        }
                        ServerConfig.RoleCommandPermission commandperm;

                            if (config.roleCommandPerms.Where(i => (i.Command == u.GetArg("Command") && i.Role == u.GetArg("User"))).ToList().Count > 0)
                            {
                                commandperm = config.roleCommandPerms.Where(i => i.Command == u.GetArg("Command") && i.Role == u.GetArg("User")).FirstOrDefault();
                                commandperm.Role = u.GetArg("User");
                                commandperm.enabled = bool.Parse(u.GetArg("Enabled"));
                                config.roleCommandPerms[config.roleCommandPerms.IndexOf(config.roleCommandPerms.Where(i => i.Command == u.GetArg("Command") && i.Role == u.GetArg("User")).FirstOrDefault())] = commandperm;
                            }
                        
                        else
                        {
                            config.roleCommandPerms.Add(new ServerConfig.RoleCommandPermission(u.GetArg("User"), u.GetArg("Command"), bool.Parse(u.GetArg("Enabled"))));

                        }
                        config1.channelPerms[config1.channelPerms.FindIndex(y => y.ChannelID == u.Channel.Id)] = config;
                        ServerConfig.WriteServerConfig(config1);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                    t.CreateCommand("removecommandrole").Description("Removes a Blacklist/Whitelist command for certain role").Parameter("User").Parameter("Command").Do(async u => {
                        //    List<char> input = u.GetArg("User").ToCharArray().ToList();
                        //   input.RemoveAt(0);
                        //   input.RemoveAt(0);

                        //   input.RemoveAt(input.Count - 1);
                        //   ulong id = ulong.Parse(String.Concat(input));
                        ServerConfig config1 = ServerConfig.GetServerConfig(u.Channel.Server.Id);
                        ServerConfig.ChannelPermission config = config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).FirstOrDefault();
                        if (config1.channelPerms.Where(i => i.ChannelID == u.Channel.Id).ToList().Count == 0)
                        {
                            config = new ServerConfig.ChannelPermission(u.Channel.Id);
                            config1.channelPerms.Add(config);
                        }
                        ServerConfig.RoleCommandPermission commandperm;

                        if (config.roleCommandPerms.Where(i => (i.Command == u.GetArg("Command") && i.Role == u.GetArg("User"))).ToList().Count > 0)
                        {
                            commandperm = config.roleCommandPerms.Where(i => i.Command == u.GetArg("Command") && i.Role == u.GetArg("User")).FirstOrDefault();
                            config.roleCommandPerms.Remove(commandperm);
                        }

                        else
                        {
                            await u.Channel.SendMessage("Permissions UnSucksecksful");

                        }
                        config1.channelPerms[config1.channelPerms.FindIndex(y => y.ChannelID == u.Channel.Id)] = config;
                        ServerConfig.WriteServerConfig(config1);
                        await u.Channel.SendMessage("Permissions Sucksecksful");
                    });
                });
            });
            _client.ExecuteAndWait(async ()=>{
                await _client.Connect("MTcxNzEyMTAwMzE2NjEwNTYx.CfbSCw.saNJTaBcw4EN8nZjjlzhzuHzJFI");
                //"*****@*****.**", "mushroom12345"
            });


        }
Ejemplo n.º 6
0
 public override Chat GetChatById(ChatItemId id)
 {
     return(ChatFromDiscordChat(client.GetChannel(id.Ids[DiscordID])));
 }
Ejemplo n.º 7
0
        private static async void HandleMessage(DiscordClient client)
        {
            client.MessageReceived += async (s, e) =>
            {
                var recievedMessage = e.Message.Text;

                if (!(e.Message.User.Name.ToLower().Equals("milliabot") || e.Message.User.Name.ToLower().Equals("robo-millia")))
                {

                    // Handle the recieved message
                    if (recievedMessage.ToLower().Equals("!help") || recievedMessage.ToLower().Equals("help"))
                    {
                        await
                            e.Channel.SendMessage(
                                "Sample commands: !nobully !idk !reaction !addreaction !hitbox !addhitbox");
                    }
                    else if (recievedMessage.ToLower().Equals("nyan"))
                        await e.Channel.SendMessage("nyan~☆");
                    else if (recievedMessage.ToLower().Equals("!nobully"))
                        await
                            e.Channel.SendMessage(
                                "http://36.media.tumblr.com/b9a0de59acdde512065cd345f6b14593/tumblr_nmvjvaqlq31r66h7yo1_500.jpg");
                    else if (recievedMessage.ToLower().Equals("!bully"))
                        await
                            e.Channel.SendMessage(
                                "https://data.desustorage.org/a/image/1436/16/1436163143100.jpg");
                    else if (recievedMessage.ToLower().Equals("!herewego"))
                        await
                            e.Channel.SendMessage(
                                "http://suptg.thisisnotatrueending.com/archive/32329424/images/1400964390429.jpg");
                    else if (recievedMessage.ToLower().Equals("!everyday"))
                        await
                            e.Channel.SendMessage(
                                "http://40.media.tumblr.com/5fef7876e1bfe7c744a7c5d8969ea5ba/tumblr_moly86fGRT1swsp86o2_r1_500.jpg");
                    else if (recievedMessage.ToLower().Equals("!idk"))
                        await
                            e.Channel.SendMessage(
                                "http://s.quickmeme.com/img/45/45cb7c3f84254c6aea385e88ab44149887e56bbb86ba7f7ad62ace9a91a521ef.jpg");
                    else if (recievedMessage.ToLower().Equals("!autism"))
                        await
                            e.Channel.SendMessage(
                                "http://i.imgur.com/bv3ruu8.jpg");
                    else if (recievedMessage.ToLower().Equals("!awoo"))
                        await
                            e.Channel.SendMessage(
                                "http://i.imgur.com/oPVnqGU.png");
                    else if ((recievedMessage.ToLower().Contains("milliabot") || recievedMessage.Replace("-", "").ToLower().Contains("robomillia")) && recievedMessage.EndsWith("?"))
                        await
                            e.Channel.SendMessage(
                                MilliaUtils.GetEightBallResponse());
                    else if (recievedMessage.ToLower().Contains("!reaction"))
                    {
                        var commandList = recievedMessage.Split(' ').ToList();
                        if (commandList.Count == 1)
                        {
                            await e.Channel.SendMessage("Format is !reaction description(optional)");
                        }
                        if (commandList.Count > 1)
                        {
                            var description = commandList.Skip(1).Aggregate((i, j) => i + " " + j).ToLower();
                            var url = ReactionUtils.GetReactionImage(description);
                            if (string.IsNullOrEmpty(url))
                                url = "No images found";
                            await
                                e.Channel.SendMessage(
                                    url);
                        }
                        else
                        {
                            var url = ReactionUtils.GetReactionImage(null);
                            if (string.IsNullOrEmpty(url))
                                url = "No images found";
                            await
                                e.Channel.SendMessage(
                                    url);
                        }
                    }
                    else if (recievedMessage.ToLower().Contains("!addreaction"))
                    {
                        var commandList = recievedMessage.Split(' ').ToList();
                        if (commandList.Count > 1)
                        {
                            var adaptor = new ReactionImagesTableAdapter();

                            if (commandList.Count > 2)
                            {
                                var description = commandList.Skip(2).Aggregate((i, j) => i + " " + j);
                                adaptor.Insert(commandList[1], description);
                            }
                            else
                                adaptor.Insert(commandList[1], null);
                        }
                        else
                        {
                            await e.Channel.SendMessage("Format is !addreaction url description");
                        }
                    }
                    else if (recievedMessage.ToLower().Contains("!hitbox"))
                    {
                        var commandList = recievedMessage.Split(' ').ToList();
                        if (commandList.Count > 2)
                        {
                            var moveName = commandList.Skip(2).Aggregate((i, j) => i + " " + j).ToLower();
                            var url = MilliaUtils.GetHitboxImageUrl(commandList[1].ToLower(), moveName);
                            await
                                e.Channel.SendMessage(
                                    url);
                        }
                        else
                        {
                            await e.Channel.SendMessage("Format is !hitbox charactername movename");
                        }
                    }
                    else if (recievedMessage.ToLower().Contains("!addhitbox"))
                    {
                        var commandList = recievedMessage.Split(' ').ToList();
                        if (commandList.Count > 3)
                        {
                            var moveName = commandList.Skip(3).Aggregate((i, j) => i + " " + j).ToLower();
                            var result = MilliaUtils.AddHitboxImage(commandList[1], commandList[2].ToLower(), moveName.ToLower());

                            await e.Channel.SendMessage(result);
                        }
                        else
                        {
                            await e.Channel.SendMessage("Format is !addhitbox url (character name) (move name)");
                        }
                    }
                    else if (recievedMessage.ToLower().Contains("!addcharacter"))
                    {
                        var commandList = recievedMessage.Split(' ').ToList();
                        if (commandList.Count > 1)
                        {
                            var charName = commandList.Skip(1).Aggregate((i, j) => i + " " + j);
                            var characterAdaptor = new CharactersTableAdapter();
                            var existingCharacter =
                                characterAdaptor.GetData().FirstOrDefault(c => c.Name.ToLower().Equals(charName));
                            if (existingCharacter == null)
                            {
                                characterAdaptor.Insert(charName, "");
                                if (characterAdaptor.GetData().FirstOrDefault(c => c.Name.Equals(charName)) != null)
                                {
                                    await e.Channel.SendMessage(charName + " added");
                                }
                                else
                                {
                                    await e.Channel.SendMessage("Failed to add character");
                                }
                            }
                            else
                            {
                                await e.Channel.SendMessage(charName + " already exists");
                            }
                        }
                        else
                        {
                            await e.Channel.SendMessage("Format is !addcharacter (character name)");
                        }
                    }
                    else if (recievedMessage.ToLower().Contains("!playsong"))
                    {
                        var commandList = recievedMessage.Split(' ').ToList();
                        if (commandList.Count > 1)
                        {
                            var songName = commandList.Skip(1).Aggregate((i, j) => i + " " + j);
                            string file = "../assets/" + songName + ".mp3";
                            var voiceChannel = OttawaAnimeCrewServer.VoiceChannels.FirstOrDefault(v => v.Name.Equals("Jam Session"));

                            var VoiceClient = await voiceChannel.JoinAudio();

                            await MusicService.PlayMusic(VoiceClient, file);
                        }
                        else
                        {
                            await e.Channel.SendMessage("Format is !playsong (songname)");
                        }
                    }
                    else if (recievedMessage.ToLower().Contains("!addsong"))
                    {

                        var commandList = recievedMessage.Split(' ').ToList();
                        if (commandList.Count > 1)
                        {
                            var youtubeUrl = commandList.Skip(1).Aggregate((i, j) => i + " " + j);
                            var channelName = "Koromo's Room";
                            var koromos_room = "twitch_chat";
                            // Change for servers
                            var voiceClient = await VoiceChannel.JoinAudio();

                            if (!IsPlayingMusic)
                            {
                                IsPlayingMusic = true;

                                Playlist.Add(youtubeUrl);

                                await MusicService.ExecutePlaylist(voiceClient, Playlist, MusicChatChannel);

                                IsPlayingMusic = false;
                            }
                            else
                            {
                                Playlist.Add(youtubeUrl);
                                await e.Channel.SendMessage("added to playlist");
                            }
                        }
                        else
                        {
                            await e.Channel.SendMessage("Format is !downloadsong (Youtube URL)");
                        }
                    }
                    else if (recievedMessage.ToLower().Equals("!skip"))
                    {
                        IsSkipSong = true;
                        await e.Channel.SendMessage("Song skipped");
                    }
                    else if (recievedMessage.ToLower().Contains("!matchvideo"))
                    {
                        var commandList = recievedMessage.ToLower().Split(' ').ToList();
                        if (commandList.Count > 1)
                        {
                            string char1 = commandList[1];
                            string char2 = "";
                            if (commandList.Count > 2)
                                char2 = commandList[2];

                            var link = WebServices.GetMatchVideo(char1, char2);

                            await e.Channel.SendMessage(link);
                        }
                        else
                        {
                            await e.Channel.SendMessage("Format is !matchvideo (char1) (char2)");
                        }
                    }
                    else if (recievedMessage.ToLower().StartsWith("!unbansonify"))
                    {
                        var commandList = recievedMessage.ToLower().Split(' ').ToList();
                        if (commandList.Count > 1)
                        {
                            var inputLine = commandList.Skip(1).Aggregate((i, j) => i + " " + j);
                            var correctedSentence = MilliaUtils.GetAutoCorrectedSentence(inputLine);
                            await e.Channel.SendMessage(correctedSentence);
                        }
                    }
                    else if (recievedMessage.ToLower().StartsWith("!add"))
                    {
                        var commandList = recievedMessage.Split(' ').ToList();
                        if (commandList.Count > 1)
                        {
                            var command = commandList[0].Replace("!add", "");
                            var adaptor = new CommandsTableAdapter();
                            var link = commandList.Skip(1).Aggregate((i, j) => i + " " + j);

                            adaptor.Insert(command, link);

                        }
                        else
                        {
                            await e.Channel.SendMessage("Format is !add (URL)");
                        }
                    }
                    // Must be last
                    else if (recievedMessage.StartsWith("!"))
                    {
                        var commandList = recievedMessage.Split(' ').ToList();

                        var value = MilliaUtils.GetCommandLink(commandList[0].Replace("!", ""));
                        if (!String.IsNullOrEmpty(value))
                            await e.Channel.SendMessage(value);
                    }
                }
                client.GetChannel(1);
            };
        }