2020-02-01 13:03:02 +01:00
using PluralKit.Core ;
2021-11-26 21:10:56 -05:00
namespace PluralKit.Bot ;
2024-10-04 15:15:17 -06:00
using Myriad.Builders ;
using Myriad.Types ;
2021-11-26 21:10:56 -05:00
public class System
2020-02-01 13:03:02 +01:00
{
2021-11-26 21:10:56 -05: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
{
2021-11-26 21:10:56 -05:00
_embeds = embeds ;
}
public async Task Query ( Context ctx , PKSystem system )
{
2024-12-31 08:09:18 -07:00
if ( system = = null ) throw Errors . NoSystemError ( ctx . DefaultPrefix ) ;
2025-08-25 14:26:29 +12:00
if ( ctx . MatchFlag ( "show-embed" , "se" ) )
{
await ctx . Reply ( text : EmbedService . LEGACY_EMBED_WARNING , embed : await _embeds . CreateSystemEmbed ( ctx , system , ctx . LookupContextFor ( system . Id ) ) ) ;
return ;
}
2021-11-26 21:10:56 -05:00
2025-08-25 11:30:46 +12:00
await ctx . Reply ( components : await _embeds . CreateSystemMessageComponents ( ctx , system , ctx . LookupContextFor ( system . Id ) ) ) ;
2021-11-26 21:10:56 -05:00
}
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 ) ;
2022-01-22 03:05:01 -05:00
var system = await ctx . Repository . CreateSystem ( systemName ) ;
await ctx . Repository . AddAccount ( system . Id , ctx . Author . Id ) ;
2021-11-26 21:10:56 -05:00
2024-10-04 15:15:17 -06:00
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" +
2024-12-31 08:09:18 -07:00
$"Otherwise, type `{ctx.DefaultPrefix}system` to view your system and `{ctx.DefaultPrefix}system help` for more information about commands you can use." ) )
2025-04-27 20:43:27 -06:00
. Field ( new Embed . Field ( $"{Emojis.Warn} Notice: Public By Default {Emojis.Warn}" , "PluralKit is a bot meant to help you share information about your system. " +
2024-10-04 15:15:39 -06:00
"Member descriptions are meant to be the equivalent to a Discord About Me. Because of this, any info you put in PK is **public by default**.\n" +
"Note that this does **not** include message content, only member fields. For more information, check out " +
"[the privacy section of the user guide](https://pluralkit.me/guide/#privacy). " ) )
2025-04-27 20:43:27 -06:00
. Field ( new Embed . Field ( $"{Emojis.Warn} Notice: Implicit Acceptance of ToS {Emojis.Warn}" , "By using the PluralKit bot you implicitly agree to our " +
"[Terms of Service](https://pluralkit.me/terms-of-service/). For questions please ask in our [support server](<https://discord.gg/PczBt78>) or " +
"email legal@pluralkit.me" ) )
2024-10-04 15:15:17 -06:00
. 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. " +
2024-12-31 08:09:18 -07:00
$"To get it, run `{ctx.DefaultPrefix}token` and then store it in a safe place.\n\n" +
2024-10-04 15:15:17 -06:00
"Keep your token safe, if other people get access to it they can also use it to access your system. " +
2024-12-31 08:09:18 -07:00
$"If your token is ever compromised run `{ctx.DefaultPrefix}token refresh` to invalidate the old token and get a new one." ) )
2024-10-04 15:15:17 -06:00
. Field ( new Embed . Field ( "Questions?" ,
"Please join the PK server https://discord.gg/PczBt78 if you have any questions, we're happy to help" ) ) ;
2024-10-04 15:16:23 -06:00
await ctx . Reply ( $"{Emojis.Warn} If you cannot see the rest of this message see [the FAQ](<https://pluralkit.me/faq/#why-do-most-of-pluralkit-s-messages-look-blank-or-empty>)" , eb . Build ( ) ) ;
2024-10-04 15:15:17 -06:00
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 )
2024-12-31 08:09:18 -07:00
throw Errors . NoSystemError ( ctx . DefaultPrefix ) ;
2022-08-27 13:52:50 +02:00
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
}