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
|
import { PluginStore } from ".";
import {
OnChannelCreateEventArgs,
OnGuildCreateEventArgs,
OnLoginEventArgs,
OnMessageEventArgs,
OnRegisterEventArgs,
OnStatusChangeEventArgs,
OnTypingEventArgs,
PreChannelCreateEventArgs,
PreChannelCreateEventResult,
PreGuildCreateEventArgs,
PreGuildCreateEventResult,
PreLoginEventArgs,
PreLoginEventResult,
PreMessageEventArgs,
PreMessageEventResult,
PreRegisterEventArgs,
PreRegisterEventResult,
PreStatusChangeEventArgs,
PreStatusChangeEventResult,
PreTypingEventArgs,
PreTypingEventResult
} from "./event_types";
export class PluginEventHandler {
public static async preRegisterEvent(args: PreRegisterEventArgs): Promise<PreRegisterEventResult[]> {
return (
await Promise.all(PluginStore.plugins.filter((x) => x.onPreRegister).map((x) => x.onPreRegister && x.onPreRegister(args)))
).filter((x) => x) as PreRegisterEventResult[];
}
public static async onRegisterEvent(args: OnRegisterEventArgs): Promise<void> {
await Promise.all(PluginStore.plugins.filter((x) => x.onRegister).map((x) => x.onRegister && x.onRegister(args)));
}
public static async preMessageEvent(args: PreMessageEventArgs): Promise<PreMessageEventResult[]> {
return (
await Promise.all(PluginStore.plugins.filter((x) => x.onPreMessage).map((x) => x.onPreMessage && x.onPreMessage(args)))
).filter((x) => x) as PreMessageEventResult[];
}
public static async onMessageEvent(args: OnMessageEventArgs): Promise<void> {
await Promise.all(PluginStore.plugins.filter((x) => x.onMessage).map((x) => x.onMessage && x.onMessage(args)));
}
public static async preLoginEvent(args: PreLoginEventArgs): Promise<PreLoginEventResult[]> {
return (await Promise.all(PluginStore.plugins.filter((x) => x.onPreLogin).map((x) => x.onPreLogin && x.onPreLogin(args)))).filter(
(x) => x
) as PreLoginEventResult[];
}
public static async onLoginEvent(args: OnLoginEventArgs): Promise<void> {
await Promise.all(PluginStore.plugins.filter((x) => x.onLogin).map((x) => x.onLogin && x.onLogin(args)));
}
public static async preGuildCreateEvent(args: PreGuildCreateEventArgs): Promise<PreGuildCreateEventResult[]> {
return (
await Promise.all(
PluginStore.plugins.filter((x) => x.onPreGuildCreate).map((x) => x.onPreGuildCreate && x.onPreGuildCreate(args))
)
).filter((x) => x) as PreGuildCreateEventResult[];
}
public static async onGuildCreateEvent(args: OnGuildCreateEventArgs): Promise<void> {
await Promise.all(PluginStore.plugins.filter((x) => x.onGuildCreate).map((x) => x.onGuildCreate && x.onGuildCreate(args)));
}
public static async preChannelCreateEvent(args: PreChannelCreateEventArgs): Promise<PreChannelCreateEventResult[]> {
return (
await Promise.all(
PluginStore.plugins.filter((x) => x.onPreChannelCreate).map((x) => x.onPreChannelCreate && x.onPreChannelCreate(args))
)
).filter((x) => x) as PreChannelCreateEventResult[];
}
public static async onChannelCreateEvent(args: OnChannelCreateEventArgs): Promise<void> {
await Promise.all(PluginStore.plugins.filter((x) => x.onChannelCreate).map((x) => x.onChannelCreate && x.onChannelCreate(args)));
}
public static async preTypingEvent(args: PreTypingEventArgs): Promise<PreTypingEventResult[]> {
return (
await Promise.all(PluginStore.plugins.filter((x) => x.onPreTyping).map((x) => x.onPreTyping && x.onPreTyping(args)))
).filter((x) => x) as PreTypingEventResult[];
}
public static async onTypingEvent(args: OnTypingEventArgs): Promise<void> {
await Promise.all(PluginStore.plugins.filter((x) => x.onTyping).map((x) => x.onTyping && x.onTyping(args)));
}
public static async preStatusChangeEvent(args: PreStatusChangeEventArgs): Promise<PreStatusChangeEventResult[]> {
return (
await Promise.all(
PluginStore.plugins.filter((x) => x.onPreStatusChange).map((x) => x.onPreStatusChange && x.onPreStatusChange(args))
)
).filter((x) => x) as PreStatusChangeEventResult[];
}
public static async onStatusChangeEvent(args: OnStatusChangeEventArgs): Promise<void> {
await Promise.all(PluginStore.plugins.filter((x) => x.onStatusChange).map((x) => x.onStatusChange && x.onStatusChange(args)));
}
}
|