-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
scheduledEvent.ts
69 lines (66 loc) · 2.69 KB
/
scheduledEvent.ts
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
import { Bot } from "../bot.ts";
import {
ScheduledEvent,
ScheduledEventEntityType,
ScheduledEventPrivacyLevel,
ScheduledEventStatus,
} from "../types/guilds/scheduledEvents.ts";
import { SnakeCasedPropertiesDeep } from "../types/util.ts";
import { DiscordenoUser } from "./member.ts";
export function transformScheduledEvent(
bot: Bot,
payload: SnakeCasedPropertiesDeep<ScheduledEvent>,
): DiscordenoScheduledEvent {
return {
id: bot.transformers.snowflake(payload.id),
guildId: bot.transformers.snowflake(payload.guild_id),
channelId: payload.channel_id ? bot.transformers.snowflake(payload.channel_id) : undefined,
creatorId: payload.creator_id ? bot.transformers.snowflake(payload.creator_id) : 0n,
scheduledStartTime: Date.parse(payload.scheduled_start_time),
scheduledEndTime: payload.scheduled_end_time ? Date.parse(payload.scheduled_end_time) : undefined,
entityId: payload.entity_id ? bot.transformers.snowflake(payload.entity_id) : undefined,
creator: payload.creator ? bot.transformers.user(bot, payload.creator) : undefined,
name: payload.name,
description: payload.description,
privacyLevel: payload.privacy_level,
status: payload.status,
entityType: payload.entity_type,
userCount: payload.user_count || 0,
location: payload.entity_metadata?.location,
image: payload.image ? bot.utils.iconHashToBigInt(payload.image) : undefined,
};
}
export interface DiscordenoScheduledEvent {
/** the id of the scheduled event */
id: bigint;
/** the guild id which the scheduled event belongs to */
guildId: bigint;
/** the channel id in which the scheduled event will be hosted if specified */
channelId?: bigint;
/** the id of the user that created the scheduled event */
creatorId: bigint;
/** the name of the scheduled event */
name: string;
/** the description of the scheduled event */
description: string;
/** the time the scheduled event will start */
scheduledStartTime: number;
/** the time the scheduled event will end if it does end. */
scheduledEndTime?: number;
/** the privacy level of the scheduled event */
privacyLevel: ScheduledEventPrivacyLevel;
/** the status of the scheduled event */
status: ScheduledEventStatus;
/** the type of hosting entity associated with a scheduled event */
entityType: ScheduledEventEntityType;
/** any additional id of the hosting entity associated with event */
entityId?: bigint;
/** location of the event */
location?: string;
/** the user that created the scheduled event */
creator?: DiscordenoUser;
/** the number of users subscribed to the scheduled event */
userCount: number;
/** the cover image hash of the scheduled event */
image?: bigint;
}