feat: import/export settings, send backup of settings when leaving guild
This commit is contained in:
parent
e6d68338db
commit
db5d7bb4f8
18 changed files with 392 additions and 39 deletions
|
|
@ -65,6 +65,34 @@ public class InviteRepository(ILogger logger, DatabaseConnection conn)
|
|||
new { GuildId = guildId.Value, Code = code }
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Bulk imports an array of invite codes and names.
|
||||
/// The GuildId property in the Invite object is ignored.
|
||||
/// </summary>
|
||||
public async Task ImportInvitesAsync(Snowflake guildId, IEnumerable<Invite> invites)
|
||||
{
|
||||
await using var tx = await conn.BeginTransactionAsync();
|
||||
foreach (var invite in invites)
|
||||
{
|
||||
await conn.ExecuteAsync(
|
||||
"""
|
||||
insert into invites (code, guild_id, name)
|
||||
values (@Code, @GuildId, @Name) on conflict (code)
|
||||
do update set name = @Name
|
||||
""",
|
||||
new
|
||||
{
|
||||
GuildId = guildId.Value,
|
||||
invite.Code,
|
||||
invite.Name,
|
||||
},
|
||||
transaction: tx
|
||||
);
|
||||
}
|
||||
|
||||
await tx.CommitAsync();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
conn.Dispose();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue