2 files changed, 32 insertions, 7 deletions
diff --git a/src/plugins/example-plugin/TestPlugin.ts b/src/plugins/example-plugin/TestPlugin.ts
index 7a86aab2..18e634f7 100644
--- a/src/plugins/example-plugin/TestPlugin.ts
+++ b/src/plugins/example-plugin/TestPlugin.ts
@@ -1,12 +1,26 @@
-import { Plugin } from "@fosscord/util";
+import { setupListener } from "@fosscord/gateway";
+import { Channel, Guild, Plugin, PluginLoadedEventArgs, PluginLoader, PluginManifest, PreMessageEventArgs, PreMessageEventResult } from "@fosscord/util";
+import { TestSettings } from "./TestSettings";
export default class TestPlugin implements Plugin {
- pluginPath: string;
- async initConfig(): Promise<void> {
-
- }
- onPluginLoaded() {
+ pluginManifest?: PluginManifest | undefined;
+ settings: TestSettings = new TestSettings();
+ async onPluginLoaded(env: PluginLoadedEventArgs) {
console.log("Test plugin active!");
+ if(this.pluginManifest) this.settings = PluginLoader.getPluginConfig(this.pluginManifest.id, this.settings) as TestSettings;
+ }
+ async onPreMessage(data: PreMessageEventArgs): Promise<PreMessageEventResult> {
+ let channel = await Channel.findOne({ where: { id: data.message.channel_id } });
+ let guild = await Guild.findOne({ where: { id: data.message.guild_id } });
+ let block = data.message.content?.includes('UwU');
+
+ let result = {cancel: block} as PreMessageEventResult;
+
+ if(block) {
+ console.log(`[TestPlugin] Blocked message in ${guild?.name}/#${channel?.name} by ${data.message.author?.username}: ${data.message.content}`);
+ result.blockReason = "[TestPlugin] Your message contains UwU! Get bamboozled!";
+ }
+
+ return result;
}
-
}
\ No newline at end of file
diff --git a/src/plugins/example-plugin/TestSettings.ts b/src/plugins/example-plugin/TestSettings.ts
new file mode 100644
index 00000000..d8c52187
--- /dev/null
+++ b/src/plugins/example-plugin/TestSettings.ts
@@ -0,0 +1,11 @@
+export class TestSettings {
+ someInt: number = 10;
+ someStr: string = "asdf";
+ someBool: boolean = true;
+ someDate: Date = new Date();
+ subSettings: SubSettings = new SubSettings();
+}
+
+export class SubSettings {
+ someStr: string = "jklm";
+}
\ No newline at end of file
|