aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorArjixWasTaken <53124886+ArjixWasTaken@users.noreply.github.com>2022-08-31 21:53:36 +0300
committerGitHub <noreply@github.com>2022-08-31 20:53:36 +0200
commitc3ff092162ef1a98bea78213e473be3207998d72 (patch)
tree96b5f04944064c7021cdd60e1b44e3bade2aacc2 /src/api
parenta7ccbcfca4f181790b86199a7f31d1ae19e0253f (diff)
downloadVencord-c3ff092162ef1a98bea78213e473be3207998d72.tar.gz
Vencord-c3ff092162ef1a98bea78213e473be3207998d72.tar.bz2
Vencord-c3ff092162ef1a98bea78213e473be3207998d72.zip
Add nitro bypass (#4)
Diffstat (limited to 'src/api')
-rw-r--r--src/api/MessageClicks.ts17
-rw-r--r--src/api/MessageEvents.ts73
-rw-r--r--src/api/index.ts2
3 files changed, 74 insertions, 18 deletions
diff --git a/src/api/MessageClicks.ts b/src/api/MessageClicks.ts
deleted file mode 100644
index 476896d..0000000
--- a/src/api/MessageClicks.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-type Listener = (message, channel, event) => void;
-
-const listeners = new Set<Listener>();
-
-export function _handleClick(message, channel, event) {
- for (const listener of listeners) {
- listener(message, channel, event);
- }
-}
-
-export function addListener(listener: Listener) {
- listeners.add(listener);
-}
-
-export function removeListener(listener: Listener) {
- return listeners.delete(listener);
-} \ No newline at end of file
diff --git a/src/api/MessageEvents.ts b/src/api/MessageEvents.ts
new file mode 100644
index 0000000..9ee54a6
--- /dev/null
+++ b/src/api/MessageEvents.ts
@@ -0,0 +1,73 @@
+import type { Message, Channel } from 'discord-types/general';
+import Logger from '../utils/logger';
+
+const MessageEventsLogger = new Logger("MessageEvents", "#e5c890");
+
+interface Emoji {
+ require_colons: boolean,
+ originalName: string,
+ animated: boolean
+ guildId: string,
+ name: string,
+ url: string,
+ id: string,
+}
+
+interface MessageObject {
+ content: string,
+ validNonShortcutEmojis: Emoji[]
+}
+
+type SendListener = (channelId: string, messageObj: MessageObject, extra: any) => void;
+type EditListener = (channelId: string, messageId: string, messageObj: MessageObject) => void;
+
+const sendListeners = new Set<SendListener>();
+const editListeners = new Set<EditListener>();
+
+export function _handlePreSend(channelId: string, messageObj: MessageObject, extra: any) {
+ for (const listener of sendListeners) {
+ try {
+ listener(channelId, messageObj, extra);
+ } catch (e) { MessageEventsLogger.error(`MessageSendHandler: Listener encoutered an unknown error. (${e})`) }
+ }
+}
+
+export function _handlePreEdit(channeld: string, messageId: string, messageObj: MessageObject) {
+ for (const listener of editListeners) {
+ try {
+ listener(channeld, messageId, messageObj);
+ } catch (e) { MessageEventsLogger.error(`MessageEditHandler: Listener encoutered an unknown error. (${e})`) }
+ }
+}
+
+/**
+ * Note: This event fires off before a message is sent, allowing you to edit the message.
+ */
+export function addPreSendListener(listener: SendListener) { sendListeners.add(listener) }
+/**
+ * Note: This event fires off before a message's edit is applied, allowing you to further edit the message.
+ */
+export function addPreEditListener(listener: EditListener) { editListeners.add(listener) }
+export function removePreSendListener(listener: SendListener) { sendListeners.delete(listener) }
+export function removePreEditListener(listener: EditListener) { editListeners.delete(listener) }
+
+// Message clicks
+type ClickListener = (message: Message, channel: Channel, event: MouseEvent) => void;
+
+const listeners = new Set<ClickListener>();
+
+export function _handleClick(message, channel, event) {
+ for (const listener of listeners) {
+ try {
+ listener(message, channel, event);
+ } catch (e) { MessageEventsLogger.error(`MessageClickHandler: Listener encoutered an unknown error. (${e})`) }
+ }
+}
+
+export function addClickListener(listener: ClickListener) {
+ listeners.add(listener);
+}
+
+export function removeClickListener(listener: ClickListener) {
+ return listeners.delete(listener);
+} \ No newline at end of file
diff --git a/src/api/index.ts b/src/api/index.ts
index 6688927..6172418 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1 +1 @@
-export * as MessageClicks from "./MessageClicks"; \ No newline at end of file
+export * as MessageEvents from "./MessageEvents"; \ No newline at end of file