From 7d936efb2f37db42c3e57ee9a915ed4d5ab8e25f Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Sat, 27 Aug 2022 05:18:48 +0200 Subject: Cleanup, reformat, fix some todos, git hook fixup! Cleanup, reformat, fix some todos, git hook --- src/plugins/example-plugin/TestPlugin.ts | 52 ++++++++++++++++++------------ src/plugins/example-plugin/TestSettings.ts | 14 ++++---- src/plugins/example-plugin/plugin.json | 14 ++++---- 3 files changed, 44 insertions(+), 36 deletions(-) (limited to 'src/plugins/example-plugin') diff --git a/src/plugins/example-plugin/TestPlugin.ts b/src/plugins/example-plugin/TestPlugin.ts index 18e634f7..da25c474 100644 --- a/src/plugins/example-plugin/TestPlugin.ts +++ b/src/plugins/example-plugin/TestPlugin.ts @@ -1,26 +1,36 @@ -import { setupListener } from "@fosscord/gateway"; -import { Channel, Guild, Plugin, PluginLoadedEventArgs, PluginLoader, PluginManifest, PreMessageEventArgs, PreMessageEventResult } from "@fosscord/util"; +import { + Channel, + Guild, + Plugin, + PluginLoadedEventArgs, + PluginLoader, + PluginManifest, + PreMessageEventArgs, + PreMessageEventResult +} from "@fosscord/util"; import { TestSettings } from "./TestSettings"; export default class TestPlugin implements Plugin { - 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 { - 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; + 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 { + 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"); - 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!"; - } + let result = { cancel: block } as PreMessageEventResult; - return result; - } -} \ No newline at end of file + 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; + } +} diff --git a/src/plugins/example-plugin/TestSettings.ts b/src/plugins/example-plugin/TestSettings.ts index d8c52187..f7ec79ff 100644 --- a/src/plugins/example-plugin/TestSettings.ts +++ b/src/plugins/example-plugin/TestSettings.ts @@ -1,11 +1,11 @@ export class TestSettings { - someInt: number = 10; - someStr: string = "asdf"; - someBool: boolean = true; - someDate: Date = new Date(); - subSettings: SubSettings = new SubSettings(); + 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 + someStr: string = "jklm"; +} diff --git a/src/plugins/example-plugin/plugin.json b/src/plugins/example-plugin/plugin.json index f6c1b7ff..4db01152 100644 --- a/src/plugins/example-plugin/plugin.json +++ b/src/plugins/example-plugin/plugin.json @@ -1,10 +1,8 @@ { - "id": "example-plugin", - "name": "Fosscord example plugin", - "authors": [ - "The Arcane Brony" - ], - "repository": "https://github.com/fosscord/fosscord-server", - "license": "", - "mainClass": "TestPlugin" + "id": "example-plugin", + "name": "Fosscord example plugin", + "authors": ["The Arcane Brony"], + "repository": "https://github.com/fosscord/fosscord-server", + "license": "", + "mainClass": "TestPlugin" } -- cgit 1.5.1