mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 13:06:50 +00:00
Add group name/description/list commands
This commit is contained in:
parent
253ae43c7f
commit
6c5cb8cea7
7 changed files with 152 additions and 6 deletions
|
|
@ -35,6 +35,9 @@ namespace PluralKit.Core
|
|||
public static Task<PKGroup?> QueryGroupByHid(this IPKConnection conn, string hid) =>
|
||||
conn.QueryFirstOrDefaultAsync<PKGroup?>("select * from groups where hid = @hid", new {hid = hid.ToLowerInvariant()});
|
||||
|
||||
public static Task<IEnumerable<PKGroup>> QueryGroupsInSystem(this IPKConnection conn, SystemId system) =>
|
||||
conn.QueryAsync<PKGroup>("select * from groups where system = @System", new {System = system});
|
||||
|
||||
public static Task<GuildConfig> QueryOrInsertGuildConfig(this IPKConnection conn, ulong guild) =>
|
||||
conn.QueryFirstAsync<GuildConfig>("insert into servers (id) values (@guild) on conflict (id) do update set id = @guild returning *", new {guild});
|
||||
|
||||
|
|
|
|||
|
|
@ -65,5 +65,13 @@ namespace PluralKit.Core
|
|||
conn.QueryFirstAsync<PKGroup>(
|
||||
"insert into groups (hid, system, name) values (find_free_group_hid(), @System, @Name) returning *",
|
||||
new {System = system, Name = name});
|
||||
|
||||
public static Task<PKGroup> UpdateGroup(this IPKConnection conn, GroupId id, GroupPatch patch)
|
||||
{
|
||||
var (query, pms) = patch.Apply(UpdateQueryBuilder.Update("groups", "id = @id"))
|
||||
.WithConstant("id", id)
|
||||
.Build("returning *");
|
||||
return conn.QueryFirstAsync<PKGroup>(query, pms);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue