summary refs log tree commit diff
path: root/src/plugins/example-plugin/TestPlugin.ts
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-27 05:18:48 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-09-04 10:48:54 +0200
commit7d936efb2f37db42c3e57ee9a915ed4d5ab8e25f (patch)
tree69d68d640c4ac2946b118591f02de9d3c24fb29b /src/plugins/example-plugin/TestPlugin.ts
parentAdd sqlite migration for plugin settings (diff)
downloadserver-7d936efb2f37db42c3e57ee9a915ed4d5ab8e25f.tar.xz
Cleanup, reformat, fix some todos, git hook
fixup! Cleanup, reformat, fix some todos, git hook
Diffstat (limited to 'src/plugins/example-plugin/TestPlugin.ts')
-rw-r--r--src/plugins/example-plugin/TestPlugin.ts52
1 files changed, 31 insertions, 21 deletions
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<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; + 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"); - 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; + } +}