-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodels.ts
More file actions
74 lines (59 loc) · 1.87 KB
/
Copy pathmodels.ts
File metadata and controls
74 lines (59 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { inscriptionStatus } from './bot-constants';
import { changeMinecraftUuid, changeStatus, deleteEntry } from './services/database';
import { Client, Collection, Guild, GuildMember, Interaction } from 'discord.js';
import { whitelistAdd, whitelistRemove, whitelistReplaceUsername } from './services/rcon';
import { fetchGuildMember } from './utils';
export interface ClientWithCommands extends Client {
commands: Collection<string, any>;
buttons: Collection<string, any>;
}
export type InteractionWithCommands = Interaction & {
client: ClientWithCommands;
}
export class UserFromMojangApi {
readonly id: string;
readonly name: string;
}
export class ButtonData {
readonly name: string;
readonly permissions: BigInt;
constructor(name: string, permisions?: BigInt) {
this.name = name;
this.permissions = permisions;
}
}
export class UserFromDb {
readonly id: number;
readonly discord_uuid: string;
readonly minecraft_uuid: string;
readonly inscription_status: number;
readonly createdAt: Date;
readonly updatedAt: Date;
async delete() {
await deleteEntry(this.discord_uuid);
}
async addToWhitelist() {
await whitelistAdd(this.minecraft_uuid);
}
async removeFromWhitelist() {
await whitelistRemove(this.minecraft_uuid);
}
async replaceWhitelistUsername(newUuid: string) {
await whitelistReplaceUsername(newUuid, this.minecraft_uuid);
}
async changeStatus(newStatus: number) {
await changeStatus(this.discord_uuid, newStatus);
}
async editMinecraftUuid(newUuid: string) {
await changeMinecraftUuid(this.discord_uuid, newUuid);
}
async fetchGuildMember(guild: Guild): Promise<GuildMember> {
return await fetchGuildMember(guild, this.discord_uuid);
}
isAwaitingApproval(): boolean {
return this.inscription_status === inscriptionStatus.awaitingApproval;
}
isRejected(): boolean {
return this.inscription_status === inscriptionStatus.rejected;
}
}