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:
parent
7f75d6d8d3
commit
b6c822e826
10 changed files with 262 additions and 0 deletions
31
backend/src/data/AFK.ts
Normal file
31
backend/src/data/AFK.ts
Normal 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 });
|
||||
}
|
||||
}
|
14
backend/src/data/entities/AFK.ts
Normal file
14
backend/src/data/entities/AFK.ts
Normal 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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue