aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRie Takahashi <megumin.bakaretsurie@gmail.com>2022-10-09 17:27:50 +0100
committerRie Takahashi <megumin.bakaretsurie@gmail.com>2022-10-09 17:27:50 +0100
commit43951456d33342289abe09bde8e93a7e92346856 (patch)
treecf5aa32c23edf3f0deef1722e372daecfe5fe838 /src
parentd3c581eb4e099e3dd368b8e9880752c1ba2a0849 (diff)
downloadVencord-43951456d33342289abe09bde8e93a7e92346856.tar.gz
Vencord-43951456d33342289abe09bde8e93a7e92346856.tar.bz2
Vencord-43951456d33342289abe09bde8e93a7e92346856.zip
🗿🗿🗿
Diffstat (limited to 'src')
-rw-r--r--src/plugins/moyai.ts27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/plugins/moyai.ts b/src/plugins/moyai.ts
index 7e629fc..938864c 100644
--- a/src/plugins/moyai.ts
+++ b/src/plugins/moyai.ts
@@ -1,6 +1,7 @@
import definePlugin from "../utils/types";
import { Devs } from "../utils/constants";
import { Message } from "discord-types/general";
+import { FluxDispatcher } from "../webpack/common";
interface IMessageCreate {
type: "MESSAGE_CREATE";
@@ -23,9 +24,9 @@ export default definePlugin({
if (event.message.state === "SENDING") return;
if (event.optimistic) return;
- const isInGuildChannel =
+ const isInChannel =
window.location.pathname.startsWith("/channels/");
- if (!isInGuildChannel) return;
+ if (!isInChannel) return;
const channelId = window.location.pathname.split("/")[3];
if (!channelId || channelId !== event.channelId) return;
@@ -40,18 +41,12 @@ export default definePlugin({
await new Promise(resolve => setTimeout(resolve, 300));
}
},
- patches: [
- {
- find: "MESSAGE_CREATE:function(",
- replacement: [
- {
- match: /MESSAGE_CREATE:function\((\w+)\){/,
- replace:
- "MESSAGE_CREATE:function($1){Vencord.Plugins.plugins.Moyai.execute($1);",
- },
- ],
- },
- ],
+ start() {
+ FluxDispatcher.subscribe("MESSAGE_CREATE", this.execute);
+ },
+ stop() {
+ FluxDispatcher.unsubscribe("MESSAGE_CREATE", this.execute);
+ }
});
const EMOJI_NAME_REGEX = /<a?:(\w+):\d+>/g;
@@ -76,7 +71,5 @@ function messageContainsMoyai(message: string): number {
}
// Maximum moyai...
- if (moyaiCount > 10) moyaiCount = 10;
-
- return moyaiCount;
+ return Math.min(moyaiCount, 10);
}