3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-14 22:07:19 +00:00

feat: AFK Command

This commit is contained in:
Jonathan 2021-04-02 23:09:12 -04:00
parent 7f75d6d8d3
commit b6c822e826
No known key found for this signature in database
GPG key ID: 19B04E3CBE0885B1
10 changed files with 262 additions and 0 deletions

31
backend/src/data/AFK.ts Normal file
View file

@ -0,0 +1,31 @@
import { BaseRepository } from "./BaseRepository";
import { getRepository, Repository } from "typeorm";
import { AFK as AFKEntity } from "./entities/AFK";
export class AFK extends BaseRepository {
private afk: Repository<AFKEntity>;
constructor() {
super();
this.afk = getRepository(AFKEntity);
}
async getUserAFKStatus(user_id: string) {
return await this.afk.findOne({ user_id });
}
async setAfkStatus(user_id: string, status: string) {
const settings = new AFKEntity();
settings.user_id = user_id;
settings.status = status;
return await this.afk.save(settings);
}
async clearAFKStatus(user_id: string) {
const afk = await this.afk.findOne({ user_id });
if (!afk) return;
return await this.afk.delete({ user_id });
}
}

View file

@ -0,0 +1,14 @@
import { Column, Entity, PrimaryColumn } from "typeorm";
@Entity("afk")
export class AFK {
@Column()
@PrimaryColumn()
id: string;
@Column()
user_id: string;
@Column()
status: string;
}