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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
import { Column, Entity, JoinColumn, ManyToMany, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass";
import { Guild } from "./Guild";
import { Message } from "./Message";
import { User } from "./User";
export enum ChannelType {
GUILD_TEXT = 0, // a text channel within a server
DM = 1, // a direct message between users
GUILD_VOICE = 2, // a voice channel within a server
GROUP_DM = 3, // a direct message between multiple users
GUILD_CATEGORY = 4, // an organizational category that contains up to 50 channels
GUILD_NEWS = 5, // a channel that users can follow and crosspost into their own server
GUILD_STORE = 6, // a channel in which game developers can sell their game on Discord
}
@Entity("channels")
export class Channel extends BaseClass {
@Column()
created_at: Date;
@Column()
name: string;
@Column({ type: "simple-enum", enum: ChannelType })
type: ChannelType;
@Column("simple-array")
@RelationId((channel: Channel) => channel.recipients)
recipient_ids: string[];
@JoinColumn({ name: "recipient_ids" })
@ManyToMany(() => User, (user: User) => user.id)
recipients?: User[];
@RelationId((channel: Channel) => channel.last_message)
last_message_id: string;
@JoinColumn({ name: "last_message_id" })
@ManyToOne(() => Message, (message: Message) => message.id)
last_message?: Message;
@RelationId((channel: Channel) => channel.guild)
guild_id?: string;
@JoinColumn({ name: "guild_id" })
@ManyToOne(() => Guild, (guild: Guild) => guild.id)
guild: Guild;
@RelationId((channel: Channel) => channel.parent)
parent_id: string;
@JoinColumn({ name: "parent_id" })
@ManyToOne(() => Channel, (channel: Channel) => channel.id)
parent?: Channel;
@RelationId((channel: Channel) => channel.owner)
owner_id: string;
@JoinColumn({ name: "owner_id" })
@ManyToOne(() => User, (user: User) => user.id)
owner: User;
@Column({ nullable: true })
last_pin_timestamp?: number;
@Column({ nullable: true })
default_auto_archive_duration?: number;
@Column()
position: number;
@Column({ type: "simple-json" })
permission_overwrites: ChannelPermissionOverwrite[];
@Column({ nullable: true })
video_quality_mode?: number;
@Column({ nullable: true })
bitrate?: number;
@Column({ nullable: true })
user_limit?: number;
@Column()
nsfw: boolean;
@Column()
rate_limit_per_user: number;
@Column({ nullable: true })
topic?: string;
}
export interface ChannelPermissionOverwrite {
allow: bigint; // for bitfields we use bigints
deny: bigint; // for bitfields we use bigints
id: string;
type: ChannelPermissionOverwriteType;
}
export enum ChannelPermissionOverwriteType {
role = 0,
member = 1,
}
|