summary refs log tree commit diff
path: root/src/util/plugin/Plugin.ts
blob: 6a6f03f415627335cd3110c9cdde21558b4d91d9 (plain) (blame)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import EventEmitter from "events";
import { PluginLoadedEventArgs, PluginManifest, TypedEventEmitter } from "@fosscord/util";
import { PluginConfig } from "./PluginConfig";
import { PreRegisterEventArgs, PreRegisterEventResult, OnRegisterEventArgs } from '.';
import { PreMessageEventArgs, PreMessageEventResult, OnMessageEventArgs } from '.';
import { PreLoginEventArgs, PreLoginEventResult, OnLoginEventArgs } from '.';
import { PreGuildCreateEventArgs, PreGuildCreateEventResult, OnGuildCreateEventArgs } from '.';
import { PreChannelCreateEventArgs, PreChannelCreateEventResult, OnChannelCreateEventArgs } from '.';
import { PreTypingEventArgs, PreTypingEventResult, OnTypingEventArgs } from '.';
import { PreStatusChangeEventArgs, PreStatusChangeEventResult, OnStatusChangeEventArgs } from '.';


/*type PluginEvents = {
	error: (error: Error | unknown) => void;
	loaded: () => void;
};*/

//this doesnt work, check later:
//EventEmitter as new () => TypedEventEmitter<PluginEvents>
export class Plugin {
	/**
	 * Path the plugin resides in.
	 *
	 * @type {string}
	 * @memberof Plugin
	 */
	pluginPath?: string;
	pluginManifest?: PluginManifest;
	/**
	 *	
	 *
	 * @param {PluginLoadedEventArgs} args Info about plugin environment
	 * @memberof Plugin
	 */
	async onPluginLoaded?(args?: PluginLoadedEventArgs) {

	}

	//generated
	/**
	* RegisterEvent: document me
	*
	* @param {OnRegisterEventArgs} args Info about what's going on
	* @memberof Plugin
	*/
	async onRegister?(args: OnRegisterEventArgs): Promise<void>;

	/**
	* RegisterEvent: Executed before changes are announced
	* document me.
	*
	* @param {PreRegisterEventArgs} args Info about what's going on
	* @return {PreRegisterEventResult} How event should be handled
	* @memberof Plugin
	*/
	async onPreRegister?(args: PreRegisterEventArgs): Promise<PreRegisterEventResult>;
	/**
	* MessageEvent: document me
	*
	* @param {OnMessageEventArgs} args Info about what's going on
	* @memberof Plugin
	*/
	async onMessage?(args: OnMessageEventArgs): Promise<void>;

	/**
	* MessageEvent: Executed before changes are announced
	* document me.
	*
	* @param {PreMessageEventArgs} args Info about what's going on
	* @return {PreMessageEventResult} How event should be handled
	* @memberof Plugin
	*/
	async onPreMessage?(args: PreMessageEventArgs): Promise<PreMessageEventResult>;
	/**
	* LoginEvent: document me
	*
	* @param {OnLoginEventArgs} args Info about what's going on
	* @memberof Plugin
	*/
	async onLogin?(args: OnLoginEventArgs): Promise<void>;

	/**
	* LoginEvent: Executed before changes are announced
	* document me.
	*
	* @param {PreLoginEventArgs} args Info about what's going on
	* @return {PreLoginEventResult} How event should be handled
	* @memberof Plugin
	*/
	async onPreLogin?(args: PreLoginEventArgs): Promise<PreLoginEventResult>;
	/**
	* GuildCreateEvent: document me
	*
	* @param {OnGuildCreateEventArgs} args Info about what's going on
	* @memberof Plugin
	*/
	async onGuildCreate?(args: OnGuildCreateEventArgs): Promise<void>;

	/**
	* GuildCreateEvent: Executed before changes are announced
	* document me.
	*
	* @param {PreGuildCreateEventArgs} args Info about what's going on
	* @return {PreGuildCreateEventResult} How event should be handled
	* @memberof Plugin
	*/
	async onPreGuildCreate?(args: PreGuildCreateEventArgs): Promise<PreGuildCreateEventResult>;
	/**
	* ChannelCreateEvent: document me
	*
	* @param {OnChannelCreateEventArgs} args Info about what's going on
	* @memberof Plugin
	*/
	async onChannelCreate?(args: OnChannelCreateEventArgs): Promise<void>;

	/**
	* ChannelCreateEvent: Executed before changes are announced
	* document me.
	*
	* @param {PreChannelCreateEventArgs} args Info about what's going on
	* @return {PreChannelCreateEventResult} How event should be handled
	* @memberof Plugin
	*/
	async onPreChannelCreate?(args: PreChannelCreateEventArgs): Promise<PreChannelCreateEventResult>;
	/**
	* TypingEvent: document me
	*
	* @param {OnTypingEventArgs} args Info about what's going on
	* @memberof Plugin
	*/
	async onTyping?(args: OnTypingEventArgs): Promise<void>;

	/**
	* TypingEvent: Executed before changes are announced
	* document me.
	*
	* @param {PreTypingEventArgs} args Info about what's going on
	* @return {PreTypingEventResult} How event should be handled
	* @memberof Plugin
	*/
	async onPreTyping?(args: PreTypingEventArgs): Promise<PreTypingEventResult>;
	/**
	* StatusChangeEvent: document me
	*
	* @param {OnStatusChangeEventArgs} args Info about what's going on
	* @memberof Plugin
	*/
	async onStatusChange?(args: OnStatusChangeEventArgs): Promise<void>;

	/**
	* StatusChangeEvent: Executed before changes are announced
	* document me.
	*
	* @param {PreStatusChangeEventArgs} args Info about what's going on
	* @return {PreStatusChangeEventResult} How event should be handled
	* @memberof Plugin
	*/
	async onPreStatusChange?(args: PreStatusChangeEventArgs): Promise<PreStatusChangeEventResult>;

}