Пример #1
0
        private async Task TriggerBadArgEmbed(string commandExecuted, SocketCommandContext context, string finalPrefix)
        {
            EmbedService embedService = Provider.GetService <EmbedService>();
            CommandInfo  cmd          = Commands.FindInfoByName(commandExecuted);

            if (cmd.Parameters.Count == 0)
            {
                await context.Channel.SendMessageAsync("", embed : Provider.GetService <EmbedService>().MakeFailFeedbackEmbed("That command takes no arguments."), lifeTime : Config.FeedbackMessageLifeTime);

                return;
            }
            EmbedBuilder badArgEmbed = new EmbedBuilder();
            string       errorString = $"You used the wrong amount of arguments.\nCheck below for the correct syntax.\n\n{finalPrefix}{cmd.Name.Bold()}\n";

            embedService.BuildFailEmbed(badArgEmbed);
            badArgEmbed.AppendEmbedDescription(errorString);
            foreach (var arg in cmd.Parameters)
            {
                badArgEmbed.AddField(x =>
                {
                    x.Name  = $"{arg.Name} - {arg.Type.ToString().Bold()}{(arg.IsOptional ? " - Optional" : "")}";
                    x.Value = arg.Summary;
                });
            }
            await context.Channel.SendMessageAsync("", embed : badArgEmbed, lifeTime : Config.FeedbackMessageLifeTime);
        }