diff --git a/util/src/entities/Guild.ts b/util/src/entities/Guild.ts
index 21b059a3..032a9415 100644
--- a/util/src/entities/Guild.ts
+++ b/util/src/entities/Guild.ts
@@ -1,20 +1,30 @@
import { Column, Entity, JoinColumn, ManyToMany, ManyToOne, OneToMany, OneToOne, RelationId } from "typeorm";
+import { Ban } from "./Ban";
import { BaseClass } from "./BaseClass";
import { Channel } from "./Channel";
import { Emoji } from "./Emoji";
import { Invite } from "./Invite";
import { Member } from "./Member";
import { Role } from "./Role";
+import { Sticker } from "./Sticker";
+import { Template } from "./Template";
import { User } from "./User";
import { VoiceState } from "./VoiceState";
+import { Webhook } from "./Webhook";
+
+// TODO: application_command_count, application_command_counts: {1: 0, 2: 0, 3: 0}
+// TODO: guild_scheduled_events
+// TODO: stage_instances
+// TODO: threads
@Entity("guilds")
export class Guild extends BaseClass {
+ @Column({ nullable: true })
@RelationId((guild: Guild) => guild.afk_channel)
afk_channel_id?: string;
@JoinColumn({ name: "afk_channel_id" })
- @ManyToOne(() => Channel, (channel: Channel) => channel.id)
+ @ManyToOne(() => Channel)
afk_channel?: Channel;
@Column({ nullable: true })
@@ -25,6 +35,10 @@ export class Guild extends BaseClass {
// @Column({ nullable: true })
// application?: string;
+ @JoinColumn({ name: "ban_ids" })
+ @OneToMany(() => Ban, (ban: Ban) => ban.guild)
+ bans: Ban[];
+
@Column({ nullable: true })
banner?: string;
@@ -64,52 +78,57 @@ export class Guild extends BaseClass {
@Column({ nullable: true })
presence_count?: number; // users online
- @RelationId((guild: Guild) => guild.members)
- member_ids: string[];
-
- @JoinColumn({ name: "member_ids" })
@OneToMany(() => Member, (member: Member) => member.guild)
members: Member[];
- @RelationId((guild: Guild) => guild.roles)
- role_ids: string[];
-
@JoinColumn({ name: "role_ids" })
@OneToMany(() => Role, (role: Role) => role.guild)
roles: Role[];
- @RelationId((guild: Guild) => guild.channels)
- channel_ids: string[];
-
@JoinColumn({ name: "channel_ids" })
@OneToMany(() => Channel, (channel: Channel) => channel.guild)
channels: Channel[];
- @RelationId((guild: Guild) => guild.emojis)
- emoji_ids: string[];
+ @Column({ nullable: true })
+ @RelationId((guild: Guild) => guild.template)
+ template_id: string;
+
+ @JoinColumn({ name: "template_id" })
+ @ManyToOne(() => Template)
+ template: Template;
@JoinColumn({ name: "emoji_ids" })
@OneToMany(() => Emoji, (emoji: Emoji) => emoji.guild)
emojis: Emoji[];
- @RelationId((guild: Guild) => guild.voice_states)
- voice_state_ids: string[];
+ @JoinColumn({ name: "sticker_ids" })
+ @OneToMany(() => Sticker, (sticker: Sticker) => sticker.guild)
+ stickers: Sticker[];
+
+ @JoinColumn({ name: "invite_ids" })
+ @OneToMany(() => Invite, (invite: Invite) => invite.guild)
+ invites: Invite[];
@JoinColumn({ name: "voice_state_ids" })
@OneToMany(() => VoiceState, (voicestate: VoiceState) => voicestate.guild)
voice_states: VoiceState[];
+ @JoinColumn({ name: "webhook_ids" })
+ @OneToMany(() => Webhook, (webhook: Webhook) => webhook.guild)
+ webhooks: Webhook[];
+
@Column({ nullable: true })
mfa_level?: number;
@Column()
name: string;
+ @Column({ nullable: true })
@RelationId((guild: Guild) => guild.owner)
owner_id: string;
- @JoinColumn({ name: "owner_id" })
- @OneToOne(() => User)
+ @JoinColumn([{ name: "owner_id", referencedColumnName: "id" }])
+ @ManyToOne(() => User)
owner: User;
@Column({ nullable: true })
@@ -121,18 +140,20 @@ export class Guild extends BaseClass {
@Column({ nullable: true })
premium_tier?: number; // nitro boost level
+ @Column({ nullable: true })
@RelationId((guild: Guild) => guild.public_updates_channel)
public_updates_channel_id: string;
@JoinColumn({ name: "public_updates_channel_id" })
- @OneToOne(() => Channel, (channel: Channel) => channel.id)
+ @ManyToOne(() => Channel)
public_updates_channel?: Channel;
+ @Column({ nullable: true })
@RelationId((guild: Guild) => guild.rules_channel)
rules_channel_id?: string;
@JoinColumn({ name: "rules_channel_id" })
- @OneToOne(() => Channel, (channel: Channel) => channel.id)
+ @ManyToOne(() => Channel)
rules_channel?: string;
@Column({ nullable: true })
@@ -141,11 +162,12 @@ export class Guild extends BaseClass {
@Column({ nullable: true })
splash?: string;
+ @Column({ nullable: true })
@RelationId((guild: Guild) => guild.system_channel)
system_channel_id?: string;
@JoinColumn({ name: "system_channel_id" })
- @OneToOne(() => Channel, (channel: Channel) => channel.id)
+ @ManyToOne(() => Channel)
system_channel?: Channel;
@Column({ nullable: true })
@@ -154,11 +176,12 @@ export class Guild extends BaseClass {
@Column({ nullable: true })
unavailable?: boolean;
+ @Column({ nullable: true })
@RelationId((guild: Guild) => guild.vanity_url)
vanity_url_code?: string;
@JoinColumn({ name: "vanity_url_code" })
- @OneToOne(() => Invite)
+ @ManyToOne(() => Invite)
vanity_url?: Invite;
@Column({ nullable: true })
@@ -176,11 +199,12 @@ export class Guild extends BaseClass {
}[];
};
+ @Column({ nullable: true })
@RelationId((guild: Guild) => guild.widget_channel)
widget_channel_id?: string;
@JoinColumn({ name: "widget_channel_id" })
- @OneToOne(() => Channel, (channel: Channel) => channel.id)
+ @ManyToOne(() => Channel)
widget_channel?: Channel;
@Column({ nullable: true })
|