Beispiel #1
0
        protected override ArgumentParseResult TryParseArgumentsGuildSynchronous(GuildCommandContext context)
        {
            channel = null;

            if (!Enum.TryParse(context.Arguments[0], out channelType))
            {
                return(new ArgumentParseResult(ARGS[0], $"Could not parse to an output channel type. Available are: `{Macros.GetEnumNames<OutputChannelType>()}`"));
            }

            if (context.Arguments.Count == 2)
            {
                if (!ArgumentParsing.TryParseGuildChannel(context, context.Arguments[1], out channel))
                {
                    return(new ArgumentParseResult(ARGS[1], $"Could not parse to a channel in this guild"));
                }
            }

            return(ArgumentParseResult.SuccessfullParse);
        }
Beispiel #2
0
        protected override ArgumentParseResult TryParseArgumentsGuildSynchronous(GuildCommandContext context)
        {
            if (!ArgumentParsing.TryParseGuildChannel(context, context.Arguments[0], out Channel))
            {
                return(new ArgumentParseResult(ARGS[0], "Failed to parse to a guild channel!"));
            }

            Configs.Clear();

            if (context.Arguments.Count > 1)
            {
                context.Arguments.Index++;
                foreach (string arg in context.Arguments)
                {
                    string[] argSplit = arg.Split(':');
                    if (argSplit.Length == 2)
                    {
                        if (!Enum.TryParse(argSplit[0], out ConfigIdentifier configIdentifier))
                        {
                            return(new ArgumentParseResult(ARGS[1], $"{arg} - Could not parse to config identifier. Available are `{Macros.GetEnumNames<ConfigIdentifier>()}`!"));
                        }
                        if (!bool.TryParse(argSplit[1], out bool setting))
                        {
                            return(new ArgumentParseResult(ARGS[1], $"{arg} - Could not parse boolean value!"));
                        }
                        Configs.Add(new Tuple <ConfigIdentifier, bool>(configIdentifier, setting));
                    }
                    else
                    {
                        return(new ArgumentParseResult(ARGS[1], $"{arg} - Could not split into config identifer and setting!"));
                    }
                }
                context.Arguments.Index--;
            }

            return(ArgumentParseResult.SuccessfullParse);
        }