aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorNico <nico@d3sox.me>2022-11-07 22:23:34 +0100
committerGitHub <noreply@github.com>2022-11-07 22:23:34 +0100
commit7d5ade21fc9b56d21e2eb9e5b0d35502432adaa2 (patch)
treef89faaff4d3ddae39c20ecf84bf0ce6cd12a696e /src/api
parentd69dfd62057182756610f4dbc644d074301d9433 (diff)
downloadVencord-7d5ade21fc9b56d21e2eb9e5b0d35502432adaa2.tar.gz
Vencord-7d5ade21fc9b56d21e2eb9e5b0d35502432adaa2.tar.bz2
Vencord-7d5ade21fc9b56d21e2eb9e5b0d35502432adaa2.zip
feat(nitroBypass): add sticker bypass (#184)
Co-authored-by: Vendicated <vendicated@riseup.net>
Diffstat (limited to 'src/api')
-rw-r--r--src/api/MessageEvents.ts24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/api/MessageEvents.ts b/src/api/MessageEvents.ts
index 90e8c73..8411c9a 100644
--- a/src/api/MessageEvents.ts
+++ b/src/api/MessageEvents.ts
@@ -37,25 +37,33 @@ export interface MessageObject {
validNonShortcutEmojis: Emoji[];
}
-export type SendListener = (channelId: string, messageObj: MessageObject, extra: any) => void;
+export interface MessageExtra {
+ stickerIds?: string[];
+}
+
+export type SendListener = (channelId: string, messageObj: MessageObject, extra: MessageExtra) => void | { cancel: boolean };
export 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) {
+export function _handlePreSend(channelId: string, messageObj: MessageObject, extra: MessageExtra) {
for (const listener of sendListeners) {
try {
- listener(channelId, messageObj, extra);
- } catch (e) { MessageEventsLogger.error(`MessageSendHandler: Listener encoutered an unknown error. (${e})`); }
+ const result = listener(channelId, messageObj, extra);
+ if (result && result.cancel === true) {
+ return true;
+ }
+ } catch (e) { MessageEventsLogger.error("MessageSendHandler: Listener encountered an unknown error\n", e); }
}
+ return false;
}
-export function _handlePreEdit(channeld: string, messageId: string, messageObj: MessageObject) {
+export function _handlePreEdit(channelId: 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})`); }
+ listener(channelId, messageId, messageObj);
+ } catch (e) { MessageEventsLogger.error("MessageEditHandler: Listener encountered an unknown error\n", e); }
}
}
@@ -90,7 +98,7 @@ export function _handleClick(message: Message, channel: Channel, event: MouseEve
for (const listener of listeners) {
try {
listener(message, channel, event);
- } catch (e) { MessageEventsLogger.error(`MessageClickHandler: Listener encoutered an unknown error. (${e})`); }
+ } catch (e) { MessageEventsLogger.error("MessageClickHandler: Listener encountered an unknown error\n", e); }
}
}