PluralKit/PluralKit.Bot/Commands/System.cs

59 lines
2.4 KiB
C#
Raw Normal View History

2020-02-01 13:03:02 +01:00
using PluralKit.Core;
namespace PluralKit.Bot;
using Myriad.Builders;
using Myriad.Types;
public class System
2020-02-01 13:03:02 +01:00
{
private readonly EmbedService _embeds;
2021-11-26 22:02:58 -05:00
public System(EmbedService embeds, ModelRepository repo)
2020-02-01 13:03:02 +01:00
{
_embeds = embeds;
}
public async Task Query(Context ctx, PKSystem system)
{
if (system == null) throw Errors.NoSystemError;
await ctx.Reply(embed: await _embeds.CreateSystemEmbed(ctx, system, ctx.LookupContextFor(system.Id)));
}
public async Task New(Context ctx)
{
ctx.CheckNoSystem();
var systemName = ctx.RemainderOrNull();
if (systemName != null && systemName.Length > Limits.MaxSystemNameLength)
throw Errors.StringTooLongError("System name", systemName.Length, Limits.MaxSystemNameLength);
var system = await ctx.Repository.CreateSystem(systemName);
await ctx.Repository.AddAccount(system.Id, ctx.Author.Id);
var eb = new EmbedBuilder()
.Title(
$"{Emojis.Success} Your system has been created.")
.Field(new Embed.Field("Getting Started",
"New to PK? Check out our Getting Started guide on setting up members and proxies: https://pluralkit.me/start\n" +
"Otherwise, type `pk;system` to view your system and `pk;system help` for more information about commands you can use."))
.Field(new Embed.Field("System Recovery", "In the case of your Discord account getting lost or deleted, the PluralKit staff can help you recover your system. " +
"In order to do so, we will need your **PluralKit token**. This is the *only* way you can prove ownership so we can help you recover your system. " +
"To get it, run `pk;token` and then store it in a safe place.\n\n" +
"Keep your token safe, if other people get access to it they can also use it to access your system. " +
"If your token is ever compromised run `pk;token refresh` to invalidate the old token and get a new one."))
.Field(new Embed.Field("Questions?",
"Please join the PK server https://discord.gg/PczBt78 if you have any questions, we're happy to help"));
await ctx.Reply(embed: eb.Build());
2020-02-01 13:03:02 +01:00
}
2022-08-27 13:52:50 +02:00
public async Task DisplayId(Context ctx, PKSystem target)
{
if (target == null)
throw Errors.NoSystemError;
2024-04-28 15:46:06 +12:00
await ctx.Reply(target.DisplayHid(ctx.Config));
2022-08-27 13:52:50 +02:00
}
2021-08-27 11:03:47 -04:00
}