Beispiel #1
0
        /// <summary>
        /// Queries the input of users chat and retrieves the command, flag and flag parameters
        /// </summary>
        /// <param name="message"></param>
        public static void parseInput(DoggoDiscordAssistant bot, Server server, Discord.Channel channel, Discord.User user, string message)
        {
            string command;
            string parameter;
            Dictionary <string, string> flags = new Dictionary <string, string>();

            //Discard command symbol and split the message into a list
            message      = message.Remove(0, 1);
            splitMessage = message.Split(' ').ToList <string>();
            //Grab the command and discard it from the list
            command = splitMessage[0];
            splitMessage.RemoveAt(0);

            /*If command matches a registered command identifier, continue parsing for the parameter,
             * flags and flag parameter, and then execute the command*/
            foreach (Command rcommand in server.AvailableCommands.ToList())
            {
                if (command == rcommand.Identifier)
                {
                    parameter = parseParameter();
                    flags     = parseFlags();
                    if (bot.Debug)
                    {
                        Logging.consoleLog(user.Name + " has executed a command! " + Environment.NewLine + "Command: " + command + Environment.NewLine + "Parameter: " + parameter, Logging.logType.Debug);
                        foreach (KeyValuePair <string, string> flag in flags)
                        {
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine("Flag: " + flag.Key + " Parameter: " + flag.Value, Logging.logType.Debug);
                            Console.ForegroundColor = ConsoleColor.White;
                        }
                    }
                    rcommand.Execute(server, channel, user, parameter, flags);
                }
            }
        }
 public static Models.Room ToRoom(this Channel channel)
 {
     return(new Models.Room
     {
         Id = channel.Id.ToString(),
         Name = channel.Name
     });
 }
Beispiel #3
0
        async public void SendMessage(Discord.Channel channel, string msg)
        {
            if (channel == null)
            {
                channel = Program.growChannel;
            }

            await channel.SendMessage(msg);
        }
Beispiel #4
0
 public ClashWar(string enemyClan, int size, ulong serverId, ulong channelId)
 {
     this.EnemyClan = enemyClan;
     this.Size      = size;
     this.Bases     = new Caller[size];
     this.ServerId  = serverId;
     this.ChannelId = channelId;
     this.Channel   = NadekoBot.Client.Servers.FirstOrDefault(s => s.Id == serverId)?.TextChannels.FirstOrDefault(c => c.Id == channelId);
 }
Beispiel #5
0
 public ClashWar(string enemyClan, int size, ulong serverId, ulong channelId)
 {
     this.EnemyClan = enemyClan;
     this.Size = size;
     this.Bases = new Caller[size];
     this.ServerId = serverId;
     this.ChannelId = channelId;
     this.Channel = NadekoBot.Client.Servers.FirstOrDefault(s => s.Id == serverId)?.TextChannels.FirstOrDefault(c => c.Id == channelId);
 }
Beispiel #6
0
        public static async Task <bool> ValidateQuery(Discord.Channel ch, string query)
        {
            if (!string.IsNullOrEmpty(query.Trim()))
            {
                return(true);
            }
            await ch.Send("Please specify search parameters.").ConfigureAwait(false);

            return(false);
        }
Beispiel #7
0
        private static async Task <bool> ValidateQuery(Discord.Channel ch, string query)
        {
            if (string.IsNullOrEmpty(query.Trim()))
            {
                await ch.Send("Please specify search parameters.");

                return(false);
            }
            return(true);
        }
Beispiel #8
0
        static async Task LewdSX(string chan, Discord.Channel c)
        {
            string        result = Helpers.GetRestClient("https://lewdchan.com").Execute(new RestRequest($"{chan}/src/list.php", Method.GET)).Content;
            List <string> list   = result.Split(new[] { Environment.NewLine }, StringSplitOptions.None).ToList();
            Regex         re     = new Regex(@"([^\s]+(\.(jpg|jpeg|png|gif|bmp)))");

            foreach (Match m in re.Matches(result))
            {
                list.Add(m.Value);
            }
            await c.SendMessage($"https://lewdchan.com/{chan}/src/{list[new Random().Next(0, list.Count())]}");
        }
Beispiel #9
0
        private String getChannelDelta(Discord.Channel bfr, Discord.Channel aft)
        {
            var outp1 = String.Empty;
            var outp2 = String.Empty;

            if (bfr.Name != aft.Name)
            {
                outp1 += "Name changed.\n";
                if (!String.IsNullOrEmpty(bfr.Name))
                {
                    outp2 += $"`Old Name     :` {discordEscape(bfr.Name)}\n";
                }
                if (!String.IsNullOrEmpty(aft.Name))
                {
                    outp2 += $"`New Name     :` {discordEscape(aft.Name)}\n";
                }
            }
            if (bfr.Id != aft.Id)
            {
                outp1 += "Id changed.\n";
                outp2 += $"`Old Id       :` `{bfr.Id}`\n";
                outp2 += $"`New Id       :` `{aft.Id}`\n";
            }
            if (bfr.Topic != aft.Topic)
            {
                outp1 += "Topic changed.\n";
                if (!String.IsNullOrEmpty(bfr.Topic))
                {
                    outp2 += $"`Old Topic    :` {discordEscape(bfr.Topic)}\n";
                }
                if (!String.IsNullOrEmpty(aft.Topic))
                {
                    outp2 += $"`New Topic    :` {discordEscape(aft.Topic)}\n";
                }
            }
            if (bfr.Position != aft.Position)
            {
                outp1 += "Position changed.\n";
                outp2 += $"`Old Position :` `{bfr.Position}`\n";
                outp2 += $"`New Position :` `{aft.Position}`\n";
            }
            if (outp1 != String.Empty)
            {
                outp2 += $"\nChannel info:\n{getChannel(aft)}\n";
            }
            return(outp1 + outp2.Trim());
        }
