2020-02-01 12:03:02 +00:00
using System.Threading.Tasks ;
using PluralKit.Core ;
2020-02-12 14:16:19 +00:00
namespace PluralKit.Bot
2020-02-01 12:03:02 +00:00
{
public class System
{
private IDataStore _data ;
private EmbedService _embeds ;
public System ( EmbedService embeds , IDataStore data )
{
_embeds = embeds ;
_data = data ;
}
public async Task Query ( Context ctx , PKSystem system ) {
if ( system = = null ) throw Errors . NoSystemError ;
2020-04-24 19:50:28 +00:00
await ctx . Reply ( embed : await _embeds . CreateSystemEmbed ( ctx . Shard , system , ctx . LookupContextFor ( system ) ) ) ;
2020-02-01 12:03:02 +00:00
}
2020-04-24 19:50:28 +00:00
2020-02-01 12:03:02 +00:00
public async Task New ( Context ctx )
{
ctx . CheckNoSystem ( ) ;
2020-08-11 20:05:27 +00:00
var systemName = ctx . RemainderOrNull ( ) ;
if ( systemName ! = null & & systemName . Length > Limits . MaxSystemNameLength )
throw Errors . SystemNameTooLongError ( systemName . Length ) ;
var system = await _data . CreateSystem ( systemName ) ;
2020-02-01 12:03:02 +00:00
await _data . AddAccount ( system , ctx . Author . Id ) ;
2020-02-09 21:35:16 +00:00
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
}
}
}