Example #1
0
        public async Task SetFilterChannel(CommandContext ctx,
                                           [Description("The channel to set the filter logs to.")] DiscordChannel chan)
        {
            // Check if the user can use these sorts of commands.
            if (ctx.Member.GetRole().IsBotManagerOrHigher())
            {
                await ctx.TriggerTypingAsync();

                // Cancels:
                if (BotSettings.FilterChannelId == chan.Id)
                {   // Trying to set the channel to itself.
                    await ctx.Channel.SendMessageAsync(
                        ChatObjects.GetErrMessage(@"Unable to set filter channel. That's already the channel..."));

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

                    return;
                }

                // Update the settings.
                BotSettings.FilterChannelId = chan.Id;
                BotSettings.Save();

                // Success message.
                await ctx.Channel.SendMessageAsync(
                    ChatObjects.GetSuccessMessage(
                        String.Format("Filter channel set to {0}!", chan.Mention)));
            }
        }
Example #2
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)));
            }
        }
Example #3
0
 private void Save_Click(object sender, RoutedEventArgs e)
 {
     SaveToSettings();   //Save to dictionary
     BotSettings.Save(); //Save to XML
     Save.IsEnabled = false;
 }