Beispiel #1
0
        public async Task ExcludeChannel(CommandContext ctx,
                                         [Description("Exclude a channel")] DiscordChannel chan)
        {
            // Check if the user can use config commands.
            if (ctx.Member.GetRole().IsBotManagerOrHigher())
            {
                await ctx.Channel.TriggerTypingAsync();

                // Cancels:
                if (BotSettings.IsChannelExcluded(chan))
                {   // This channel does not exist.
                    await ctx.Channel.SendMessageAsync(
                        ChatObjects.GetErrMessage(@"Unable to uexclude channel. This channel is already excluded..."));

                    return;
                }
                if (!ctx.Guild.Channels.ContainsKey(chan.Id))
                {   // This channel is not in the guild.
                    await ctx.Channel.SendMessageAsync(
                        ChatObjects.GetErrMessage(@"Unable to exclude channel. This channel does not exist in this server..."));

                    return;
                }


                BotSettings.ExcludeChannel(chan);
                BotSettings.Save();

                await ctx.Channel.SendMessageAsync(
                    ChatObjects.GetSuccessMessage(
                        String.Format("{0} was successfully excluded!", chan.Mention)));
            }
        }