feat: add pk;random for other systems
This commit is contained in:
parent
c77b2bb4fc
commit
ccac0a9203
@ -51,7 +51,7 @@ public partial class CommandTree
|
|||||||
public static Command MemberServerName = new Command("member servername", "member <member> servername [server name]", "Changes a member's display name in the current server");
|
public static Command MemberServerName = new Command("member servername", "member <member> servername [server name]", "Changes a member's display name in the current server");
|
||||||
public static Command MemberAutoproxy = new Command("member autoproxy", "member <member> autoproxy [on|off]", "Sets whether a member will be autoproxied when autoproxy is set to latch or front mode.");
|
public static Command MemberAutoproxy = new Command("member autoproxy", "member <member> autoproxy [on|off]", "Sets whether a member will be autoproxied when autoproxy is set to latch or front mode.");
|
||||||
public static Command MemberKeepProxy = new Command("member keepproxy", "member <member> keepproxy [on|off]", "Sets whether to include a member's proxy tags when proxying");
|
public static Command MemberKeepProxy = new Command("member keepproxy", "member <member> keepproxy [on|off]", "Sets whether to include a member's proxy tags when proxying");
|
||||||
public static Command MemberRandom = new Command("random", "random", "Shows the info card of a randomly selected member in your system.");
|
public static Command MemberRandom = new Command("system random", "system [system] random", "Shows the info card of a randomly selected member in a system.");
|
||||||
public static Command MemberPrivacy = new Command("member privacy", "member <member> privacy <name|description|birthday|pronouns|metadata|visibility|all> <public|private>", "Changes a members's privacy settings");
|
public static Command MemberPrivacy = new Command("member privacy", "member <member> privacy <name|description|birthday|pronouns|metadata|visibility|all> <public|private>", "Changes a members's privacy settings");
|
||||||
public static Command GroupInfo = new Command("group", "group <name>", "Looks up information about a group");
|
public static Command GroupInfo = new Command("group", "group <name>", "Looks up information about a group");
|
||||||
public static Command GroupNew = new Command("group new", "group new <name>", "Creates a new group");
|
public static Command GroupNew = new Command("group new", "group new <name>", "Creates a new group");
|
||||||
@ -69,7 +69,7 @@ public partial class CommandTree
|
|||||||
public static Command GroupDelete = new Command("group delete", "group <group> delete", "Deletes a group");
|
public static Command GroupDelete = new Command("group delete", "group <group> delete", "Deletes a group");
|
||||||
public static Command GroupFrontPercent = new Command("group frontpercent", "group <group> frontpercent [timespan]", "Shows a group's front breakdown.");
|
public static Command GroupFrontPercent = new Command("group frontpercent", "group <group> frontpercent [timespan]", "Shows a group's front breakdown.");
|
||||||
public static Command GroupMemberRandom = new Command("group random", "group <group> random", "Shows the info card of a randomly selected member in a group.");
|
public static Command GroupMemberRandom = new Command("group random", "group <group> random", "Shows the info card of a randomly selected member in a group.");
|
||||||
public static Command GroupRandom = new Command("random", "random group", "Shows the info card of a randomly selected group in your system.");
|
public static Command GroupRandom = new Command("system random", "system [system] random group", "Shows the info card of a randomly selected group in a system.");
|
||||||
public static Command Switch = new Command("switch", "switch <member> [member 2] [member 3...]", "Registers a switch");
|
public static Command Switch = new Command("switch", "switch <member> [member 2] [member 3...]", "Registers a switch");
|
||||||
public static Command SwitchOut = new Command("switch out", "switch out", "Registers a switch with no members");
|
public static Command SwitchOut = new Command("switch out", "switch out", "Registers a switch with no members");
|
||||||
public static Command SwitchMove = new Command("switch move", "switch move <date/time>", "Moves the latest switch in time");
|
public static Command SwitchMove = new Command("switch move", "switch move <date/time>", "Moves the latest switch in time");
|
||||||
|
@ -100,9 +100,9 @@ public partial class CommandTree
|
|||||||
return HandleAdminCommand(ctx);
|
return HandleAdminCommand(ctx);
|
||||||
if (ctx.Match("random", "r"))
|
if (ctx.Match("random", "r"))
|
||||||
if (ctx.Match("group", "g") || ctx.MatchFlag("group", "g"))
|
if (ctx.Match("group", "g") || ctx.MatchFlag("group", "g"))
|
||||||
return ctx.Execute<Random>(GroupRandom, r => r.Group(ctx));
|
return ctx.Execute<Random>(GroupRandom, r => r.Group(ctx, ctx.System));
|
||||||
else
|
else
|
||||||
return ctx.Execute<Random>(MemberRandom, m => m.Member(ctx));
|
return ctx.Execute<Random>(MemberRandom, m => m.Member(ctx, ctx.System));
|
||||||
|
|
||||||
// remove compiler warning
|
// remove compiler warning
|
||||||
return ctx.Reply(
|
return ctx.Reply(
|
||||||
@ -250,6 +250,11 @@ public partial class CommandTree
|
|||||||
await ctx.CheckSystem(target).Execute<SystemEdit>(SystemPrivacy, m => m.SystemPrivacy(ctx, target));
|
await ctx.CheckSystem(target).Execute<SystemEdit>(SystemPrivacy, m => m.SystemPrivacy(ctx, target));
|
||||||
else if (ctx.Match("delete", "remove", "destroy", "erase", "yeet"))
|
else if (ctx.Match("delete", "remove", "destroy", "erase", "yeet"))
|
||||||
await ctx.CheckSystem(target).Execute<SystemEdit>(SystemDelete, m => m.Delete(ctx, target));
|
await ctx.CheckSystem(target).Execute<SystemEdit>(SystemDelete, m => m.Delete(ctx, target));
|
||||||
|
else if (ctx.Match("random", "r"))
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task HandleMemberCommand(Context ctx)
|
private async Task HandleMemberCommand(Context ctx)
|
||||||
|
@ -15,48 +15,58 @@ public class Random
|
|||||||
|
|
||||||
// todo: get postgresql to return one random member/group instead of querying all members/groups
|
// todo: get postgresql to return one random member/group instead of querying all members/groups
|
||||||
|
|
||||||
public async Task Member(Context ctx)
|
public async Task Member(Context ctx, PKSystem target)
|
||||||
{
|
{
|
||||||
ctx.CheckSystem();
|
if (target == null)
|
||||||
|
throw Errors.NoSystemError;
|
||||||
|
|
||||||
var members = await ctx.Repository.GetSystemMembers(ctx.System.Id).ToListAsync();
|
ctx.CheckSystemPrivacy(target.Id, target.MemberListPrivacy);
|
||||||
|
|
||||||
|
var members = await ctx.Repository.GetSystemMembers(target.Id).ToListAsync();
|
||||||
|
|
||||||
if (!ctx.MatchFlag("all", "a"))
|
if (!ctx.MatchFlag("all", "a"))
|
||||||
members = members.Where(m => m.MemberVisibility == PrivacyLevel.Public).ToList();
|
members = members.Where(m => m.MemberVisibility == PrivacyLevel.Public).ToList();
|
||||||
|
else
|
||||||
|
ctx.CheckOwnSystem(target);
|
||||||
|
|
||||||
if (members == null || !members.Any())
|
if (members == null || !members.Any())
|
||||||
throw new PKError(
|
throw new PKError(
|
||||||
"Your system has no members! Please create at least one member before using this command.");
|
"Your system has no members! Please create at least one member before using this command.");
|
||||||
|
|
||||||
var randInt = randGen.Next(members.Count);
|
var randInt = randGen.Next(members.Count);
|
||||||
await ctx.Reply(embed: await _embeds.CreateMemberEmbed(ctx.System, members[randInt], ctx.Guild,
|
await ctx.Reply(embed: await _embeds.CreateMemberEmbed(target, members[randInt], ctx.Guild,
|
||||||
ctx.LookupContextFor(ctx.System.Id), ctx.Zone));
|
ctx.LookupContextFor(target.Id), ctx.Zone));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Group(Context ctx)
|
public async Task Group(Context ctx, PKSystem target)
|
||||||
{
|
{
|
||||||
ctx.CheckSystem();
|
if (target == null)
|
||||||
|
throw Errors.NoSystemError;
|
||||||
|
|
||||||
var groups = await ctx.Repository.GetSystemGroups(ctx.System.Id).ToListAsync();
|
ctx.CheckSystemPrivacy(target.Id, target.GroupListPrivacy);
|
||||||
|
|
||||||
|
var groups = await ctx.Repository.GetSystemGroups(target.Id).ToListAsync();
|
||||||
if (!ctx.MatchFlag("all", "a"))
|
if (!ctx.MatchFlag("all", "a"))
|
||||||
groups = groups.Where(g => g.Visibility == PrivacyLevel.Public).ToList();
|
groups = groups.Where(g => g.Visibility == PrivacyLevel.Public).ToList();
|
||||||
|
else
|
||||||
|
ctx.CheckOwnSystem(target);
|
||||||
|
|
||||||
if (groups == null || !groups.Any())
|
if (groups == null || !groups.Any())
|
||||||
throw new PKError(
|
throw new PKError(
|
||||||
"Your system has no groups! Please create at least one group before using this command.");
|
"Your system has no groups! Please create at least one group before using this command.");
|
||||||
|
|
||||||
var randInt = randGen.Next(groups.Count());
|
var randInt = randGen.Next(groups.Count());
|
||||||
await ctx.Reply(embed: await _embeds.CreateGroupEmbed(ctx, ctx.System, groups.ToArray()[randInt]));
|
await ctx.Reply(embed: await _embeds.CreateGroupEmbed(ctx, target, groups.ToArray()[randInt]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task GroupMember(Context ctx, PKGroup group)
|
public async Task GroupMember(Context ctx, PKGroup group)
|
||||||
{
|
{
|
||||||
ctx.CheckOwnGroup(group);
|
ctx.CheckSystemPrivacy(group.System, group.ListPrivacy);
|
||||||
|
|
||||||
var opts = ctx.ParseListOptions(ctx.DirectLookupContextFor(group.System));
|
var opts = ctx.ParseListOptions(ctx.DirectLookupContextFor(group.System));
|
||||||
opts.GroupFilter = group.Id;
|
opts.GroupFilter = group.Id;
|
||||||
|
|
||||||
var members = await ctx.Database.Execute(conn => conn.QueryMemberList(ctx.System.Id, opts.ToQueryOptions()));
|
var members = await ctx.Database.Execute(conn => conn.QueryMemberList(group.System, opts.ToQueryOptions()));
|
||||||
|
|
||||||
if (members == null || !members.Any())
|
if (members == null || !members.Any())
|
||||||
throw new PKError(
|
throw new PKError(
|
||||||
@ -64,11 +74,20 @@ public class Random
|
|||||||
|
|
||||||
if (!ctx.MatchFlag("all", "a"))
|
if (!ctx.MatchFlag("all", "a"))
|
||||||
members = members.Where(g => g.MemberVisibility == PrivacyLevel.Public);
|
members = members.Where(g => g.MemberVisibility == PrivacyLevel.Public);
|
||||||
|
else
|
||||||
|
ctx.CheckOwnGroup(group);
|
||||||
|
|
||||||
|
|
||||||
var ms = members.ToList();
|
var ms = members.ToList();
|
||||||
|
|
||||||
|
PKSystem system;
|
||||||
|
if (ctx.System?.Id == group.System)
|
||||||
|
system = ctx.System;
|
||||||
|
else
|
||||||
|
system = await ctx.Repository.GetSystem(group.System);
|
||||||
|
|
||||||
var randInt = randGen.Next(ms.Count);
|
var randInt = randGen.Next(ms.Count);
|
||||||
await ctx.Reply(embed: await _embeds.CreateMemberEmbed(ctx.System, ms[randInt], ctx.Guild,
|
await ctx.Reply(embed: await _embeds.CreateMemberEmbed(system, ms[randInt], ctx.Guild,
|
||||||
ctx.LookupContextFor(ctx.System.Id), ctx.Zone));
|
ctx.LookupContextFor(group.System), ctx.Zone));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -53,6 +53,7 @@ Some arguments indicate the use of specific Discord features. These include:
|
|||||||
- `pk;system [system] list -full` - Shows a paginated list of a system's members, with increased detail.
|
- `pk;system [system] list -full` - Shows a paginated list of a system's members, with increased detail.
|
||||||
- `pk;find <search term>` - Searches members by name.
|
- `pk;find <search term>` - Searches members by name.
|
||||||
- `pk;system [system] find <search term>` - (same as above, but for a specific system)
|
- `pk;system [system] find <search term>` - (same as above, but for a specific system)
|
||||||
|
- `pk;system [system] random [-group]` - Shows the info card of a randomly selected member [or group] in a system.
|
||||||
|
|
||||||
## Member commands
|
## Member commands
|
||||||
*Replace `<member>` with a member's name, 5-character ID or display name. For most commands, adding `-clear` will clear/delete the field.*
|
*Replace `<member>` with a member's name, 5-character ID or display name. For most commands, adding `-clear` will clear/delete the field.*
|
||||||
@ -127,7 +128,6 @@ Some arguments indicate the use of specific Discord features. These include:
|
|||||||
- `pk;blacklist remove <#channel> [#channel...]` - Removes the given channel(s) from the proxy blacklist.
|
- `pk;blacklist remove <#channel> [#channel...]` - Removes the given channel(s) from the proxy blacklist.
|
||||||
|
|
||||||
## Utility
|
## Utility
|
||||||
- `pk;random [-group]` - Shows the info card of a randomly selected member [or group] in your system.
|
|
||||||
- `pk;message <message id|message link|reply>` - Looks up information about a proxied message by its message ID or link.
|
- `pk;message <message id|message link|reply>` - Looks up information about a proxied message by its message ID or link.
|
||||||
- `pk;invite` - Sends the bot invite link for PluralKit.
|
- `pk;invite` - Sends the bot invite link for PluralKit.
|
||||||
- `pk;import` - Imports a data file from PluralKit or Tupperbox.
|
- `pk;import` - Imports a data file from PluralKit or Tupperbox.
|
||||||
|
Loading…
Reference in New Issue
Block a user