示例#1
0
        public static CakeEmbedBuilder ReturnUserBest(OsuJsonUser user, string thumbnail, List <Tuple <string, string> > fields, int mode)
        {
            var embedTop = new CakeEmbedBuilder();

            embedTop.WithAuthor(author =>
            {
                author
                .WithName($"Top play(s) of {user.username}")
                .WithUrl($"{user.url}")
                .WithIconUrl($"{user.image}");
            })
            .WithFooter($"{(OsuModeEnum)mode}")
            .WithThumbnailUrl(thumbnail);

            //data of fields.
            foreach (var field in fields)
            {
                embedTop.AddField(x =>
                {
                    x.Name  = field.Item1;
                    x.Value = field.Item2;
                });
            }

            return(embedTop);
        }
示例#2
0
        private void Init(string message)
        {
            _logger.Log(Logging.Type.Error, message);

            _embedError = new CakeEmbedBuilder(EmbedType.Error);
            _embedError.AddField("Error", message);
        }
示例#3
0
        private void PopulateEmbedFieldsWithModuleCommands(ModuleInfo moduleInfo, ref CakeEmbedBuilder cakeEmbedBuilder, string commandSearchFilter = "")
        {
            foreach (CommandInfo command in moduleInfo.Commands)
            {
                if (!CanAddCommandToEmbedField(command))
                {
                    continue;
                }

                EmbedFieldBuilder commandField = GetEmbedFieldWithCommandInfo(command);
                cakeEmbedBuilder.AddField(commandField);
            }

            #region Local_Function

            bool CanAddCommandToEmbedField(CommandInfo command)
            {
                if (CommandHasHideAttribute(command))
                {
                    return(false);
                }

                if (!string.IsNullOrWhiteSpace(commandSearchFilter))
                {
                    if (!CommandContainsSearchFilter(command))
                    {
                        return(false);
                    }
                }

                return(true);
            }

            bool CommandContainsSearchFilter(CommandInfo command)
            {
                if (!string.IsNullOrWhiteSpace(command.Name))
                {
                    if (command.Name.Contains(commandSearchFilter))
                    {
                        return(true);
                    }
                }

                if (!string.IsNullOrWhiteSpace(command.Remarks))
                {
                    if (command.Remarks.Contains(commandSearchFilter))
                    {
                        return(true);
                    }
                }

                if (!string.IsNullOrWhiteSpace(command.Summary))
                {
                    if (command.Summary.Contains(commandSearchFilter))
                    {
                        return(true);
                    }
                }

                return(false);
            }

            EmbedFieldBuilder GetEmbedFieldWithCommandInfo(CommandInfo commandInfo)
            {
                EmbedFieldBuilder commandField = new EmbedFieldBuilder();

                commandField.WithIsInline(true);
                commandField.WithName(commandInfo.Name);
                commandField.WithValue(GetCommandDescriptionFromCommandInfo(commandInfo));
                return(commandField);
            }

            string GetCommandDescriptionFromCommandInfo(CommandInfo commandInfo)
            {
                return($"`{commandInfo.Summary}`{ System.Environment.NewLine + commandInfo.Remarks}");
            }

            #endregion
        }