Beispiel #1
0
        public ArgumentConverterResult ConvertArgument(CommandContext ctx, string input)
        {
            if (sbyte.TryParse(input, NumberStyles.Integer, CultureInfo.CurrentCulture, out sbyte sb))
            {
                return(ArgumentConverterResult.FromSuccess(sb));
            }

            return(ArgumentConverterResult.Failed());
        }
Beispiel #2
0
        public ArgumentConverterResult ConvertArgument(CommandContext ctx, string input)
        {
            if (char.TryParse(input, out char c))
            {
                return(ArgumentConverterResult.FromSuccess(c));
            }

            return(ArgumentConverterResult.Failed());
        }
Beispiel #3
0
        public ArgumentConverterResult ConvertArgument(CommandContext ctx, string input)
        {
            if (decimal.TryParse(input, NumberStyles.Float, CultureInfo.CurrentCulture, out decimal d))
            {
                return(ArgumentConverterResult.FromSuccess(d));
            }

            return(ArgumentConverterResult.Failed());
        }
Beispiel #4
0
        public ArgumentConverterResult ConvertArgument(CommandContext ctx, string input)
        {
            if (string.IsNullOrWhiteSpace(input))
            {
                return(ArgumentConverterResult.Failed("Cannot convert a null or whitespace name to a player."));
            }

            input = input.Trim();

            // ULX style self targeting
            if (input == "^")
            {
                if (ctx.Caller != null)
                {
                    return(ArgumentConverterResult.FromSuccess(ctx.Caller));
                }

                return(ArgumentConverterResult.Failed("Cannot target the console!"));
            }

            // TODO: Check all users for a match by name, steamid, steamid64
            throw new NotImplementedException();
        }
Beispiel #5
0
        public ArgumentConverterResult ConvertArgument(CommandContext ctx, string input)
        {
            if (input == null)
            {
                return(ArgumentConverterResult.Failed());
            }

            if (bool.TryParse(input, out bool b))
            {
                return(ArgumentConverterResult.FromSuccess(b));
            }

            if (byte.TryParse(input, out byte by))
            {
                switch (by)
                {
                case 0: return(ArgumentConverterResult.FromSuccess(false));

                case 1: return(ArgumentConverterResult.FromSuccess(true));
                }
            }

            // Let's catch a little more cases, but you really shouldn't be looking for these.
            input = input.Trim();
            if (input.Equals("yes", StringComparison.CurrentCultureIgnoreCase))
            {
                return(ArgumentConverterResult.FromSuccess(true));
            }

            if (input.Equals("no", StringComparison.CurrentCultureIgnoreCase))
            {
                return(ArgumentConverterResult.FromSuccess(false));
            }

            return(ArgumentConverterResult.Failed());
        }
Beispiel #6
0
 public ArgumentConverterResult ConvertArgument(CommandContext ctx, string input)
 {
     return(string.IsNullOrWhiteSpace(input)
         ? ArgumentConverterResult.Failed()
         : ArgumentConverterResult.FromSuccess(input));
 }