예제 #1
0
파일: Config.cs 프로젝트: JFronny/Disc-Hax
        private async Task ConfigCmd(CommandContext ctx, SnowflakeObject target)
        {
            if (ctx.Channel.Get(ConfigManager.Enabled).True())
            {
                await ctx.TriggerTypingAsync();

                await ctx.RespondAsync(target.GetStr(CommandArr.GetCommandNames()));
            }
        }
예제 #2
0
 public Task Clean(CommandContext ctx)
 {
     ctx.Client.DebugLogger.LogMessage(LogLevel.Info, "DiscHax", "Cleaning...", DateTime.Now);
     Cleanup.Clean(CommandArr.GetCommandNames(),
                   ctx.Client.Guilds.Select(s =>
                                            new Tuple <string, IEnumerable <string> >(s.Key.ToString(),
                                                                                      s.Value.Members.Select(u => u.Key.ToString()))),
                   ctx.Client.Guilds.SelectMany(s => s.Value.Channels).Select(s => s.Key.ToString()));
     return(ctx.RespondAsync("Complete"));
 }
예제 #3
0
        public async Task Guild(CommandContext ctx)
        {
            if (ctx.Channel.Get(ConfigManager.Enabled)
                .And(ctx.Channel.GetMethodEnabled()))
            {
                await ctx.TriggerTypingAsync();

                await ctx.RespondPaginatedIfTooLong(
                    $"Config:\n{ctx.Guild.GetStr(CommandArr.GetCommandNames())}\n\nProperties:\n{string.Join("\n", typeof(DiscordGuild).GetProperties().Select(s => { try { return $"{s.Name}: {s.GetValue(ctx.Guild)}"; } catch { return $"Could not read {s.Name}"; } }))}");
            }
        }
예제 #4
0
파일: Config.cs 프로젝트: JFronny/Disc-Hax
        private async Task ConfigCmd(CommandContext ctx, SnowflakeObject target, string element, string value,
                                     bool noComment = false)
        {
            if (ctx.Channel.Get(ConfigManager.Enabled).True() ||
                ctx.Guild.Channels.All(s => s.Value.Get(ConfigManager.Enabled).False()))
            {
                if (!noComment)
                {
                    await ctx.TriggerTypingAsync();
                }
                if (string.Equals(element, ConfigManager.Prefix, StringComparison.CurrentCultureIgnoreCase))
                {
                    target.Set(ConfigManager.Prefix, value);
                }
                else if (CommandArr.GetGroupNames().Contains(element))
                {
                    foreach (string t in CommandArr.GetCommandNames(element))
                    {
                        await ConfigCmd(ctx, target, t, value, true);
                    }
                }
                else if (!CommandArr.GetCommandNames().Contains(element))
                {
                    throw new ArgumentException($"Element ({element}) not in CommandArr");
                }
                else
                {
                    target.Set(element, (await ctx.Client.GetCommandsNext().ConvertArgument <bool>(value, ctx)).ToString());
                }
                if (target is DiscordGuild guild)
                {
                    if (string.Equals(element, ConfigManager.Enabled, StringComparison.CurrentCultureIgnoreCase))
                    {
                        await ctx.RespondAsync("Please do not EVER set \"enabled\" to false globally!");

                        return;
                    }
                    foreach ((ulong _, DiscordChannel channel) in guild.Channels)
                    {
                        await ConfigCmd(ctx, channel, element, value, true);
                    }
                }
                if (!noComment)
                {
                    await ctx.RespondAsync($"Set {element} to {value}");
                }
            }
        }
예제 #5
0
        public async Task Member(CommandContext ctx, [Description("Channel to print, leave empty for current")]
                                 DiscordChannel?channel = null)
        {
            if (ctx.Channel.Get(ConfigManager.Enabled)
                .And(ctx.Channel.GetMethodEnabled()))
            {
                await ctx.TriggerTypingAsync();

                if (channel == null)
                {
                    channel = ctx.Channel;
                }
                await ctx.RespondPaginatedIfTooLong(
                    $"Config:\n{channel.GetStr(CommandArr.GetCommandNames())}\n\nProperties:\n{string.Join("\n", typeof(DiscordChannel).GetProperties().Select(s => { try { return $"{s.Name}: {s.GetValue(channel)}"; } catch { return $"Could not read {s.Name}"; } }))}");
            }
        }
예제 #6
0
파일: Config.cs 프로젝트: JFronny/Disc-Hax
        private async Task ConfigCmd(CommandContext ctx, SnowflakeObject target, string element)
        {
            if (ctx.Channel.Get(ConfigManager.Enabled).True())
            {
                await ctx.TriggerTypingAsync();

                if (string.Equals(element, ConfigManager.Prefix, StringComparison.CurrentCultureIgnoreCase))
                {
                    await ctx.RespondAsync(
                        $"{element}: {target.Get(element, target is DiscordGuild ? Common.Prefix : ((DiscordChannel) target).Guild.Get(ConfigManager.Prefix, Common.Prefix))}");
                }
                else
                {
                    if (!CommandArr.GetCommandNames().Contains(element))
                    {
                        throw new ArgumentException($"Element ({element}) not in CommandArr");
                    }
                    await ctx.RespondAsync($"{element}: {target.Get(element)}");
                }
            }
        }