Beispiel #10
0
    // Attempts to find a user by the inputted name, returns search result. TODO make this not user based but ID based?
    public UserSearchResult GetUserByName(string Name, Discord.Channel ChannelToSearch)
    {
        // Create default struct and set it to not found in case nothing was found later on.
        UserSearchResult SearchResult = new UserSearchResult();

        SearchResult.WasFound = false;

        // Go through all the users in a given channel and try to find a user by the specified name.
        foreach (Discord.User User in ChannelToSearch.Users)
        {
            // If the user with a matching name or nickname is found...
            if (User.Name == Name || User.Nickname == Name)
            {
                // Save the user into a variable, set it to found and exit the loop.
                SearchResult.User     = User;
                SearchResult.WasFound = true;
                break;
            }
        }

        return(SearchResult);
    }
Beispiel #11
0
 public override void Execute(Server server, Discord.Channel channel, Discord.User user, string parameter, Dictionary <string, string> flags)
 {
     channel.SendMessage("Pong!");
 }
Beispiel #12
0
        public override void Install(ModuleManager manager)
        {
            var client = manager.Client;

            var serializer = new ManateeSerializer();

            TrelloConfiguration.Serializer         = serializer;
            TrelloConfiguration.Deserializer       = serializer;
            TrelloConfiguration.JsonFactory        = new ManateeFactory();
            TrelloConfiguration.RestClientProvider = new Manatee.Trello.WebApi.WebApiClientProvider();
            TrelloAuthorization.Default.AppKey     = WizBot.Creds.TrelloAppKey;
            //TrelloAuthorization.Default.UserToken = "[your user token]";

            Discord.Channel bound = null;
            Board           board = null;

            List <string> last5ActionIDs = null;

            t.Elapsed += async(s, e) =>
            {
                try
                {
                    if (board == null || bound == null)
                    {
                        return; //do nothing if there is no bound board
                    }
                    board.Refresh();
                    var cur5Actions      = board.Actions.Take(board.Actions.Count() < 5 ? board.Actions.Count() : 5);
                    var cur5ActionsArray = cur5Actions as Action[] ?? cur5Actions.ToArray();

                    if (last5ActionIDs == null)
                    {
                        last5ActionIDs = cur5ActionsArray.Select(a => a.Id).ToList();
                        return;
                    }

                    foreach (var a in cur5ActionsArray.Where(ca => !last5ActionIDs.Contains(ca.Id)))
                    {
                        await bound.Send("**--TRELLO NOTIFICATION--**\n" + a.ToString()).ConfigureAwait(false);
                    }
                    last5ActionIDs.Clear();
                    last5ActionIDs.AddRange(cur5ActionsArray.Select(a => a.Id));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Timer failed " + ex.ToString());
                }
            };

            manager.CreateCommands("", cgb =>
            {
                cgb.AddCheck(PermissionChecker.Instance);

                cgb.CreateCommand(Prefix + "bind")
                .Description("Bind a trello bot to a single channel. " +
                             "You will receive notifications from your board when something is added or edited." +
                             $" **Bot Owner Only!**| `{Prefix}bind [board_id]`")
                .Parameter("board_id", Discord.Commands.ParameterType.Required)
                .Do(async e =>
                {
                    if (!WizBot.IsOwner(e.User.Id))
                    {
                        return;
                    }
                    if (bound != null)
                    {
                        return;
                    }
                    try
                    {
                        bound = e.Channel;
                        board = new Board(e.GetArg("board_id").Trim());
                        board.Refresh();
                        await e.Channel.SendMessage("Successfully bound to this channel and board " + board.Name);
                        t.Start();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Failed to join the board. " + ex.ToString());
                    }
                });

                cgb.CreateCommand(Prefix + "unbind")
                .Description($"Unbinds a bot from the channel and board. **Bot Owner Only!**| `{Prefix}unbind`")
                .Do(async e =>
                {
                    if (!WizBot.IsOwner(e.User.Id))
                    {
                        return;
                    }
                    if (bound == null || bound != e.Channel)
                    {
                        return;
                    }
                    t.Stop();
                    bound = null;
                    board = null;
                    await e.Channel.SendMessage("Successfully unbound trello from this channel.").ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "lists")
                .Alias(Prefix + "list")
                .Description($"Lists all lists, yo ;) **Bot Owner Only!**| `{Prefix}list`")
                .Do(async e =>
                {
                    if (!WizBot.IsOwner(e.User.Id))
                    {
                        return;
                    }
                    if (bound == null || board == null || bound != e.Channel)
                    {
                        return;
                    }
                    await e.Channel.SendMessage("Lists for a board '" + board.Name + "'\n" + string.Join("\n", board.Lists.Select(l => "**• " + l.ToString() + "**")))
                    .ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "cards")
                .Description($"Lists all cards from the supplied list. You can supply either a name or an index. **Bot Owner Only!**| `{Prefix}cards index`")
                .Parameter("list_name", Discord.Commands.ParameterType.Unparsed)
                .Do(async e =>
                {
                    if (!WizBot.IsOwner(e.User.Id))
                    {
                        return;
                    }
                    if (bound == null || board == null || bound != e.Channel || e.GetArg("list_name") == null)
                    {
                        return;
                    }

                    int num;
                    var success = int.TryParse(e.GetArg("list_name"), out num);
                    List list   = null;
                    if (success && num <= board.Lists.Count() && num > 0)
                    {
                        list = board.Lists[num - 1];
                    }
                    else
                    {
                        list = board.Lists.FirstOrDefault(l => l.Name == e.GetArg("list_name"));
                    }


                    if (list != null)
                    {
                        await e.Channel.SendMessage("There are " + list.Cards.Count() + " cards in a **" + list.Name + "** list\n" + string.Join("\n", list.Cards.Select(c => "**• " + c.ToString() + "**")))
                        .ConfigureAwait(false);
                    }
                    else
                    {
                        await e.Channel.SendMessage("No such list.")
                        .ConfigureAwait(false);
                    }
                });
            });
        }
Beispiel #13
0
        public override void Install(ModuleManager manager)
        {
            var client = manager.Client;

            var serializer = new ManateeSerializer();

            TrelloConfiguration.Serializer         = serializer;
            TrelloConfiguration.Deserializer       = serializer;
            TrelloConfiguration.JsonFactory        = new ManateeFactory();
            TrelloConfiguration.RestClientProvider = new Manatee.Trello.WebApi.WebApiClientProvider();
            TrelloAuthorization.Default.AppKey     = MidnightBot.Creds.TrelloAppKey;
            //TrelloAuthorization.Default.UserToken = "[your user token]";

            Discord.Channel bound = null;
            Board           board = null;

            List <string> last5ActionIDs = null;

            t.Elapsed += async(s, e) =>
            {
                try
                {
                    if (board == null || bound == null)
                    {
                        return; //do nothing if there is no bound board
                    }
                    board.Refresh();
                    var cur5Actions      = board.Actions.Take(board.Actions.Count() < 5 ? board.Actions.Count() : 5);
                    var cur5ActionsArray = cur5Actions as Action[] ?? cur5Actions.ToArray();

                    if (last5ActionIDs == null)
                    {
                        last5ActionIDs = cur5ActionsArray.Select(a => a.Id).ToList();
                        return;
                    }

                    foreach (var a in cur5ActionsArray.Where(ca => !last5ActionIDs.Contains(ca.Id)))
                    {
                        await bound.Send("**--TRELLO NOTIFICATION--**\n" + a.ToString()).ConfigureAwait(false);
                    }
                    last5ActionIDs.Clear();
                    last5ActionIDs.AddRange(cur5ActionsArray.Select(a => a.Id));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Timer failed " + ex.ToString());
                }
            };

            manager.CreateCommands("", cgb =>
            {
                cgb.AddCheck(PermissionChecker.Instance);

                cgb.CreateCommand(Prefix + "bind")
                .Description("Bindet einen trello Bot an einen einzigen Server. " +
                             "Du erhälst Benachrichtigungen, wenn etwas entfernt, oder hinzugefügt wird." +
                             $" | `{Prefix}bind [board_id]`")
                .Parameter("board_id", Discord.Commands.ParameterType.Required)
                .Do(async e =>
                {
                    if (!MidnightBot.IsOwner(e.User.Id))
                    {
                        return;
                    }
                    if (bound != null)
                    {
                        return;
                    }
                    try
                    {
                        bound = e.Channel;
                        board = new Board(e.GetArg("board_id").Trim());
                        board.Refresh();
                        await e.Channel.SendMessage("Erfolgreich zu diesem Board und Channel gebunden " + board.Name).ConfigureAwait(false);
                        t.Start();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Board konnte nicht beigetreten werden. " + ex.ToString());
                    }
                });

                cgb.CreateCommand(Prefix + "unbind")
                .Description("Entknüpft einen Bot vom Channel und Board.")
                .Do(async e =>
                {
                    if (!MidnightBot.IsOwner(e.User.Id))
                    {
                        return;
                    }
                    if (bound == null || bound != e.Channel)
                    {
                        return;
                    }
                    t.Stop();
                    bound = null;
                    board = null;
                    await e.Channel.SendMessage("Erfolgreich trello von diesem Channel entknüpft.").ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "lists")
                .Alias(Prefix + "list")
                .Description("Listet alle Listen")
                .Do(async e =>
                {
                    if (!MidnightBot.IsOwner(e.User.Id))
                    {
                        return;
                    }
                    if (bound == null || board == null || bound != e.Channel)
                    {
                        return;
                    }
                    await e.Channel.SendMessage("Lists for a board '" + board.Name + "'\n" + string.Join("\n", board.Lists.Select(l => "**• " + l.ToString() + "**")))
                    .ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "cards")
                .Description($"Lists all cards from the supplied list. You can supply either a name or an index. | `{Prefix}cards index`")
                .Parameter("list_name", Discord.Commands.ParameterType.Unparsed)
                .Do(async e =>
                {
                    if (!MidnightBot.IsOwner(e.User.Id))
                    {
                        return;
                    }
                    if (bound == null || board == null || bound != e.Channel || e.GetArg("list_name") == null)
                    {
                        return;
                    }

                    int num;
                    var success = int.TryParse(e.GetArg("list_name"), out num);
                    List list   = null;
                    if (success && num <= board.Lists.Count() && num > 0)
                    {
                        list = board.Lists[num - 1];
                    }
                    else
                    {
                        list = board.Lists.FirstOrDefault(l => l.Name == e.GetArg("list_name"));
                    }


                    if (list != null)
                    {
                        await e.Channel.SendMessage("There are " + list.Cards.Count() + " cards in a **" + list.Name + "** list\n" + string.Join("\n", list.Cards.Select(c => "**• " + c.ToString() + "**")))
                        .ConfigureAwait(false);
                    }
                    else
                    {
                        await e.Channel.SendMessage("No such list.").ConfigureAwait(false);
                    }
                });
            });
        }
Beispiel #14
0
 public abstract void Execute(Server server, Discord.Channel channel, Discord.User user, string parameter, Dictionary <string, string> flags);
Beispiel #15
0
        public static void syncFiles(DriveService driveService, List <Google.Apis.Drive.v3.Data.File> list, string syncLocation, Discord.Channel txtchnl)
        {
            // Initialise a list to store which files need downloading.
            List <Google.Apis.Drive.v3.Data.File> toSync = new List <Google.Apis.Drive.v3.Data.File>();
            // Store what files are present locally.
            var localFiles = Directory.GetFiles(location + syncLocation);

            // Cycle through all files, If there isn't a local copy, add it to the list.
            foreach (Google.Apis.Drive.v3.Data.File file in list)
            {
                if (!localFiles.Contains(location + syncLocation + file.Name))
                {
                    toSync.Add(file);
                }
            }
            // Tell the channel how many files are to be downloaded.
            txtchnl.SendMessage($"Downloading {toSync.Count} files.");
            // For each file to be downloaded, download it.
            foreach (Google.Apis.Drive.v3.Data.File file in toSync)
            {
                if (!Directory.GetFiles(location + syncLocation).Contains(location + syncLocation + file.Name))
                {
                    DownloadFile(driveService, file, syncLocation + file.Name);
                }
            }
        }
Beispiel #16
0
        public static async Task Start(string ApiKey)
        {
            try
            {
                Api = new Client(ApiKey);
                Me  = await Api.GetMe();
            }
            catch (Exception Ex)
            {
                Ex.Log();
                "Telegram integration could not be loaded".Log();
                return;
            }

            Commands.Add("add", async(s, e) =>
            {
                var Music = GetMusic(e);
                if (Music != null && (string)s != string.Empty)
                {
                    string[] Data = await ParseInlineId((string)s);
                    if (Data[0] == null)
                    {
                        return;
                    }

                    await Respond(Data[0], e, "Resolving song..");

                    var Files = Directory.GetFiles(SongData.MusicDir).Where(x => x.EndsWith(".mp3") && x.ToLower().Contains(Data[1].ToLower())).ToArray();
                    string Song;
                    if (Files.Length == 0)
                    {
                        Song = Music.Enqueue(Data[1]);
                    }
                    else
                    {
                        Song = Music.Enqueue(Files[0], true);
                    }

                    await Respond(Data[0], e, Song);
                }
            });

            Commands.Add("song", async(s, e) =>
            {
                var Music = GetMusic(e);
                if (Music != null)
                {
                    string[] Data = await ParseInlineId((string)s);
                    string Song   = Music.GetCurrentSong()?.FullName;
                    if (Song == null)
                    {
                        await Respond(Data[0], e, "Nothing is playing right now");
                    }
                    else
                    {
                        await Respond(Data[0], e, "I'm playing " + Song);
                    }
                }
            });

            Commands.Add("queue", async(s, e) =>
            {
                var Music = GetMusic(e);
                if (Music != null)
                {
                    string[] Data   = await ParseInlineId((string)s);
                    string Playlist = Music.GetCurrentPlaylist();
                    if (Playlist == string.Empty)
                    {
                        await Respond(Data[0], e, "The queue is empty");
                    }
                    else
                    {
                        await Respond(Data[0], e, Playlist);
                    }
                }
            });

            Commands.Add("skip", async(s, e) =>
            {
                var Music = GetMusic(e);
                if (Music != null)
                {
                    string[] Data = await ParseInlineId((string)s);
                    if (Music.Playing)
                    {
                        string NextTitle = Music.PeekNextName();
                        if (NextTitle == null)
                        {
                            await Respond(Data[0], e, "Skipped, no more songs left");
                        }
                        else
                        {
                            await Respond(Data[0], e, "Skipped to " + NextTitle.Compact(100));
                        }

                        Music.Skip();
                    }
                    else
                    {
                        await Respond(Data[0], e, "I'm not playing any music at the moment");
                    }
                }
            });

            Commands.Add("remove", async(s, e) =>
            {
                var Music = GetMusic(e);
                if (Music != null)
                {
                    string[] Data = await ParseInlineId((string)s);
                    var Removed   = Music.Remove(Data[1].ParseInts());

                    if (Removed.Count > 0)
                    {
                        await Respond(Data[0], e, "Removed " + Removed.Join(", "));
                    }
                    else
                    {
                        await Respond(Data[0], e, "I couldn't remove that song");
                    }

                    /*else
                     * {
                     *  int Count = Music.SongCount;
                     *  if (Count == 0)
                     *  {
                     *      await Respond(Data[0], e, "There is nothing I can remove");
                     *  }
                     *  else
                     *  {
                     *      var KeyboardMarkup = new ReplyKeyboardMarkup();
                     *      int Row = -1;
                     *
                     *      KeyboardMarkup.Keyboard = new KeyboardButton[(int)Math.Ceiling((double)Count / 2)][];
                     *      for (int i = 0; i < (2 * KeyboardMarkup.Keyboard.Length); i++)
                     *      {
                     *          if (i % 2 == 0)
                     *          {
                     *              KeyboardMarkup.Keyboard[++Row] = new KeyboardButton[2];
                     *          }
                     *
                     *          if (i < Count)
                     *          {
                     *              KeyboardMarkup.Keyboard[Row][i % 2] = "/remove " + (i + 1).ToString();
                     *          }
                     *          else
                     *          {
                     *              KeyboardMarkup.Keyboard[Row][i % 2] = string.Empty;
                     *          }
                     *      }
                     *
                     *      KeyboardMarkup.OneTimeKeyboard = true;
                     *      KeyboardMarkup.ResizeKeyboard = true;
                     *      KeyboardMarkup.Selective = true;
                     *
                     *      await Respond(Data[0], e, Music.GetCurrentPlaylist() + "\nWhich song should I remove?", Markup: KeyboardMarkup);
                     *  }
                     * }*/
                }
            });

            Commands.Add("pair", async(s, e) =>
            {
                if (NextPairChannel != null)
                {
                    Db.SetDiscordServerId(e.Chat.Id, NextPairChannel.Server.Id);
                    Respond(e, "This chat has now been succesfully paired with " + NextPairChannel.Server.Name).Forget();
                    await Bot.SendAsync(NextPairChannel, "This server has been paired with " + ((e.Chat.Type == ChatType.Private) ? "" : e.Chat.Title + " by ") + e.From.Username);

                    NextPairChannel = null;
                }
            });

            Commands.Add("hrc", (s, e) =>
            {
                try
                {
                    if (e.Chat.Type == ChatType.Private || e.Chat.Title.StartsWith("H"))
                    {
                        Respond(e, Lewd.GetRandomLewd(s, (e.From.Username != "Akkey" && e.Chat.Type != ChatType.Private)), false).Forget();
                    }
                }
                catch (Exception Ex)
                {
                    $"HRC {Ex}".Log();
                }
            });

            $"Logged into Telegram as {Me.Username}".Log();

            Api.MessageReceived            += Api_MessageReceived;
            Api.InlineQueryReceived        += Api_InlineQueryReceived;
            Api.ChosenInlineResultReceived += Api_ChosenInlineResultReceived;
            Api.CallbackQueryReceived      += Api_CallbackQueryReceived;
            Api.StartReceiving();
        }
Beispiel #17
0
 private async Task SendExceptonMessage(Discord.Channel channel, ArgumentException exp)
 {
     await SendStyleMessage(channel, exp.Message, SettingsModuleResource.Css);
 }
Beispiel #18
0
        public override void Install(ModuleManager manager)
        {
            var client = NadekoBot.client;

            manager.CreateCommands("", cgb => {
                cgb.AddCheck(Classes.Permissions.PermissionChecker.Instance);

                commands.ForEach(cmd => cmd.Init(cgb));

                cgb.CreateCommand(prefix + "permrole")
                .Alias(prefix + "pr")
                .Description("Sets a role which can change permissions. Or supply no parameters to find out the current one. Default one is 'Nadeko'.")
                .Parameter("role", ParameterType.Unparsed)
                .Do(async e => {
                    if (string.IsNullOrWhiteSpace(e.GetArg("role")))
                    {
                        await e.Channel.SendMessage($"Current permissions role is `{PermsHandler.GetServerPermissionsRoleName(e.Server)}`");
                        return;
                    }

                    var arg           = e.GetArg("role");
                    Discord.Role role = null;
                    try {
                        role = PermissionHelper.ValidateRole(e.Server, arg);
                    }
                    catch (Exception ex) {
                        Console.WriteLine(ex.Message);
                        await e.Channel.SendMessage($"Role `{arg}` probably doesn't exist. Create the role with that name first.");
                        return;
                    }
                    PermsHandler.SetPermissionsRole(e.Server, role.Name);
                    await e.Channel.SendMessage($"Role `{role.Name}` is now required in order to change permissions.");
                });

                cgb.CreateCommand(prefix + "verbose")
                .Alias(prefix + "v")
                .Description("Sets whether to show when a command/module is blocked.\n**Usage**: ;verbose true")
                .Parameter("arg", ParameterType.Required)
                .Do(async e => {
                    var arg  = e.GetArg("arg");
                    bool val = PermissionHelper.ValidateBool(arg);
                    PermsHandler.SetVerbosity(e.Server, val);
                    await e.Channel.SendMessage($"Verbosity set to {val}.");
                });

                cgb.CreateCommand(prefix + "serverperms")
                .Alias(prefix + "sp")
                .Description("Shows banned permissions for this server.")
                .Do(async e => {
                    var perms = PermsHandler.GetServerPermissions(e.Server);
                    if (string.IsNullOrWhiteSpace(perms?.ToString()))
                    {
                        await e.Channel.SendMessage("No permissions set for this server.");
                    }
                    await e.Channel.SendMessage(perms.ToString());
                });

                cgb.CreateCommand(prefix + "roleperms")
                .Alias(prefix + "rp")
                .Description("Shows banned permissions for a certain role. No argument means for everyone.\n**Usage**: ;rp AwesomeRole")
                .Parameter("role", ParameterType.Unparsed)
                .Do(async e => {
                    var arg           = e.GetArg("role");
                    Discord.Role role = e.Server.EveryoneRole;
                    if (!string.IsNullOrWhiteSpace(arg))
                    {
                        try {
                            role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
                        }
                        catch (Exception ex) {
                            await e.Channel.SendMessage("💢 Error: " + ex.Message);
                            return;
                        }
                    }

                    var perms = PermsHandler.GetRolePermissionsById(e.Server, role.Id);

                    if (string.IsNullOrWhiteSpace(perms?.ToString()))
                    {
                        await e.Channel.SendMessage($"No permissions set for **{role.Name}** role.");
                    }
                    await e.Channel.SendMessage(perms.ToString());
                });

                cgb.CreateCommand(prefix + "channelperms")
                .Alias(prefix + "cp")
                .Description("Shows banned permissions for a certain channel. No argument means for this channel.\n**Usage**: ;cp #dev")
                .Parameter("channel", ParameterType.Unparsed)
                .Do(async e => {
                    var arg = e.GetArg("channel");
                    Discord.Channel channel = e.Channel;
                    if (!string.IsNullOrWhiteSpace(arg))
                    {
                        try {
                            channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
                        }
                        catch (Exception ex) {
                            await e.Channel.SendMessage("💢 Error: " + ex.Message);
                            return;
                        }
                    }

                    var perms = PermsHandler.GetChannelPermissionsById(e.Server, channel.Id);
                    if (string.IsNullOrWhiteSpace(perms?.ToString()))
                    {
                        await e.Channel.SendMessage($"No permissions set for **{channel.Name}** channel.");
                    }
                    await e.Channel.SendMessage(perms.ToString());
                });

                cgb.CreateCommand(prefix + "userperms")
                .Alias(prefix + "up")
                .Description("Shows banned permissions for a certain user. No argument means for yourself.\n**Usage**: ;up Kwoth")
                .Parameter("user", ParameterType.Unparsed)
                .Do(async e => {
                    var arg           = e.GetArg("user");
                    Discord.User user = e.User;
                    if (!string.IsNullOrWhiteSpace(e.GetArg("user")))
                    {
                        try {
                            user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user"));
                        }
                        catch (Exception ex) {
                            await e.Channel.SendMessage("💢 Error: " + ex.Message);
                            return;
                        }
                    }

                    var perms = PermsHandler.GetUserPermissionsById(e.Server, user.Id);
                    if (string.IsNullOrWhiteSpace(perms?.ToString()))
                    {
                        await e.Channel.SendMessage($"No permissions set for user **{user.Name}**.");
                    }
                    await e.Channel.SendMessage(perms.ToString());
                });

                cgb.CreateCommand(prefix + "sm").Alias(prefix + "servermodule")
                .Parameter("module", ParameterType.Required)
                .Parameter("bool", ParameterType.Required)
                .Description("Sets a module's permission at the server level.\n**Usage**: ;sm <module_name> enable")
                .Do(async e => {
                    try {
                        string module = PermissionHelper.ValidateModule(e.GetArg("module"));
                        bool state    = PermissionHelper.ValidateBool(e.GetArg("bool"));

                        PermsHandler.SetServerModulePermission(e.Server, module, state);
                        await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on this server.");
                    }
                    catch (ArgumentException exArg) {
                        await e.Channel.SendMessage(exArg.Message);
                    }
                    catch (Exception ex) {
                        await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
                    }
                });

                cgb.CreateCommand(prefix + "sc").Alias(prefix + "servercommand")
                .Parameter("command", ParameterType.Required)
                .Parameter("bool", ParameterType.Required)
                .Description("Sets a command's permission at the server level.\n**Usage**: ;sc <command_name> disable")
                .Do(async e => {
                    try {
                        string command = PermissionHelper.ValidateCommand(e.GetArg("command"));
                        bool state     = PermissionHelper.ValidateBool(e.GetArg("bool"));

                        PermsHandler.SetServerCommandPermission(e.Server, command, state);
                        await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on this server.");
                    }
                    catch (ArgumentException exArg) {
                        await e.Channel.SendMessage(exArg.Message);
                    }
                    catch (Exception ex) {
                        await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
                    }
                });

                cgb.CreateCommand(prefix + "rm").Alias(prefix + "rolemodule")
                .Parameter("module", ParameterType.Required)
                .Parameter("bool", ParameterType.Required)
                .Parameter("role", ParameterType.Unparsed)
                .Description("Sets a module's permission at the role level.\n**Usage**: ;rm <module_name> enable <role_name>")
                .Do(async e => {
                    try {
                        string module = PermissionHelper.ValidateModule(e.GetArg("module"));
                        bool state    = PermissionHelper.ValidateBool(e.GetArg("bool"));

                        if (e.GetArg("role")?.ToLower() == "all")
                        {
                            foreach (var role in e.Server.Roles)
                            {
                                PermsHandler.SetRoleModulePermission(role, module, state);
                            }
                            await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **ALL** roles.");
                        }
                        else
                        {
                            Discord.Role role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));

                            PermsHandler.SetRoleModulePermission(role, module, state);
                            await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");
                        }
                    }
                    catch (ArgumentException exArg) {
                        await e.Channel.SendMessage(exArg.Message);
                    }
                    catch (Exception ex) {
                        await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
                    }
                });

                cgb.CreateCommand(prefix + "rc").Alias(prefix + "rolecommand")
                .Parameter("command", ParameterType.Required)
                .Parameter("bool", ParameterType.Required)
                .Parameter("role", ParameterType.Unparsed)
                .Description("Sets a command's permission at the role level.\n**Usage**: ;rc <command_name> disable <role_name>")
                .Do(async e => {
                    try {
                        string command = PermissionHelper.ValidateCommand(e.GetArg("command"));
                        bool state     = PermissionHelper.ValidateBool(e.GetArg("bool"));

                        if (e.GetArg("role")?.ToLower() == "all")
                        {
                            foreach (var role in e.Server.Roles)
                            {
                                PermsHandler.SetRoleCommandPermission(role, command, state);
                            }
                            await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **ALL** roles.");
                        }
                        else
                        {
                            Discord.Role role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));

                            PermsHandler.SetRoleCommandPermission(role, command, state);
                            await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");
                        }
                    }
                    catch (ArgumentException exArg) {
                        await e.Channel.SendMessage(exArg.Message);
                    }
                    catch (Exception ex) {
                        await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
                    }
                });

                cgb.CreateCommand(prefix + "cm").Alias(prefix + "channelmodule")
                .Parameter("module", ParameterType.Required)
                .Parameter("bool", ParameterType.Required)
                .Parameter("channel", ParameterType.Unparsed)
                .Description("Sets a module's permission at the channel level.\n**Usage**: ;cm <module_name> enable <channel_name>")
                .Do(async e => {
                    try {
                        string module = PermissionHelper.ValidateModule(e.GetArg("module"));
                        bool state    = PermissionHelper.ValidateBool(e.GetArg("bool"));

                        if (e.GetArg("channel")?.ToLower() == "all")
                        {
                            foreach (var channel in e.Server.TextChannels)
                            {
                                PermsHandler.SetChannelModulePermission(channel, module, state);
                            }
                            await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels.");
                        }
                        else
                        {
                            Discord.Channel channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));

                            PermsHandler.SetChannelModulePermission(channel, module, state);
                            await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.");
                        }
                    }
                    catch (ArgumentException exArg) {
                        await e.Channel.SendMessage(exArg.Message);
                    }
                    catch (Exception ex) {
                        await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
                    }
                });

                cgb.CreateCommand(prefix + "cc").Alias(prefix + "channelcommand")
                .Parameter("command", ParameterType.Required)
                .Parameter("bool", ParameterType.Required)
                .Parameter("channel", ParameterType.Unparsed)
                .Description("Sets a command's permission at the channel level.\n**Usage**: ;cm enable <channel_name>")
                .Do(async e => {
                    try {
                        string command = PermissionHelper.ValidateCommand(e.GetArg("command"));
                        bool state     = PermissionHelper.ValidateBool(e.GetArg("bool"));

                        if (e.GetArg("channel")?.ToLower() == "all")
                        {
                            foreach (var channel in e.Server.TextChannels)
                            {
                                PermsHandler.SetChannelCommandPermission(channel, command, state);
                            }
                            await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels.");
                        }
                        else
                        {
                            Discord.Channel channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));

                            PermsHandler.SetChannelCommandPermission(channel, command, state);
                            await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.");
                        }
                    }
                    catch (ArgumentException exArg) {
                        await e.Channel.SendMessage(exArg.Message);
                    }
                    catch (Exception ex) {
                        await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
                    }
                });

                cgb.CreateCommand(prefix + "um").Alias(prefix + "usermodule")
                .Parameter("module", ParameterType.Required)
                .Parameter("bool", ParameterType.Required)
                .Parameter("user", ParameterType.Unparsed)
                .Description("Sets a module's permission at the user level.\n**Usage**: ;um <module_name> enable <user_name>")
                .Do(async e => {
                    try {
                        string module     = PermissionHelper.ValidateModule(e.GetArg("module"));
                        bool state        = PermissionHelper.ValidateBool(e.GetArg("bool"));
                        Discord.User user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user"));

                        PermsHandler.SetUserModulePermission(user, module, state);
                        await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.");
                    }
                    catch (ArgumentException exArg) {
                        await e.Channel.SendMessage(exArg.Message);
                    }
                    catch (Exception ex) {
                        await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
                    }
                });

                cgb.CreateCommand(prefix + "uc").Alias(prefix + "usercommand")
                .Parameter("command", ParameterType.Required)
                .Parameter("bool", ParameterType.Required)
                .Parameter("user", ParameterType.Unparsed)
                .Description("Sets a command's permission at the user level.\n**Usage**: ;uc <module_command> enable <user_name>")
                .Do(async e => {
                    try {
                        string command    = PermissionHelper.ValidateCommand(e.GetArg("command"));
                        bool state        = PermissionHelper.ValidateBool(e.GetArg("bool"));
                        Discord.User user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user"));

                        PermsHandler.SetUserCommandPermission(user, command, state);
                        await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.");
                    }
                    catch (ArgumentException exArg) {
                        await e.Channel.SendMessage(exArg.Message);
                    }
                    catch (Exception ex) {
                        await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
                    }
                });

                cgb.CreateCommand(prefix + "asm").Alias(prefix + "allservermodules")
                .Parameter("bool", ParameterType.Required)
                .Description("Sets permissions for all modules at the server level.\n**Usage**: ;asm <enable/disable>")
                .Do(async e => {
                    try {
                        bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));

                        foreach (var module in NadekoBot.client.GetService <ModuleService>().Modules)
                        {
                            PermsHandler.SetServerModulePermission(e.Server, module.Name, state);
                        }
                        await e.Channel.SendMessage($"All modules have been **{(state ? "enabled" : "disabled")}** on this server.");
                    }
                    catch (ArgumentException exArg) {
                        await e.Channel.SendMessage(exArg.Message);
                    }
                    catch (Exception ex) {
                        await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
                    }
                });

                cgb.CreateCommand(prefix + "asc").Alias(prefix + "allservercommands")
                .Parameter("module", ParameterType.Required)
                .Parameter("bool", ParameterType.Required)
                .Description("Sets permissions for all commands from a certain module at the server level.\n**Usage**: ;asc <module_name> <enable/disable>")
                .Do(async e => {
                    try {
                        bool state    = PermissionHelper.ValidateBool(e.GetArg("bool"));
                        string module = PermissionHelper.ValidateModule(e.GetArg("module"));

                        foreach (var command in NadekoBot.client.GetService <CommandService>().AllCommands.Where(c => c.Category == module))
                        {
                            PermsHandler.SetServerCommandPermission(e.Server, command.Text, state);
                        }
                        await e.Channel.SendMessage($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** on this server.");
                    }
                    catch (ArgumentException exArg) {
                        await e.Channel.SendMessage(exArg.Message);
                    }
                    catch (Exception ex) {
                        await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
                    }
                });

                cgb.CreateCommand(prefix + "acm").Alias(prefix + "allchannelmodules")
                .Parameter("bool", ParameterType.Required)
                .Parameter("channel", ParameterType.Unparsed)
                .Description("Sets permissions for all modules at the channel level.\n**Usage**: ;acm <enable/disable> <channel_name>")
                .Do(async e => {
                    try {
                        bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
                        Discord.Channel channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
                        foreach (var module in NadekoBot.client.GetService <ModuleService>().Modules)
                        {
                            PermsHandler.SetChannelModulePermission(channel, module.Name, state);
                        }

                        await e.Channel.SendMessage($"All modules have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.");
                    }
                    catch (ArgumentException exArg) {
                        await e.Channel.SendMessage(exArg.Message);
                    }
                    catch (Exception ex) {
                        await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
                    }
                });

                cgb.CreateCommand(prefix + "acc").Alias(prefix + "allchannelcommands")
                .Parameter("module", ParameterType.Required)
                .Parameter("bool", ParameterType.Required)
                .Parameter("channel", ParameterType.Unparsed)
                .Description("Sets permissions for all commands from a certain module at the channel level.\n**Usage**: ;acc <module_name> <enable/disable> <channel_name>")
                .Do(async e => {
                    try {
                        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.GetService <CommandService>().AllCommands.Where(c => c.Category == module))
                        {
                            PermsHandler.SetChannelCommandPermission(channel, command.Text, state);
                        }
                        await e.Channel.SendMessage($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.");
                    }
                    catch (ArgumentException exArg) {
                        await e.Channel.SendMessage(exArg.Message);
                    }
                    catch (Exception ex) {
                        await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
                    }
                });

                cgb.CreateCommand(prefix + "arm").Alias(prefix + "allrolemodules")
                .Parameter("bool", ParameterType.Required)
                .Parameter("role", ParameterType.Unparsed)
                .Description("Sets permissions for all modules at the role level.\n**Usage**: ;arm <enable/disable> <role_name>")
                .Do(async e => {
                    try {
                        bool state        = PermissionHelper.ValidateBool(e.GetArg("bool"));
                        Discord.Role role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
                        foreach (var module in NadekoBot.client.GetService <ModuleService>().Modules)
                        {
                            PermsHandler.SetRoleModulePermission(role, module.Name, state);
                        }

                        await e.Channel.SendMessage($"All modules have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");
                    }
                    catch (ArgumentException exArg) {
                        await e.Channel.SendMessage(exArg.Message);
                    }
                    catch (Exception ex) {
                        await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
                    }
                });

                cgb.CreateCommand(prefix + "arc").Alias(prefix + "allrolecommands")
                .Parameter("module", ParameterType.Required)
                .Parameter("bool", ParameterType.Required)
                .Parameter("channel", ParameterType.Unparsed)
                .Description("Sets permissions for all commands from a certain module at the role level.\n**Usage**: ;arc <module_name> <enable/disable> <channel_name>")
                .Do(async e => {
                    try {
                        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.GetService <CommandService>().AllCommands.Where(c => c.Category == module))
                        {
                            PermsHandler.SetRoleCommandPermission(role, command.Text, state);
                        }
                        await e.Channel.SendMessage($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");
                    }
                    catch (ArgumentException exArg) {
                        await e.Channel.SendMessage(exArg.Message);
                    }
                    catch (Exception ex) {
                        await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
                    }
                });
            });
        }
