2020-02-12 15:16:19 +01:00
using PluralKit.Core ;
2019-10-05 07:41:00 +02:00
2021-11-26 21:10:56 -05:00
namespace PluralKit.Bot ;
2021-11-26 22:04:04 -05:00
public partial class CommandTree
2019-10-05 07:41:00 +02:00
{
2021-11-26 21:10:56 -05:00
public Task ExecuteCommand ( Context ctx )
{
2025-05-13 17:56:29 -06:00
if ( ctx . Match ( "system" , "s" , "account" , "acc" ) )
2021-11-26 21:10:56 -05:00
return HandleSystemCommand ( ctx ) ;
if ( ctx . Match ( "member" , "m" ) )
return HandleMemberCommand ( ctx ) ;
if ( ctx . Match ( "group" , "g" ) )
return HandleGroupCommand ( ctx ) ;
if ( ctx . Match ( "switch" , "sw" ) )
return HandleSwitchCommand ( ctx ) ;
if ( ctx . Match ( "commands" , "cmd" , "c" ) )
return CommandHelpRoot ( ctx ) ;
if ( ctx . Match ( "ap" , "autoproxy" , "auto" ) )
return HandleAutoproxyCommand ( ctx ) ;
2024-10-01 05:38:26 -06:00
if ( ctx . Match ( "config" , "cfg" , "configure" ) )
2021-11-29 21:35:21 -05:00
return HandleConfigCommand ( ctx ) ;
2024-11-10 15:46:36 +13:00
if ( ctx . Match ( "serverconfig" , "guildconfig" , "scfg" ) )
return HandleServerConfigCommand ( ctx ) ;
2022-03-30 11:42:34 +02:00
if ( ctx . Match ( "list" , "find" , "members" , "search" , "query" , "l" , "f" , "fd" , "ls" ) )
2021-11-26 21:10:56 -05:00
return ctx . Execute < SystemList > ( SystemList , m = > m . MemberList ( ctx , ctx . System ) ) ;
if ( ctx . Match ( "link" ) )
return ctx . Execute < SystemLink > ( Link , m = > m . LinkSystem ( ctx ) ) ;
if ( ctx . Match ( "unlink" ) )
return ctx . Execute < SystemLink > ( Unlink , m = > m . UnlinkAccount ( ctx ) ) ;
if ( ctx . Match ( "token" ) )
if ( ctx . Match ( "refresh" , "renew" , "invalidate" , "reroll" , "regen" ) )
return ctx . Execute < Api > ( TokenRefresh , m = > m . RefreshToken ( ctx ) ) ;
2021-06-08 19:37:44 +02:00
else
2021-11-26 21:10:56 -05:00
return ctx . Execute < Api > ( TokenGet , m = > m . GetToken ( ctx ) ) ;
if ( ctx . Match ( "import" ) )
return ctx . Execute < ImportExport > ( Import , m = > m . Import ( ctx ) ) ;
if ( ctx . Match ( "export" ) )
return ctx . Execute < ImportExport > ( Export , m = > m . Export ( ctx ) ) ;
2022-05-08 13:37:17 +12:00
if ( ctx . Match ( "help" , "h" ) )
2021-11-26 21:10:56 -05:00
if ( ctx . Match ( "commands" ) )
return ctx . Reply ( "For the list of commands, see the website: <https://pluralkit.me/commands>" ) ;
else if ( ctx . Match ( "proxy" ) )
return ctx . Reply (
"The proxy help page has been moved! See the website: https://pluralkit.me/guide#proxying" ) ;
else return ctx . Execute < Help > ( Help , m = > m . HelpRoot ( ctx ) ) ;
if ( ctx . Match ( "explain" ) )
return ctx . Execute < Help > ( Explain , m = > m . Explain ( ctx ) ) ;
2024-08-29 06:32:22 -06:00
if ( ctx . Match ( "message" , "msg" , "messageinfo" ) )
2021-11-26 21:10:56 -05:00
return ctx . Execute < ProxiedMessage > ( Message , m = > m . GetMessage ( ctx ) ) ;
if ( ctx . Match ( "edit" , "e" ) )
2024-03-07 03:25:17 -08:00
return ctx . Execute < ProxiedMessage > ( MessageEdit , m = > m . EditMessage ( ctx , false ) ) ;
if ( ctx . Match ( "x" ) )
return ctx . Execute < ProxiedMessage > ( MessageEdit , m = > m . EditMessage ( ctx , true ) ) ;
2024-08-29 06:32:22 -06:00
if ( ctx . Match ( "reproxy" , "rp" , "crimes" , "crime" ) )
2022-05-09 09:10:07 +12:00
return ctx . Execute < ProxiedMessage > ( MessageReproxy , m = > m . ReproxyMessage ( ctx ) ) ;
2021-11-26 21:10:56 -05:00
if ( ctx . Match ( "log" ) )
if ( ctx . Match ( "channel" ) )
2024-11-12 05:19:44 +09:00
return ctx . Execute < ServerConfig > ( LogChannel , m = > m . SetLogChannel ( ctx ) , true ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "enable" , "on" ) )
2024-11-12 05:19:44 +09:00
return ctx . Execute < ServerConfig > ( LogEnable , m = > m . SetLogEnabled ( ctx , true ) , true ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "disable" , "off" ) )
2024-11-12 05:19:44 +09:00
return ctx . Execute < ServerConfig > ( LogDisable , m = > m . SetLogEnabled ( ctx , false ) , true ) ;
2022-06-02 22:36:42 -04:00
else if ( ctx . Match ( "list" , "show" ) )
2024-11-12 05:19:44 +09:00
return ctx . Execute < ServerConfig > ( LogShow , m = > m . ShowLogDisabledChannels ( ctx ) , true ) ;
else
2024-12-31 08:09:18 -07:00
return ctx . Reply ( $"{Emojis.Warn} Message logging commands have moved to `{ctx.DefaultPrefix}serverconfig`." ) ;
2021-11-26 21:10:56 -05:00
if ( ctx . Match ( "logclean" ) )
2024-11-10 15:46:36 +13:00
return ctx . Execute < ServerConfig > ( ServerConfigLogClean , m = > m . SetLogCleanup ( ctx ) , true ) ;
2021-11-26 21:10:56 -05:00
if ( ctx . Match ( "blacklist" , "bl" ) )
if ( ctx . Match ( "enable" , "on" , "add" , "deny" ) )
2024-11-12 05:19:44 +09:00
return ctx . Execute < ServerConfig > ( BlacklistAdd , m = > m . SetProxyBlacklisted ( ctx , true ) , true ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "disable" , "off" , "remove" , "allow" ) )
2024-11-12 05:19:44 +09:00
return ctx . Execute < ServerConfig > ( BlacklistRemove , m = > m . SetProxyBlacklisted ( ctx , false ) , true ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "list" , "show" ) )
2024-11-12 05:19:44 +09:00
return ctx . Execute < ServerConfig > ( BlacklistShow , m = > m . ShowProxyBlacklisted ( ctx ) , true ) ;
else
2024-12-31 08:09:18 -07:00
return ctx . Reply ( $"{Emojis.Warn} Blacklist commands have moved to `{ctx.DefaultPrefix}serverconfig`." ) ;
2021-11-26 21:10:56 -05:00
if ( ctx . Match ( "proxy" ) )
if ( ctx . Match ( "debug" ) )
return ctx . Execute < Checks > ( ProxyCheck , m = > m . MessageProxyCheck ( ctx ) ) ;
else
return ctx . Execute < SystemEdit > ( SystemProxy , m = > m . SystemProxy ( ctx ) ) ;
if ( ctx . Match ( "invite" ) ) return ctx . Execute < Misc > ( Invite , m = > m . Invite ( ctx ) ) ;
if ( ctx . Match ( "mn" ) ) return ctx . Execute < Fun > ( null , m = > m . Mn ( ctx ) ) ;
if ( ctx . Match ( "fire" ) ) return ctx . Execute < Fun > ( null , m = > m . Fire ( ctx ) ) ;
if ( ctx . Match ( "thunder" ) ) return ctx . Execute < Fun > ( null , m = > m . Thunder ( ctx ) ) ;
if ( ctx . Match ( "freeze" ) ) return ctx . Execute < Fun > ( null , m = > m . Freeze ( ctx ) ) ;
if ( ctx . Match ( "starstorm" ) ) return ctx . Execute < Fun > ( null , m = > m . Starstorm ( ctx ) ) ;
if ( ctx . Match ( "flash" ) ) return ctx . Execute < Fun > ( null , m = > m . Flash ( ctx ) ) ;
2022-01-30 05:04:02 +01:00
if ( ctx . Match ( "rool" ) ) return ctx . Execute < Fun > ( null , m = > m . Rool ( ctx ) ) ;
2022-02-04 03:12:14 +01:00
if ( ctx . Match ( "sus" ) ) return ctx . Execute < Fun > ( null , m = > m . Sus ( ctx ) ) ;
2021-11-26 21:10:56 -05:00
if ( ctx . Match ( "error" ) ) return ctx . Execute < Fun > ( null , m = > m . Error ( ctx ) ) ;
2024-08-29 06:32:22 -06:00
if ( ctx . Match ( "stats" , "status" ) ) return ctx . Execute < Misc > ( null , m = > m . Stats ( ctx ) ) ;
2021-11-26 21:10:56 -05:00
if ( ctx . Match ( "permcheck" ) )
return ctx . Execute < Checks > ( PermCheck , m = > m . PermCheckGuild ( ctx ) ) ;
if ( ctx . Match ( "proxycheck" ) )
return ctx . Execute < Checks > ( ProxyCheck , m = > m . MessageProxyCheck ( ctx ) ) ;
if ( ctx . Match ( "debug" ) )
return HandleDebugCommand ( ctx ) ;
if ( ctx . Match ( "admin" ) )
return HandleAdminCommand ( ctx ) ;
2024-08-29 06:32:22 -06:00
if ( ctx . Match ( "random" , "rand" , "r" ) )
2021-11-26 21:10:56 -05:00
if ( ctx . Match ( "group" , "g" ) | | ctx . MatchFlag ( "group" , "g" ) )
2022-08-27 13:32:48 +02:00
return ctx . Execute < Random > ( GroupRandom , r = > r . Group ( ctx , ctx . System ) ) ;
2021-11-26 21:10:56 -05:00
else
2022-08-27 13:32:48 +02:00
return ctx . Execute < Random > ( MemberRandom , m = > m . Member ( ctx , ctx . System ) ) ;
2024-10-04 10:39:52 -06:00
if ( ctx . Match ( "dashboard" , "dash" ) )
return ctx . Execute < Help > ( Dashboard , m = > m . Dashboard ( ctx ) ) ;
2021-06-08 19:37:44 +02:00
2024-11-10 15:46:36 +13:00
// don't send an "invalid command" response if the guild has those turned off
if ( ctx . GuildConfig ! = null & & ctx . GuildConfig ! . InvalidCommandResponseEnabled ! = true )
return Task . CompletedTask ;
2021-11-26 21:10:56 -05:00
// remove compiler warning
return ctx . Reply (
$"{Emojis.Error} Unknown command {ctx.PeekArgument().AsCode()}. For a list of possible commands, see <https://pluralkit.me/commands>." ) ;
}
2024-10-23 10:08:25 +13:00
private async Task HandleAdminAbuseLogCommand ( Context ctx )
{
ctx . AssertBotAdmin ( ) ;
if ( ctx . Match ( "n" , "new" , "create" ) )
await ctx . Execute < Admin > ( Admin , a = > a . AbuseLogCreate ( ctx ) ) ;
else
{
AbuseLog ? abuseLog = null ! ;
var account = await ctx . MatchUser ( ) ;
if ( account ! = null )
{
abuseLog = await ctx . Repository . GetAbuseLogByAccount ( account . Id ) ;
}
else
{
abuseLog = await ctx . Repository . GetAbuseLogByGuid ( new Guid ( ctx . PopArgument ( ) ) ) ;
}
if ( abuseLog = = null )
{
await ctx . Reply ( $"{Emojis.Error} Could not find an existing abuse log entry for that query." ) ;
return ;
}
if ( ! ctx . HasNext ( ) )
await ctx . Execute < Admin > ( Admin , a = > a . AbuseLogShow ( ctx , abuseLog ) ) ;
else if ( ctx . Match ( "au" , "adduser" ) )
await ctx . Execute < Admin > ( Admin , a = > a . AbuseLogAddUser ( ctx , abuseLog ) ) ;
else if ( ctx . Match ( "ru" , "removeuser" ) )
await ctx . Execute < Admin > ( Admin , a = > a . AbuseLogRemoveUser ( ctx , abuseLog ) ) ;
else if ( ctx . Match ( "desc" , "description" ) )
await ctx . Execute < Admin > ( Admin , a = > a . AbuseLogDescription ( ctx , abuseLog ) ) ;
else if ( ctx . Match ( "deny" , "deny-bot-usage" ) )
await ctx . Execute < Admin > ( Admin , a = > a . AbuseLogFlagDeny ( ctx , abuseLog ) ) ;
else if ( ctx . Match ( "yeet" , "remove" , "delete" ) )
await ctx . Execute < Admin > ( Admin , a = > a . AbuseLogDelete ( ctx , abuseLog ) ) ;
else
await ctx . Reply ( $"{Emojis.Error} Unknown subcommand {ctx.PeekArgument().AsCode()}." ) ;
}
}
2021-11-26 21:10:56 -05:00
private async Task HandleAdminCommand ( Context ctx )
{
if ( ctx . Match ( "usid" , "updatesystemid" ) )
await ctx . Execute < Admin > ( Admin , a = > a . UpdateSystemId ( ctx ) ) ;
else if ( ctx . Match ( "umid" , "updatememberid" ) )
await ctx . Execute < Admin > ( Admin , a = > a . UpdateMemberId ( ctx ) ) ;
else if ( ctx . Match ( "ugid" , "updategroupid" ) )
await ctx . Execute < Admin > ( Admin , a = > a . UpdateGroupId ( ctx ) ) ;
2022-11-23 23:53:21 +13:00
else if ( ctx . Match ( "rsid" , "rerollsystemid" ) )
await ctx . Execute < Admin > ( Admin , a = > a . RerollSystemId ( ctx ) ) ;
else if ( ctx . Match ( "rmid" , "rerollmemberid" ) )
await ctx . Execute < Admin > ( Admin , a = > a . RerollMemberId ( ctx ) ) ;
else if ( ctx . Match ( "rgid" , "rerollgroupid" ) )
await ctx . Execute < Admin > ( Admin , a = > a . RerollGroupId ( ctx ) ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "uml" , "updatememberlimit" ) )
await ctx . Execute < Admin > ( Admin , a = > a . SystemMemberLimit ( ctx ) ) ;
else if ( ctx . Match ( "ugl" , "updategrouplimit" ) )
await ctx . Execute < Admin > ( Admin , a = > a . SystemGroupLimit ( ctx ) ) ;
2022-11-23 23:54:21 +13:00
else if ( ctx . Match ( "sr" , "systemrecover" ) )
await ctx . Execute < Admin > ( Admin , a = > a . SystemRecover ( ctx ) ) ;
2024-10-23 10:08:25 +13:00
else if ( ctx . Match ( "sd" , "systemdelete" ) )
await ctx . Execute < Admin > ( Admin , a = > a . SystemDelete ( ctx ) ) ;
2025-09-09 10:43:00 -04:00
else if ( ctx . Match ( "sendmsg" , "sendmessage" ) )
await ctx . Execute < Admin > ( Admin , a = > a . SendAdminMessage ( ctx ) ) ;
2024-10-23 10:08:25 +13:00
else if ( ctx . Match ( "al" , "abuselog" ) )
await HandleAdminAbuseLogCommand ( ctx ) ;
2021-11-26 21:10:56 -05:00
else
await ctx . Reply ( $"{Emojis.Error} Unknown command." ) ;
}
private async Task HandleDebugCommand ( Context ctx )
{
var availableCommandsStr = "Available debug targets: `permissions`, `proxying`" ;
if ( ctx . Match ( "permissions" , "perms" , "permcheck" ) )
if ( ctx . Match ( "channel" , "ch" ) )
2021-09-13 04:21:03 -04:00
await ctx . Execute < Checks > ( PermCheck , m = > m . PermCheckChannel ( ctx ) ) ;
2021-08-03 21:06:14 -04:00
else
2021-11-26 21:10:56 -05:00
await ctx . Execute < Checks > ( PermCheck , m = > m . PermCheckGuild ( ctx ) ) ;
else if ( ctx . Match ( "channel" ) )
await ctx . Execute < Checks > ( PermCheck , m = > m . PermCheckChannel ( ctx ) ) ;
else if ( ctx . Match ( "proxy" , "proxying" , "proxycheck" ) )
await ctx . Execute < Checks > ( ProxyCheck , m = > m . MessageProxyCheck ( ctx ) ) ;
else if ( ! ctx . HasNext ( ) )
await ctx . Reply ( $"{Emojis.Error} You need to pass a command. {availableCommandsStr}" ) ;
else
await ctx . Reply (
$"{Emojis.Error} Unknown debug command {ctx.PeekArgument().AsCode()}. {availableCommandsStr}" ) ;
}
2021-08-03 21:06:14 -04:00
2021-11-26 21:10:56 -05:00
private async Task HandleSystemCommand ( Context ctx )
{
2021-12-05 17:21:31 -05:00
// these commands never take a system target
2022-01-26 06:20:26 -05:00
if ( ctx . Match ( "new" , "create" , "make" , "add" , "register" , "init" , "n" ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < System > ( SystemNew , m = > m . New ( ctx ) ) ;
2021-12-05 17:21:31 -05:00
else if ( ctx . Match ( "commands" , "help" ) )
await PrintCommandList ( ctx , "systems" , SystemCommands ) ;
// todo: these aren't deprecated but also shouldn't be here
else if ( ctx . Match ( "webhook" , "hook" ) )
await ctx . Execute < Api > ( null , m = > m . SystemWebhook ( ctx ) ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "proxy" ) )
await ctx . Execute < SystemEdit > ( SystemProxy , m = > m . SystemProxy ( ctx ) ) ;
2021-12-05 17:21:31 -05:00
2022-01-26 06:20:26 -05:00
// finally, parse commands that *can* take a system target
2021-12-05 17:21:31 -05:00
else
2019-10-05 07:41:00 +02:00
{
2021-12-05 17:21:31 -05:00
// try matching a system ID
var target = await ctx . MatchSystem ( ) ;
var previousPtr = ctx . Parameters . _ptr ;
// if we have a parsed target and no more commands, don't bother with the command flow
// we skip the `target != null` check here since the argument isn't be popped if it's not a system
if ( ! ctx . HasNext ( ) )
{
2022-01-26 06:20:26 -05:00
await ctx . Execute < System > ( SystemInfo , m = > m . Query ( ctx , target ? ? ctx . System ) ) ;
2021-12-05 17:21:31 -05:00
return ;
}
2022-01-26 06:20:26 -05:00
// hacky, but we need to CheckSystem(target) which throws a PKError
2023-03-25 16:08:44 -04:00
// normally PKErrors are only handled in ctx.Execute
2022-01-26 06:20:26 -05:00
try
{
await HandleSystemCommandTargeted ( ctx , target ? ? ctx . System ) ;
}
catch ( PKError e )
{
await ctx . Reply ( $"{Emojis.Error} {e.Message}" ) ;
return ;
}
2021-12-05 17:21:31 -05:00
// if we *still* haven't matched anything, the user entered an invalid command name or system reference
if ( ctx . Parameters . _ptr = = previousPtr )
{
2024-06-04 18:52:55 +09:00
if ( ! ctx . Parameters . Peek ( ) . TryParseHid ( out _ ) & & ! ctx . Parameters . Peek ( ) . TryParseMention ( out _ ) )
2021-12-05 17:21:31 -05:00
{
await PrintCommandNotFoundError ( ctx , SystemCommands ) ;
return ;
}
2024-12-31 08:09:18 -07:00
var list = CreatePotentialCommandList ( ctx . DefaultPrefix , SystemCommands ) ;
2021-12-05 17:21:31 -05:00
await ctx . Reply ( $"{Emojis.Error} {await CreateSystemNotFoundError(ctx)}\n\n"
+ $"Perhaps you meant to use one of the following commands?\n{list}" ) ;
}
2019-10-05 07:41:00 +02:00
}
2021-11-26 21:10:56 -05:00
}
2019-10-05 07:41:00 +02:00
2021-12-05 17:21:31 -05:00
private async Task HandleSystemCommandTargeted ( Context ctx , PKSystem target )
2021-11-26 21:10:56 -05:00
{
2022-05-08 10:59:22 +12:00
if ( ctx . Match ( "name" , "rename" , "changename" , "rn" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemEdit > ( SystemRename , m = > m . Name ( ctx , target ) ) ;
2023-07-19 12:48:04 +12:00
else if ( ctx . Match ( "servername" , "sn" , "sname" , "snick" , "snickname" , "servernick" , "servernickname" ,
"serverdisplayname" , "guildname" , "guildnick" , "guildnickname" , "serverdn" ) )
await ctx . Execute < SystemEdit > ( SystemServerName , m = > m . ServerName ( ctx , target ) ) ;
2022-05-08 10:27:37 +12:00
else if ( ctx . Match ( "tag" , "t" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemEdit > ( SystemTag , m = > m . Tag ( ctx , target ) ) ;
2023-05-11 20:46:46 -06:00
else if ( ctx . Match ( "servertag" , "st" , "stag" , "deer" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemEdit > ( SystemServerTag , m = > m . ServerTag ( ctx , target ) ) ;
2024-08-29 06:32:22 -06:00
else if ( ctx . Match ( "description" , "desc" , "describe" , "d" , "bio" , "info" , "text" , "intro" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemEdit > ( SystemDesc , m = > m . Description ( ctx , target ) ) ;
2024-08-29 06:32:22 -06:00
else if ( ctx . Match ( "pronouns" , "pronoun" , "prns" , "pn" ) )
2022-03-23 19:20:16 +01:00
await ctx . CheckSystem ( target ) . Execute < SystemEdit > ( SystemPronouns , m = > m . Pronouns ( ctx , target ) ) ;
2021-12-05 17:21:31 -05:00
else if ( ctx . Match ( "color" , "colour" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemEdit > ( SystemColor , m = > m . Color ( ctx , target ) ) ;
2021-12-05 17:21:31 -05:00
else if ( ctx . Match ( "banner" , "splash" , "cover" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemEdit > ( SystemBannerImage , m = > m . BannerImage ( ctx , target ) ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "avatar" , "picture" , "icon" , "image" , "pic" , "pfp" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemEdit > ( SystemAvatar , m = > m . Avatar ( ctx , target ) ) ;
2023-07-19 12:48:04 +12:00
else if ( ctx . Match ( "serveravatar" , "sa" , "servericon" , "serverimage" , "serverpfp" , "serverpic" , "savatar" , "spic" ,
"guildavatar" , "guildpic" , "guildicon" , "sicon" , "spfp" ) )
await ctx . CheckSystem ( target ) . Execute < SystemEdit > ( SystemServerAvatar , m = > m . ServerAvatar ( ctx , target ) ) ;
2022-03-30 11:42:34 +02:00
else if ( ctx . Match ( "list" , "l" , "members" , "ls" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemList > ( SystemList , m = > m . MemberList ( ctx , target ) ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "find" , "search" , "query" , "fd" , "s" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemList > ( SystemFind , m = > m . MemberList ( ctx , target ) ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "f" , "front" , "fronter" , "fronters" ) )
{
if ( ctx . Match ( "h" , "history" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemFront > ( SystemFrontHistory , m = > m . SystemFrontHistory ( ctx , target ) ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "p" , "percent" , "%" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemFront > ( SystemFrontPercent , m = > m . FrontPercent ( ctx , system : target ) ) ;
2019-10-05 07:41:00 +02:00
else
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemFront > ( SystemFronter , m = > m . SystemFronter ( ctx , target ) ) ;
2019-10-05 07:41:00 +02:00
}
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "fh" , "fronthistory" , "history" , "switches" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemFront > ( SystemFrontHistory , m = > m . SystemFrontHistory ( ctx , target ) ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "fp" , "frontpercent" , "front%" , "frontbreakdown" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemFront > ( SystemFrontPercent , m = > m . FrontPercent ( ctx , system : target ) ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "info" , "view" , "show" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < System > ( SystemInfo , m = > m . Query ( ctx , target ) ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "groups" , "gs" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < Groups > ( GroupList , g = > g . ListSystemGroups ( ctx , target ) ) ;
2021-12-05 17:21:31 -05:00
else if ( ctx . Match ( "privacy" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemEdit > ( SystemPrivacy , m = > m . SystemPrivacy ( ctx , target ) ) ;
2021-12-05 17:21:31 -05:00
else if ( ctx . Match ( "delete" , "remove" , "destroy" , "erase" , "yeet" ) )
2022-01-26 06:20:26 -05:00
await ctx . CheckSystem ( target ) . Execute < SystemEdit > ( SystemDelete , m = > m . Delete ( ctx , target ) ) ;
2022-08-27 13:52:50 +02:00
else if ( ctx . Match ( "id" ) )
await ctx . CheckSystem ( target ) . Execute < System > ( SystemId , m = > m . DisplayId ( ctx , target ) ) ;
2024-08-29 06:32:22 -06:00
else if ( ctx . Match ( "random" , "rand" , "r" ) )
2022-08-27 13:32:48 +02:00
if ( ctx . Match ( "group" , "g" ) | | ctx . MatchFlag ( "group" , "g" ) )
await ctx . CheckSystem ( target ) . Execute < Random > ( GroupRandom , r = > r . Group ( ctx , target ) ) ;
else
await ctx . CheckSystem ( target ) . Execute < Random > ( MemberRandom , m = > m . Member ( ctx , target ) ) ;
2021-11-26 21:10:56 -05:00
}
2021-08-27 11:03:47 -04:00
2021-11-26 21:10:56 -05:00
private async Task HandleMemberCommand ( Context ctx )
{
if ( ctx . Match ( "new" , "n" , "add" , "create" , "register" ) )
await ctx . Execute < Member > ( MemberNew , m = > m . NewMember ( ctx ) ) ;
else if ( ctx . Match ( "list" ) )
await ctx . Execute < SystemList > ( SystemList , m = > m . MemberList ( ctx , ctx . System ) ) ;
else if ( ctx . Match ( "commands" , "help" ) )
await PrintCommandList ( ctx , "members" , MemberCommands ) ;
else if ( await ctx . MatchMember ( ) is PKMember target )
await HandleMemberCommandTargeted ( ctx , target ) ;
else if ( ! ctx . HasNext ( ) )
await PrintCommandExpectedError ( ctx , MemberNew , MemberInfo , MemberRename , MemberDisplayName ,
MemberServerName , MemberDesc , MemberPronouns ,
MemberColor , MemberBirthday , MemberProxy , MemberDelete , MemberAvatar ) ;
else
await ctx . Reply ( $"{Emojis.Error} {ctx.CreateNotFoundError(" Member ", ctx.PopArgument())}" ) ;
}
private async Task HandleMemberCommandTargeted ( Context ctx , PKMember target )
{
// Commands that have a member target (eg. pk;member <member> delete)
2022-05-08 10:59:22 +12:00
if ( ctx . Match ( "rename" , "name" , "changename" , "setname" , "rn" ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < MemberEdit > ( MemberRename , m = > m . Name ( ctx , target ) ) ;
2024-08-29 06:32:22 -06:00
else if ( ctx . Match ( "description" , "desc" , "describe" , "d" , "bio" , "info" , "text" , "intro" ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < MemberEdit > ( MemberDesc , m = > m . Description ( ctx , target ) ) ;
2022-02-26 16:32:53 -05:00
else if ( ctx . Match ( "pronouns" , "pronoun" , "prns" , "pn" ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < MemberEdit > ( MemberPronouns , m = > m . Pronouns ( ctx , target ) ) ;
else if ( ctx . Match ( "color" , "colour" ) )
await ctx . Execute < MemberEdit > ( MemberColor , m = > m . Color ( ctx , target ) ) ;
2024-08-29 06:32:22 -06:00
else if ( ctx . Match ( "birthday" , "birth" , "bday" , "birthdate" , "cakeday" , "bdate" , "bd" ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < MemberEdit > ( MemberBirthday , m = > m . Birthday ( ctx , target ) ) ;
else if ( ctx . Match ( "proxy" , "tags" , "proxytags" , "brackets" ) )
await ctx . Execute < MemberProxy > ( MemberProxy , m = > m . Proxy ( ctx , target ) ) ;
else if ( ctx . Match ( "delete" , "remove" , "destroy" , "erase" , "yeet" ) )
await ctx . Execute < MemberEdit > ( MemberDelete , m = > m . Delete ( ctx , target ) ) ;
else if ( ctx . Match ( "avatar" , "profile" , "picture" , "icon" , "image" , "pfp" , "pic" ) )
await ctx . Execute < MemberAvatar > ( MemberAvatar , m = > m . Avatar ( ctx , target ) ) ;
2024-08-29 06:32:22 -06:00
else if ( ctx . Match ( "proxyavatar" , "proxypfp" , "webhookavatar" , "webhookpfp" , "pa" , "pavatar" , "ppfp" ) )
2023-03-02 06:11:35 +13:00
await ctx . Execute < MemberAvatar > ( MemberAvatar , m = > m . WebhookAvatar ( ctx , target ) ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "banner" , "splash" , "cover" ) )
await ctx . Execute < MemberEdit > ( MemberBannerImage , m = > m . BannerImage ( ctx , target ) ) ;
2023-03-13 16:38:20 +00:00
else if ( ctx . Match ( "group" , "groups" , "g" ) )
2021-11-26 21:10:56 -05:00
if ( ctx . Match ( "add" , "a" ) )
2021-11-26 22:04:04 -05:00
await ctx . Execute < GroupMember > ( MemberGroupAdd ,
m = > m . AddRemoveGroups ( ctx , target , Groups . AddRemoveOperation . Add ) ) ;
2024-11-08 02:02:41 +00:00
else if ( ctx . Match ( "remove" , "rem" ) )
2021-11-26 22:04:04 -05:00
await ctx . Execute < GroupMember > ( MemberGroupRemove ,
m = > m . AddRemoveGroups ( ctx , target , Groups . AddRemoveOperation . Remove ) ) ;
2019-10-05 07:41:00 +02:00
else
2021-11-26 22:04:04 -05:00
await ctx . Execute < GroupMember > ( MemberGroups , m = > m . ListMemberGroups ( ctx , target ) ) ;
2022-01-19 17:23:10 -05:00
else if ( ctx . Match ( "serveravatar" , "sa" , "servericon" , "serverimage" , "serverpfp" , "serverpic" , "savatar" , "spic" ,
2023-07-19 12:48:04 +12:00
"guildavatar" , "guildpic" , "guildicon" , "sicon" , "spfp" ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < MemberAvatar > ( MemberServerAvatar , m = > m . ServerAvatar ( ctx , target ) ) ;
else if ( ctx . Match ( "displayname" , "dn" , "dname" , "nick" , "nickname" , "dispname" ) )
await ctx . Execute < MemberEdit > ( MemberDisplayName , m = > m . DisplayName ( ctx , target ) ) ;
else if ( ctx . Match ( "servername" , "sn" , "sname" , "snick" , "snickname" , "servernick" , "servernickname" ,
"serverdisplayname" , "guildname" , "guildnick" , "guildnickname" , "serverdn" ) )
await ctx . Execute < MemberEdit > ( MemberServerName , m = > m . ServerName ( ctx , target ) ) ;
else if ( ctx . Match ( "autoproxy" , "ap" ) )
await ctx . Execute < MemberEdit > ( MemberAutoproxy , m = > m . MemberAutoproxy ( ctx , target ) ) ;
2022-05-08 13:37:17 +12:00
else if ( ctx . Match ( "keepproxy" , "keeptags" , "showtags" , "kp" ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < MemberEdit > ( MemberKeepProxy , m = > m . KeepProxy ( ctx , target ) ) ;
2023-08-10 18:03:37 +12:00
else if ( ctx . Match ( "texttospeech" , "text-to-speech" , "tts" ) )
await ctx . Execute < MemberEdit > ( MemberTts , m = > m . Tts ( ctx , target ) ) ;
2023-08-10 18:15:25 +12:00
else if ( ctx . Match ( "serverkeepproxy" , "servershowtags" , "guildshowtags" , "guildkeeptags" , "serverkeeptags" , "skp" ) )
2023-08-10 18:35:01 +12:00
await ctx . Execute < MemberEdit > ( MemberServerKeepProxy , m = > m . ServerKeepProxy ( ctx , target ) ) ;
2022-08-27 13:52:50 +02:00
else if ( ctx . Match ( "id" ) )
await ctx . Execute < Member > ( MemberId , m = > m . DisplayId ( ctx , target ) ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "privacy" ) )
await ctx . Execute < MemberEdit > ( MemberPrivacy , m = > m . Privacy ( ctx , target , null ) ) ;
else if ( ctx . Match ( "private" , "hidden" , "hide" ) )
await ctx . Execute < MemberEdit > ( MemberPrivacy , m = > m . Privacy ( ctx , target , PrivacyLevel . Private ) ) ;
2024-08-29 06:32:22 -06:00
else if ( ctx . Match ( "public" , "shown" , "show" , "unhide" , "unhidden" ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < MemberEdit > ( MemberPrivacy , m = > m . Privacy ( ctx , target , PrivacyLevel . Public ) ) ;
else if ( ctx . Match ( "soulscream" ) )
await ctx . Execute < Member > ( MemberInfo , m = > m . Soulscream ( ctx , target ) ) ;
else if ( ! ctx . HasNext ( ) ) // Bare command
await ctx . Execute < Member > ( MemberInfo , m = > m . ViewMember ( ctx , target ) ) ;
else
await PrintCommandNotFoundError ( ctx , MemberInfo , MemberRename , MemberDisplayName , MemberServerName ,
MemberDesc , MemberPronouns , MemberColor , MemberBirthday , MemberProxy , MemberDelete , MemberAvatar ,
SystemList ) ;
}
2019-10-05 07:41:00 +02:00
2021-11-26 21:10:56 -05:00
private async Task HandleGroupCommand ( Context ctx )
{
// Commands with no group argument
if ( ctx . Match ( "n" , "new" ) )
await ctx . Execute < Groups > ( GroupNew , g = > g . CreateGroup ( ctx ) ) ;
else if ( ctx . Match ( "list" , "l" ) )
await ctx . Execute < Groups > ( GroupList , g = > g . ListSystemGroups ( ctx , null ) ) ;
else if ( ctx . Match ( "commands" , "help" ) )
await PrintCommandList ( ctx , "groups" , GroupCommands ) ;
else if ( await ctx . MatchGroup ( ) is { } target )
2019-10-05 07:41:00 +02:00
{
2021-11-26 21:10:56 -05:00
// Commands with group argument
2022-05-08 10:59:22 +12:00
if ( ctx . Match ( "rename" , "name" , "changename" , "setname" , "rn" ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < Groups > ( GroupRename , g = > g . RenameGroup ( ctx , target ) ) ;
else if ( ctx . Match ( "nick" , "dn" , "displayname" , "nickname" ) )
await ctx . Execute < Groups > ( GroupDisplayName , g = > g . GroupDisplayName ( ctx , target ) ) ;
2024-08-29 06:32:22 -06:00
else if ( ctx . Match ( "description" , "desc" , "describe" , "d" , "bio" , "info" , "text" , "intro" ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < Groups > ( GroupDesc , g = > g . GroupDescription ( ctx , target ) ) ;
else if ( ctx . Match ( "add" , "a" ) )
2021-11-26 22:04:04 -05:00
await ctx . Execute < GroupMember > ( GroupAdd ,
2021-11-26 21:10:56 -05:00
g = > g . AddRemoveMembers ( ctx , target , Groups . AddRemoveOperation . Add ) ) ;
2024-11-08 02:02:41 +00:00
else if ( ctx . Match ( "remove" , "rem" ) )
2021-11-26 22:04:04 -05:00
await ctx . Execute < GroupMember > ( GroupRemove ,
2021-11-26 21:10:56 -05:00
g = > g . AddRemoveMembers ( ctx , target , Groups . AddRemoveOperation . Remove ) ) ;
2022-03-30 11:42:34 +02:00
else if ( ctx . Match ( "members" , "list" , "ms" , "l" , "ls" ) )
2021-11-26 22:04:04 -05:00
await ctx . Execute < GroupMember > ( GroupMemberList , g = > g . ListGroupMembers ( ctx , target ) ) ;
2024-11-08 02:02:41 +00:00
else if ( ctx . Match ( "random" , "rand" , "r" ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < Random > ( GroupMemberRandom , r = > r . GroupMember ( ctx , target ) ) ;
else if ( ctx . Match ( "privacy" ) )
await ctx . Execute < Groups > ( GroupPrivacy , g = > g . GroupPrivacy ( ctx , target , null ) ) ;
else if ( ctx . Match ( "public" , "pub" ) )
await ctx . Execute < Groups > ( GroupPrivacy , g = > g . GroupPrivacy ( ctx , target , PrivacyLevel . Public ) ) ;
else if ( ctx . Match ( "private" , "priv" ) )
await ctx . Execute < Groups > ( GroupPrivacy , g = > g . GroupPrivacy ( ctx , target , PrivacyLevel . Private ) ) ;
2023-07-13 20:43:56 +12:00
else if ( ctx . Match ( "delete" , "destroy" , "erase" , "yeet" ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < Groups > ( GroupDelete , g = > g . DeleteGroup ( ctx , target ) ) ;
else if ( ctx . Match ( "avatar" , "picture" , "icon" , "image" , "pic" , "pfp" ) )
await ctx . Execute < Groups > ( GroupIcon , g = > g . GroupIcon ( ctx , target ) ) ;
2021-08-02 13:46:12 -04:00
else if ( ctx . Match ( "banner" , "splash" , "cover" ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < Groups > ( GroupBannerImage , g = > g . GroupBannerImage ( ctx , target ) ) ;
else if ( ctx . Match ( "fp" , "frontpercent" , "front%" , "frontbreakdown" ) )
2022-01-19 17:59:01 -05:00
await ctx . Execute < SystemFront > ( GroupFrontPercent , g = > g . FrontPercent ( ctx , group : target ) ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "color" , "colour" ) )
await ctx . Execute < Groups > ( GroupColor , g = > g . GroupColor ( ctx , target ) ) ;
2022-08-27 13:52:50 +02:00
else if ( ctx . Match ( "id" ) )
await ctx . Execute < Groups > ( GroupId , g = > g . DisplayId ( ctx , target ) ) ;
2020-07-06 19:50:39 +02:00
else if ( ! ctx . HasNext ( ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < Groups > ( GroupInfo , g = > g . ShowGroupCard ( ctx , target ) ) ;
2020-07-06 19:50:39 +02:00
else
2021-11-26 21:10:56 -05:00
await PrintCommandNotFoundError ( ctx , GroupCommandsTargeted ) ;
2020-06-29 23:51:12 +02:00
}
2021-11-26 21:10:56 -05:00
else if ( ! ctx . HasNext ( ) )
await PrintCommandExpectedError ( ctx , GroupCommands ) ;
else
await ctx . Reply ( $"{Emojis.Error} {ctx.CreateNotFoundError(" Group ", ctx.PopArgument())}" ) ;
}
2020-06-29 23:51:12 +02:00
2021-11-26 21:10:56 -05:00
private async Task HandleSwitchCommand ( Context ctx )
{
if ( ctx . Match ( "out" ) )
await ctx . Execute < Switch > ( SwitchOut , m = > m . SwitchOut ( ctx ) ) ;
2023-03-12 02:24:54 +00:00
else if ( ctx . Match ( "move" , "m" , "shift" , "offset" ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < Switch > ( SwitchMove , m = > m . SwitchMove ( ctx ) ) ;
2023-03-12 02:24:54 +00:00
else if ( ctx . Match ( "edit" , "e" , "replace" ) )
2019-10-05 07:41:00 +02:00
if ( ctx . Match ( "out" ) )
2021-11-26 21:10:56 -05:00
await ctx . Execute < Switch > ( SwitchEditOut , m = > m . SwitchEditOut ( ctx ) ) ;
2019-10-05 07:41:00 +02:00
else
2021-11-26 21:10:56 -05:00
await ctx . Execute < Switch > ( SwitchEdit , m = > m . SwitchEdit ( ctx ) ) ;
else if ( ctx . Match ( "delete" , "remove" , "erase" , "cancel" , "yeet" ) )
await ctx . Execute < Switch > ( SwitchDelete , m = > m . SwitchDelete ( ctx ) ) ;
2024-10-03 02:29:38 -06:00
else if ( ctx . Match ( "copy" , "add" , "duplicate" , "dupe" ) )
await ctx . Execute < Switch > ( SwitchCopy , m = > m . SwitchEdit ( ctx , true ) ) ;
2021-11-26 21:10:56 -05:00
else if ( ctx . Match ( "commands" , "help" ) )
await PrintCommandList ( ctx , "switching" , SwitchCommands ) ;
else if ( ctx . HasNext ( ) ) // there are following arguments
await ctx . Execute < Switch > ( Switch , m = > m . SwitchDo ( ctx ) ) ;
else
await PrintCommandNotFoundError ( ctx , Switch , SwitchOut , SwitchMove , SwitchEdit , SwitchEditOut ,
2024-10-03 02:29:38 -06:00
SwitchDelete , SwitchCopy , SystemFronter , SystemFrontHistory ) ;
2021-11-26 21:10:56 -05:00
}
2019-10-05 07:41:00 +02:00
2021-11-26 21:10:56 -05:00
private async Task CommandHelpRoot ( Context ctx )
{
if ( ! ctx . HasNext ( ) )
2021-08-27 11:03:47 -04:00
{
2021-11-26 21:10:56 -05:00
await ctx . Reply (
2022-01-19 17:40:27 -05:00
"Available command help targets: `system`, `member`, `group`, `switch`, `config`, `autoproxy`, `log`, `blacklist`."
2024-12-31 08:09:18 -07:00
+ $"\n- **{ctx.DefaultPrefix}commands <target>** - *View commands related to a help target.*"
2021-11-26 21:10:56 -05:00
+ "\n\nFor the full list of commands, see the website: <https://pluralkit.me/commands>" ) ;
return ;
2020-11-19 17:58:57 -05:00
}
2021-11-26 21:10:56 -05:00
switch ( ctx . PeekArgument ( ) )
2020-11-20 20:48:33 -05:00
{
2021-11-26 21:10:56 -05:00
case "system" :
case "systems" :
case "s" :
2025-05-13 17:56:29 -06:00
case "account" :
case "acc" :
2021-11-26 21:10:56 -05:00
await PrintCommandList ( ctx , "systems" , SystemCommands ) ;
break ;
case "member" :
case "members" :
case "m" :
await PrintCommandList ( ctx , "members" , MemberCommands ) ;
break ;
case "group" :
case "groups" :
case "g" :
await PrintCommandList ( ctx , "groups" , GroupCommands ) ;
break ;
case "switch" :
case "switches" :
case "switching" :
case "sw" :
await PrintCommandList ( ctx , "switching" , SwitchCommands ) ;
break ;
case "log" :
await PrintCommandList ( ctx , "message logging" , LogCommands ) ;
break ;
case "blacklist" :
case "bl" :
await PrintCommandList ( ctx , "channel blacklisting" , BlacklistCommands ) ;
break ;
2021-11-29 21:35:21 -05:00
case "config" :
case "cfg" :
await PrintCommandList ( ctx , "settings" , ConfigCommands ) ;
2021-11-26 21:10:56 -05:00
break ;
2024-11-10 15:46:36 +13:00
case "serverconfig" :
case "guildconfig" :
case "scfg" :
await PrintCommandList ( ctx , "server settings" , ServerConfigCommands ) ;
break ;
2022-01-19 17:40:27 -05:00
case "autoproxy" :
case "ap" :
await PrintCommandList ( ctx , "autoproxy" , AutoproxyCommands ) ;
break ;
2021-11-26 21:10:56 -05:00
default :
await ctx . Reply ( "For the full list of commands, see the website: <https://pluralkit.me/commands>" ) ;
break ;
2020-11-20 20:48:33 -05:00
}
2021-11-26 21:10:56 -05:00
}
2020-11-20 20:48:33 -05:00
2021-11-26 21:10:56 -05:00
private Task HandleAutoproxyCommand ( Context ctx )
{
// ctx.CheckSystem();
// oops, that breaks stuff! PKErrors before ctx.Execute don't actually do anything.
// so we just emulate checking and throwing an error.
if ( ctx . System = = null )
2024-12-31 08:09:18 -07:00
return ctx . Reply ( $"{Emojis.Error} {Errors.NoSystemError(ctx.DefaultPrefix).Message}" ) ;
2021-11-26 21:10:56 -05:00
return ctx . Execute < Autoproxy > ( AutoproxySet , m = > m . SetAutoproxyMode ( ctx ) ) ;
}
2021-11-29 21:35:21 -05:00
private Task HandleConfigCommand ( Context ctx )
{
if ( ctx . System = = null )
2024-12-31 08:09:18 -07:00
return ctx . Reply ( $"{Emojis.Error} {Errors.NoSystemError(ctx.DefaultPrefix).Message}" ) ;
2021-11-29 21:35:21 -05:00
if ( ! ctx . HasNext ( ) )
return ctx . Execute < Config > ( null , m = > m . ShowConfig ( ctx ) ) ;
if ( ctx . MatchMultiple ( new [ ] { "autoproxy" , "ap" } , new [ ] { "account" , "ac" } ) )
return ctx . Execute < Config > ( null , m = > m . AutoproxyAccount ( ctx ) ) ;
if ( ctx . MatchMultiple ( new [ ] { "autoproxy" , "ap" } , new [ ] { "timeout" , "tm" } ) )
return ctx . Execute < Config > ( null , m = > m . AutoproxyTimeout ( ctx ) ) ;
if ( ctx . Match ( "timezone" , "zone" , "tz" ) )
return ctx . Execute < Config > ( null , m = > m . SystemTimezone ( ctx ) ) ;
if ( ctx . Match ( "ping" ) )
return ctx . Execute < Config > ( null , m = > m . SystemPing ( ctx ) ) ;
2021-12-07 01:58:05 -05:00
if ( ctx . MatchMultiple ( new [ ] { "private" } , new [ ] { "member" } ) | | ctx . Match ( "mp" ) )
2021-12-01 11:48:49 -05:00
return ctx . Execute < Config > ( null , m = > m . MemberDefaultPrivacy ( ctx ) ) ;
2021-12-07 01:58:05 -05:00
if ( ctx . MatchMultiple ( new [ ] { "private" } , new [ ] { "group" } ) | | ctx . Match ( "gp" ) )
2021-12-01 11:48:49 -05:00
return ctx . Execute < Config > ( null , m = > m . GroupDefaultPrivacy ( ctx ) ) ;
2021-12-06 04:01:42 -05:00
if ( ctx . MatchMultiple ( new [ ] { "show" } , new [ ] { "private" } ) | | ctx . Match ( "sp" ) )
return ctx . Execute < Config > ( null , m = > m . ShowPrivateInfo ( ctx ) ) ;
2022-11-23 09:48:24 +01:00
if ( ctx . MatchMultiple ( new [ ] { "proxy" } , new [ ] { "case" } ) )
return ctx . Execute < Config > ( null , m = > m . CaseSensitiveProxyTags ( ctx ) ) ;
2023-03-25 23:42:47 +01:00
if ( ctx . MatchMultiple ( new [ ] { "proxy" } , new [ ] { "error" } ) | | ctx . Match ( "pe" ) )
return ctx . Execute < Config > ( null , m = > m . ProxyErrorMessageEnabled ( ctx ) ) ;
2024-04-29 16:46:18 +12:00
if ( ctx . MatchMultiple ( new [ ] { "split" } , new [ ] { "id" , "ids" } ) | | ctx . Match ( "sid" , "sids" ) )
2024-04-28 15:46:06 +12:00
return ctx . Execute < Config > ( null , m = > m . HidDisplaySplit ( ctx ) ) ;
2024-04-29 16:46:18 +12:00
if ( ctx . MatchMultiple ( new [ ] { "cap" , "caps" , "capitalize" , "capitalise" } , new [ ] { "id" , "ids" } ) | | ctx . Match ( "capid" , "capids" ) )
2024-04-28 21:05:46 +12:00
return ctx . Execute < Config > ( null , m = > m . HidDisplayCaps ( ctx ) ) ;
2024-05-19 21:31:26 +09:00
if ( ctx . MatchMultiple ( new [ ] { "pad" } , new [ ] { "id" , "ids" } ) | | ctx . MatchMultiple ( new [ ] { "id" } , new [ ] { "pad" , "padding" } ) | | ctx . Match ( "idpad" , "padid" , "padids" ) )
return ctx . Execute < Config > ( null , m = > m . HidListPadding ( ctx ) ) ;
2025-09-07 10:16:50 +12:00
if ( ctx . MatchMultiple ( new [ ] { "show" } , new [ ] { "color" , "colour" , "colors" , "colours" } ) | | ctx . Match ( "showcolor" , "showcolour" , "showcolors" , "showcolours" , "colorcode" , "colorhex" ) )
return ctx . Execute < Config > ( null , m = > m . CardShowColorHex ( ctx ) ) ;
2024-11-12 21:18:32 +13:00
if ( ctx . MatchMultiple ( new [ ] { "name" } , new [ ] { "format" } ) | | ctx . Match ( "nameformat" , "nf" ) )
2024-10-22 03:05:32 -04:00
return ctx . Execute < Config > ( null , m = > m . NameFormat ( ctx ) ) ;
2024-10-04 05:00:07 -06:00
if ( ctx . MatchMultiple ( new [ ] { "member" , "group" } , new [ ] { "limit" } ) | | ctx . Match ( "limit" ) )
return ctx . Execute < Config > ( null , m = > m . LimitUpdate ( ctx ) ) ;
2024-11-09 11:34:06 -07:00
if ( ctx . MatchMultiple ( new [ ] { "proxy" } , new [ ] { "switch" } ) | | ctx . Match ( "proxyswitch" , "ps" ) )
return ctx . Execute < Config > ( null , m = > m . ProxySwitch ( ctx ) ) ;
2024-11-19 17:35:09 -07:00
if ( ctx . MatchMultiple ( new [ ] { "server" } , new [ ] { "name" } , new [ ] { "format" } ) | | ctx . MatchMultiple ( new [ ] { "server" , "servername" } , new [ ] { "format" , "nameformat" , "nf" } ) | | ctx . Match ( "snf" , "servernf" , "servernameformat" , "snameformat" ) )
return ctx . Execute < Config > ( null , m = > m . ServerNameFormat ( ctx ) ) ;
2021-11-29 21:35:21 -05:00
// todo: maybe add the list of configuration keys here?
2024-12-31 08:09:18 -07:00
return ctx . Reply ( $"{Emojis.Error} Could not find a setting with that name. Please see `{ctx.DefaultPrefix}commands config` for the list of possible config settings." ) ;
2021-11-29 21:35:21 -05:00
}
2024-11-10 15:46:36 +13:00
private Task HandleServerConfigCommand ( Context ctx )
{
if ( ! ctx . HasNext ( ) )
return ctx . Execute < ServerConfig > ( null , m = > m . ShowConfig ( ctx ) ) ;
if ( ctx . MatchMultiple ( new [ ] { "log" } , new [ ] { "cleanup" , "clean" } ) | | ctx . Match ( "logclean" ) )
return ctx . Execute < ServerConfig > ( null , m = > m . SetLogCleanup ( ctx ) ) ;
if ( ctx . MatchMultiple ( new [ ] { "invalid" , "unknown" } , new [ ] { "command" } , new [ ] { "error" , "response" } ) | | ctx . Match ( "invalidcommanderror" , "unknowncommanderror" ) )
return ctx . Execute < ServerConfig > ( null , m = > m . InvalidCommandResponse ( ctx ) ) ;
if ( ctx . MatchMultiple ( new [ ] { "require" , "enforce" } , new [ ] { "tag" , "systemtag" } ) | | ctx . Match ( "requiretag" , "enforcetag" ) )
return ctx . Execute < ServerConfig > ( null , m = > m . RequireSystemTag ( ctx ) ) ;
2024-12-30 06:24:28 +00:00
if ( ctx . MatchMultiple ( new [ ] { "suppress" } , new [ ] { "notifications" } ) | | ctx . Match ( "proxysilent" ) )
2024-12-30 04:33:17 +00:00
return ctx . Execute < ServerConfig > ( null , m = > m . SuppressNotifications ( ctx ) ) ;
2024-11-12 05:19:44 +09:00
if ( ctx . MatchMultiple ( new [ ] { "log" } , new [ ] { "channel" } ) )
return ctx . Execute < ServerConfig > ( null , m = > m . SetLogChannel ( ctx ) ) ;
if ( ctx . MatchMultiple ( new [ ] { "log" } , new [ ] { "blacklist" } ) )
{
if ( ctx . Match ( "enable" , "on" , "add" , "deny" ) )
return ctx . Execute < ServerConfig > ( null , m = > m . SetLogBlacklisted ( ctx , true ) ) ;
else if ( ctx . Match ( "disable" , "off" , "remove" , "allow" ) )
return ctx . Execute < ServerConfig > ( null , m = > m . SetLogBlacklisted ( ctx , false ) ) ;
else
return ctx . Execute < ServerConfig > ( null , m = > m . ShowLogDisabledChannels ( ctx ) ) ;
}
if ( ctx . MatchMultiple ( new [ ] { "proxy" , "proxying" } , new [ ] { "blacklist" } ) )
{
if ( ctx . Match ( "enable" , "on" , "add" , "deny" ) )
return ctx . Execute < ServerConfig > ( null , m = > m . SetProxyBlacklisted ( ctx , true ) ) ;
else if ( ctx . Match ( "disable" , "off" , "remove" , "allow" ) )
return ctx . Execute < ServerConfig > ( null , m = > m . SetProxyBlacklisted ( ctx , false ) ) ;
else
return ctx . Execute < ServerConfig > ( null , m = > m . ShowProxyBlacklisted ( ctx ) ) ;
}
2024-11-10 15:46:36 +13:00
// todo: maybe add the list of configuration keys here?
2024-12-31 08:09:18 -07:00
return ctx . Reply ( $"{Emojis.Error} Could not find a setting with that name. Please see `{ctx.DefaultPrefix}commands serverconfig` for the list of possible config settings." ) ;
2024-11-10 15:46:36 +13:00
}
2024-03-07 03:31:01 -08:00
}