コード例 #1
0
        public async Task Help()
        {
            var builder = new EmbedBuilder()
            {
                Color       = new Color(114, 137, 218),
                Description = "Mögliche Commands:"
            };

            foreach (var m in _service.Modules)
            {
                string moduleDesc = null;
                foreach (var c in m.Commands)
                {
                    var result = await c.CheckPreconditionsAsync(Context);

                    if (result.IsSuccess)
                    {
                        moduleDesc += $"![{(string.Join(",", c.Aliases))}][{string.Join(",", c.Parameters.Select(x => $"{x.Type.Name}:{x.Name}"))}]\n";
                    }
                }
                if (!string.IsNullOrWhiteSpace(moduleDesc))
                {
                    builder.AddField(x =>
                    {
                        x.Name     = m.Name;
                        x.Value    = moduleDesc;
                        x.IsInline = false;
                    });
                }
            }
            builder.AddField(x =>
            {
                x.Name     = "Shortcuts";
                x.Value    = string.Join("\n", Looter.Shorts);
                x.IsInline = false;
            });

            await ReplyAsync("Bidde", false, builder.Build());

            StringBuilder sb   = new StringBuilder();
            var           tags = Looter.GetAllTags()
                                 .Select(y => $"{y.Key} [{y.Value}]")
                                 .ToList();
            int length = 0;

            string NEWLINE           = Environment.NewLine;
            string TAG_HEADER        = "Tags : " + NEWLINE;
            int    ADDITIONAL_LENGTH = (TAG_HEADER + NEWLINE).Length;

            for (int i = 0; i < tags.Count; i++)
            {
                if (length + tags[i].Length + ADDITIONAL_LENGTH >= 2000)
                {
                    await ReplyAsync(TAG_HEADER + sb.ToString());

                    length = 0;
                    sb.Clear();
                }
                sb.Append(tags[i] + NEWLINE);
                length += tags[i].Length + 2;
            }
            if (length > 0)
            {
                await ReplyAsync(TAG_HEADER + sb.ToString());
            }
        }