Split Messages: patch getMaxMessageLength, not constants
This commit is contained in:
parent
e813ad2608
commit
4386bb397b
1 changed files with 8 additions and 10 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { findByProps, findByStoreName } from "@vendetta/metro";
|
||||
import { before } from "@vendetta/patcher";
|
||||
import { before, instead } from "@vendetta/patcher";
|
||||
import { storage } from "@vendetta/plugin";
|
||||
import { getAssetIDByName } from "@vendetta/ui/assets";
|
||||
import { showToast } from "@vendetta/ui/toasts";
|
||||
|
|
@ -10,21 +10,21 @@ function sleep(ms: number): Promise<void> {
|
|||
return new Promise((r) => setTimeout(r, ms));
|
||||
}
|
||||
|
||||
let unpatch: (() => boolean) | undefined;
|
||||
let unpatchMaxLength: (() => boolean) | undefined;
|
||||
let unpatchSend: (() => boolean) | undefined;
|
||||
|
||||
export default {
|
||||
onLoad() {
|
||||
storage.splitOnWords ??= false;
|
||||
|
||||
const Constants = findByProps("MAX_MESSAGE_LENGTH");
|
||||
const MaxLengthModule = findByProps("getMaxMessageLength");
|
||||
const MessageActions = findByProps("sendMessage", "editMessage");
|
||||
const UserStore = findByStoreName("UserStore");
|
||||
const ChannelStore = findByStoreName("ChannelStore");
|
||||
|
||||
Constants.MAX_MESSAGE_LENGTH = 2 ** 30;
|
||||
Constants.MAX_MESSAGE_LENGTH_PREMIUM = 2 ** 30;
|
||||
unpatchMaxLength = instead("getMaxMessageLength", MaxLengthModule, () => 2 ** 30);
|
||||
|
||||
unpatch = before("sendMessage", MessageActions, (args: any[]) => {
|
||||
unpatchSend = before("sendMessage", MessageActions, (args: any[]) => {
|
||||
const [channelId, message] = args;
|
||||
const content: string = message?.content ?? "";
|
||||
const maxLength = UserStore.getCurrentUser()?.premiumType === 2 ? 4000 : 2000;
|
||||
|
|
@ -60,10 +60,8 @@ export default {
|
|||
});
|
||||
},
|
||||
onUnload() {
|
||||
unpatch?.();
|
||||
const Constants = findByProps("MAX_MESSAGE_LENGTH");
|
||||
Constants.MAX_MESSAGE_LENGTH = 2000;
|
||||
Constants.MAX_MESSAGE_LENGTH_PREMIUM = 4000;
|
||||
unpatchMaxLength?.();
|
||||
unpatchSend?.();
|
||||
},
|
||||
settings: Settings,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue