PluralKit/PluralKit.Bot/Commands/SystemList.cs

38 lines
993 B
C#
Raw Normal View History

2020-06-04 11:21:47 +00:00
using System.Text;
2020-02-01 12:03:02 +00:00
using PluralKit.Core;
2020-02-01 12:03:02 +00:00
namespace PluralKit.Bot;
2021-08-27 15:03:47 +00:00
public class SystemList
{
public async Task MemberList(Context ctx, PKSystem target)
{
if (target == null) throw Errors.NoSystemError;
ctx.CheckSystemPrivacy(target, target.MemberListPrivacy);
var opts = ctx.ParseMemberListOptions(ctx.LookupContextFor(target.Id));
await ctx.RenderMemberList(
ctx.LookupContextFor(target.Id),
target.Id,
GetEmbedTitle(target, opts),
target.Color,
opts
);
}
2020-02-01 12:03:02 +00:00
private string GetEmbedTitle(PKSystem target, MemberListOptions opts)
{
var title = new StringBuilder("Members of ");
2021-08-27 15:03:47 +00:00
if (target.Name != null)
title.Append($"{target.Name} (`{target.Hid}`)");
else
title.Append($"`{target.Hid}`");
2021-08-27 15:03:47 +00:00
if (opts.Search != null)
title.Append($" matching **{opts.Search}**");
2021-08-27 15:03:47 +00:00
return title.ToString();
2020-02-01 12:03:02 +00:00
}
}