2020-02-01 12:03:02 +00:00
using PluralKit.Core ;
2021-11-27 02:10:56 +00:00
namespace PluralKit.Bot ;
public class System
2020-02-01 12:03:02 +00:00
{
2021-11-27 02:10:56 +00:00
private readonly EmbedService _embeds ;
2021-11-27 03:02:58 +00:00
public System ( EmbedService embeds , ModelRepository repo )
2020-02-01 12:03:02 +00:00
{
2021-11-27 02:10:56 +00:00
_embeds = embeds ;
}
public async Task Query ( Context ctx , PKSystem system )
{
if ( system = = null ) throw Errors . NoSystemError ;
2021-12-06 05:32:54 +00:00
await ctx . Reply ( embed : await _embeds . CreateSystemEmbed ( ctx , system , ctx . LookupContextFor ( system . Id ) ) ) ;
2021-11-27 02:10:56 +00: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 08:05:01 +00:00
var system = await ctx . Repository . CreateSystem ( systemName ) ;
await ctx . Repository . AddAccount ( system . Id , ctx . Author . Id ) ;
2021-11-27 02:10:56 +00:00
// TODO: better message, perhaps embed like in groups?
await ctx . Reply (
$"{Emojis.Success} Your system has been created. Type `pk;system` to view it, and type `pk;system help` for more information about commands you can use now. Now that you have that set up, check out the getting started guide on setting up members and proxies: <https://pluralkit.me/start>" ) ;
2020-02-01 12:03:02 +00:00
}
2022-08-27 11:52:50 +00:00
public async Task DisplayId ( Context ctx , PKSystem target )
{
if ( target = = null )
throw Errors . NoSystemError ;
await ctx . Reply ( $"{target.Hid}" ) ;
}
2021-08-27 15:03:47 +00:00
}