mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-13 21:35:02 +00:00
feat: add member cache; handle all role changes with RoleManagerPlugin; exit gracefully
This commit is contained in:
parent
fd60a09947
commit
fa50110766
48 changed files with 755 additions and 264 deletions
|
@ -2,11 +2,6 @@ import { getRepository, Repository } from "typeorm";
|
|||
import { BaseGuildRepository } from "./BaseGuildRepository";
|
||||
import { PersistedData } from "./entities/PersistedData";
|
||||
|
||||
export interface IPartialPersistData {
|
||||
roles?: string[];
|
||||
nickname?: string;
|
||||
}
|
||||
|
||||
export class GuildPersistedData extends BaseGuildRepository {
|
||||
private persistedData: Repository<PersistedData>;
|
||||
|
||||
|
@ -24,11 +19,7 @@ export class GuildPersistedData extends BaseGuildRepository {
|
|||
});
|
||||
}
|
||||
|
||||
async set(userId: string, data: IPartialPersistData = {}) {
|
||||
const finalData: any = {};
|
||||
if (data.roles) finalData.roles = data.roles.join(",");
|
||||
if (data.nickname) finalData.nickname = data.nickname;
|
||||
|
||||
async set(userId: string, data: Partial<PersistedData> = {}) {
|
||||
const existing = await this.find(userId);
|
||||
if (existing) {
|
||||
await this.persistedData.update(
|
||||
|
@ -36,11 +27,11 @@ export class GuildPersistedData extends BaseGuildRepository {
|
|||
guild_id: this.guildId,
|
||||
user_id: userId,
|
||||
},
|
||||
finalData,
|
||||
data,
|
||||
);
|
||||
} else {
|
||||
await this.persistedData.insert({
|
||||
...finalData,
|
||||
...data,
|
||||
guild_id: this.guildId,
|
||||
user_id: userId,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue