diff --git a/src/Bot.cs b/src/Bot.cs index 845c0213..30a2b507 100644 --- a/src/Bot.cs +++ b/src/Bot.cs @@ -425,14 +425,15 @@ private async Task Commands_CommandErrored(CommandErrorEventArgs e) // The user lacks required permissions, var emoji = DiscordEmoji.FromName(e.Context.Client, ":x:"); - var prefix = _whConfig.Servers.ContainsKey(e.Context.Guild.Id) ? _whConfig.Servers[e.Context.Guild.Id].CommandPrefix : "!"; + var guildId = e.Context.Guild?.Id ?? e.Context.Client.Guilds.FirstOrDefault(x => _whConfig.Servers.ContainsKey(x.Key)).Key; + var prefix = _whConfig.Servers.ContainsKey(guildId) ? _whConfig.Servers[guildId].CommandPrefix : "!"; var example = $"Command Example: ```{prefix}{e.Command.Name} {string.Join(" ", e.Command.Arguments.Select(x => x.IsOptional ? $"[{x.Name}]" : x.Name))}```\r\n*Parameters in brackets are optional.*"; // let's wrap the response into an embed var embed = new DiscordEmbedBuilder { Title = $"{emoji} Invalid Argument(s)", - Description = $"{string.Join(Environment.NewLine, e.Command.Arguments.Select(x => $"Parameter **{x.Name}** expects type **{x.Type}.**"))}.\r\n\r\n{example}", + Description = $"{string.Join(Environment.NewLine, e.Command.Arguments.Select(x => $"Parameter **{x.Name}** expects type **{x.Type.ToHumanReadableString()}.**"))}.\r\n\r\n{example}", Color = new DiscordColor(0xFF0000) // red }; await e.Context.RespondAsync(embed: embed); diff --git a/src/Extensions/GenericsExtensions.cs b/src/Extensions/GenericsExtensions.cs index ac44ac7f..96f02cd5 100644 --- a/src/Extensions/GenericsExtensions.cs +++ b/src/Extensions/GenericsExtensions.cs @@ -105,5 +105,19 @@ public static bool ScrambledEquals(this IEnumerable list1, IEnumerable } return cnt.Values.All(c => c == 0); } + + public static string ToHumanReadableString(this Type type) + { + if (type == typeof(string)) + return "Text"; + else if (type == typeof(int)) + return "Number"; + else if (type == typeof(double) || + type == typeof(float)) + return "Decimal"; + else if (type == typeof(bool)) + return "Boolean"; + return type.Name.ToString(); + } } } \ No newline at end of file