Beispiel #19
0
 private String getChannel(Discord.Channel channel) =>
 $"`Name         :` {discordEscape(channel.Name)}\n" +
 $"`Topic        :` {discordEscape(channel.Topic)}\n" +
 $"`Id           :` `{channel.Id}`\n" +
 $"`Position     :` `{channel.Position}`\n" +
 $"`Type         :` {channel.Type.ToString()}";
Beispiel #20
0
        public override void Install(ModuleManager manager)
        {
            var client = manager.Client;

            var serializer = new ManateeSerializer();

            TrelloConfiguration.Serializer         = serializer;
            TrelloConfiguration.Deserializer       = serializer;
            TrelloConfiguration.JsonFactory        = new ManateeFactory();
            TrelloConfiguration.RestClientProvider = new Manatee.Trello.WebApi.WebApiClientProvider();
            TrelloAuthorization.Default.AppKey     = NadekoBot.TrelloAppKey;
            //TrelloAuthorization.Default.UserToken = "[your user token]";

            Discord.Channel bound = null;
            Board           board = null;

            Timer t = new Timer();

            t.Interval = 2000;
            List <string> last5ActionIDs = null;

            t.Elapsed += async(s, e) => {
                try {
                    if (board == null || bound == null)
                    {
                        return; //do nothing if there is no bound board
                    }
                    board.Refresh();
                    IEnumerable <Manatee.Trello.Action> cur5Actions;
                    if (board.Actions.Count() < 5)
                    {
                        cur5Actions = board.Actions.Take(board.Actions.Count());
                    }
                    else
                    {
                        cur5Actions = board.Actions.Take(5);
                    }

                    if (last5ActionIDs == null)
                    {
                        last5ActionIDs = new List <string>();
                        foreach (var a in cur5Actions)
                        {
                            last5ActionIDs.Add(a.Id);
                        }
                        return;
                    }
                    foreach (var a in cur5Actions.Where(ca => !last5ActionIDs.Contains(ca.Id)))
                    {
                        await bound.Send("**--TRELLO NOTIFICATION--**\n" + a.ToString());
                    }
                    last5ActionIDs.Clear();
                    foreach (var a in cur5Actions)
                    {
                        last5ActionIDs.Add(a.Id);
                    }
                } catch (Exception ex) {
                    Console.WriteLine("Timer failed " + ex.ToString());
                }
            };

            manager.CreateCommands("", cgb => {
                cgb.CreateCommand("join")
                .Alias("j")
                .Description("Joins a server")
                .Parameter("code", Discord.Commands.ParameterType.Required)
                .Do(async e => {
                    if (e.User.Id != NadekoBot.OwnerID)
                    {
                        return;
                    }
                    try {
                        await(await client.GetInvite(e.GetArg("code"))).Accept();
                    } catch (Exception ex) {
                        Console.WriteLine(ex.ToString());
                    }
                });

                cgb.CreateCommand("bind")
                .Description("Bind a trello bot to a single channel. You will receive notifications from your board when somethign is added or edited.")
                .Parameter("board_id", Discord.Commands.ParameterType.Required)
                .Do(async e => {
                    if (e.User.Id != NadekoBot.OwnerID)
                    {
                        return;
                    }
                    if (bound != null)
                    {
                        return;
                    }
                    try {
                        bound = e.Channel;
                        board = new Board(e.GetArg("board_id").Trim());
                        board.Refresh();
                        await e.Send("Successfully bound to this channel and board " + board.Name);
                        t.Start();
                    } catch (Exception ex) {
                        Console.WriteLine("Failed to join the board. " + ex.ToString());
                    }
                });

                cgb.CreateCommand("unbind")
                .Description("Unbinds a bot from the channel and board.")
                .Do(async e => {
                    if (e.User.Id != NadekoBot.OwnerID)
                    {
                        return;
                    }
                    if (bound == null || bound != e.Channel)
                    {
                        return;
                    }
                    t.Stop();
                    bound = null;
                    board = null;
                    await e.Send("Successfully unbound trello from this channel.");
                });

                cgb.CreateCommand("lists")
                .Alias("list")
                .Description("Lists all lists yo ;)")
                .Do(async e => {
                    if (e.User.Id != NadekoBot.OwnerID)
                    {
                        return;
                    }
                    if (bound == null || board == null || bound != e.Channel)
                    {
                        return;
                    }
                    await e.Send("Lists for a board '" + board.Name + "'\n" + string.Join("\n", board.Lists.Select(l => "**• " + l.ToString() + "**")));
                });

                cgb.CreateCommand("cards")
                .Description("Lists all cards from the supplied list. You can supply either a name or an index.")
                .Parameter("list_name", Discord.Commands.ParameterType.Unparsed)
                .Do(async e => {
                    if (e.User.Id != NadekoBot.OwnerID)
                    {
                        return;
                    }
                    if (bound == null || board == null || bound != e.Channel || e.GetArg("list_name") == null)
                    {
                        return;
                    }

                    int num;
                    var success = int.TryParse(e.GetArg("list_name"), out num);
                    List list   = null;
                    if (success && num <= board.Lists.Count() && num > 0)
                    {
                        list = board.Lists[num - 1];
                    }
                    else
                    {
                        list = board.Lists.Where(l => l.Name == e.GetArg("list_name")).FirstOrDefault();
                    }


                    if (list != null)
                    {
                        await e.Send("There are " + list.Cards.Count() + " cards in a **" + list.Name + "** list\n" + string.Join("\n", list.Cards.Select(c => "**• " + c.ToString() + "**")));
                    }
                    else
                    {
                        await e.Send("No such list.");
                    }
                });
            });
        }
 public DiscordChannel(Discord.Channel channel)
 {
     channelInterface = channel;
 }