Skip to content

Commit

Permalink
Freemoji: nitro check and explicit toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico040 committed May 21, 2024
1 parent 5b7ab53 commit ea2574a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions plugins/freemoji/src/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ export default () => {
onValueChange={ () => {storage.hyperlink = !storage.hyperlink;}}
note=""
/>
<FormSwitchRow
label="Force Freemoji"
subLabel="Explicitly force Freemoji even if you have nitro (useful for testing)"
leading={<Forms.FormIcon source={getAssetIDByName("img_nitro_emojis")} />}
value={storage.forceMoji}
onValueChange={ () => {storage.forceMoji = !storage.forceMoji;}}
note=""
/>
</FormSection>
<FormSection title="Emoji Size" >
{Object.entries(sizeOptions).map(([name, size]) => <FormRadioRow
Expand Down
3 changes: 3 additions & 0 deletions plugins/freemoji/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { storage } from "@vendetta/plugin";
import { findByStoreName } from "@vendetta/metro";
import nitroChecks from "./patches/nitroChecks";
import sendMessage from "./patches/sendMessage";

// Default settings
storage.emojiSize ??= 48;
storage.hyperlink ??= true;
storage.haveNitro ??= findByStoreName("UserStore").getCurrentUser()?.purchasedFlags != 0;
storage.forceMoji ??= false;

// Migration code, used to be string containing a number but is now just a number
if (typeof storage.emojiSize === "string") storage.emojiSize = parseInt(storage.emojiSize);
Expand Down
2 changes: 1 addition & 1 deletion plugins/freemoji/src/msgProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function extractUnusableEmojis(messageString: string, size: number) {
}

export default function modifyIfNeeded(msg: Message) {
if (!msg.content.match(hasEmotesRegex)) return;
if (!msg.content.match(hasEmotesRegex) && (!storage.haveNitro || !storage.forceMoji)) return;

// Find all emojis from the captured message string and return object with emojiURLS and content
const { newContent, extractedEmojis } = extractUnusableEmojis(msg.content, storage.emojiSize);
Expand Down

0 comments on commit ea2574a

Please sign in to comment.