Skip to content

Commit

Permalink
yet another wip upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico040 committed Jun 6, 2024
1 parent 894c6a5 commit faf6cd8
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 0 deletions.
18 changes: 18 additions & 0 deletions plugins/action-sheet-finder/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "ActionSheetFinder",
"description": "Port of Enmity plugin.",
"authors": [
{
"name": "Rico040",
"id": "619474349845643275"
},
{
"name": "byeoon",
"id": "1167275288036655133"
}
],
"main": "src/index.tsx",
"vendetta": {
"icon": "ic_search"
}
}
24 changes: 24 additions & 0 deletions plugins/action-sheet-finder/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { showToast } from "@vendetta/ui/toasts"
import { before } from '@vendetta/patcher';
import { getAssetIDByName } from '@vendetta/ui/assets';
import { findByProps } from "@vendetta/metro";

const LazyActionSheet = findByProps("openLazy", "hideActionSheet");
let unpatchOpenLazy: () => boolean;

function SheetOutput(text) {
console.log("[ActionSheetFinder] Found ActionSheet: " + text);
showToast("[ActionSheetFinder] Found ActionSheet: " + text, getAssetIDByName("Check"))
}


export default {
onLoad() {
console.log("[ActionSheetFinder] Hello world!")
unpatchOpenLazy = before('openLazy', LazyActionSheet, ([key]) => {
console.log(this)
return SheetOutput(key);
});
},
onUnload: unpatchOpenLazy
};
14 changes: 14 additions & 0 deletions plugins/sticker-utils/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "StickerUtils",
"description": "i love discord!",
"authors": [
{
"name": "sapphire",
"id": "757982547861962752"
}
],
"main": "src/index.tsx",
"vendetta": {
"icon": "ic_sticker_24px"
}
}
89 changes: 89 additions & 0 deletions plugins/sticker-utils/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { before } from "@vendetta/patcher"
import { find, findByProps, findByStoreName } from "@vendetta/metro"
import { findInReactTree } from "@vendetta/utils"
import { Button } from "@vendetta/ui/components"
import { showToast } from "@vendetta/ui/toasts"
import { getAssetIDByName } from "@vendetta/ui/assets"
import { clipboard } from "@vendetta/metro/common"

type Sticker = {
id: string
name: string
tags: string
type: number
format_type: number
description: string
asset: string
available: boolean
guild_id: string
}

const GuildStore = findByStoreName("GuildStore")
const UserSettingsProtoStore = findByStoreName("UserSettingsProtoStore")
const ActionSheet = findByProps("ActionSheet")?.ActionSheet ?? find(m => m?.render?.name === "ActionSheet")
const { hideActionSheet } = findByProps("hideActionSheet")
const { downloadMediaAsset } = findByProps("downloadMediaAsset")
const StickerUtils = findByProps("favoriteSticker", "unfavoriteSticker")

const style = { marginBottom: 10 }

const unpatch = before("render", ActionSheet, ([props]) => {
const guh = findInReactTree(props, x => Array.isArray(x?.children))
const sticker = findInReactTree(props, x => typeof x?.sticker === "object" && x?.sticker?.hasOwnProperty("guild_id"))?.sticker as Sticker
const favoritedStickers = UserSettingsProtoStore.frecencyWithoutFetchingLatest?.favoriteStickers?.stickerIds as Array<string>
if (!guh || !sticker) return
const isFavorited = !!favoritedStickers?.find((s: string) => s === sticker.id)
const stickerUrl = `https://discord.com/stickers/${sticker.id}.png`
// replaces HUGE get nitro button, wow!
guh.children[1] = <>
{ Object.values(GuildStore.getGuilds()).find((x: any) => x.id === sticker.guild_id) &&
<Button
text={isFavorited ? "Remove from Favorites" : "Add to Favorites"}
color={isFavorited ? "red" : "brand"}
style={style}
size="small"
onPress={() => {
isFavorited ? StickerUtils.unfavoriteSticker(sticker.id) : StickerUtils.favoriteSticker(sticker.id)
// temp, idk how to make dynamically
hideActionSheet()
return showToast(isFavorited ? "Removed from Favorites" : "Added to Favorites", getAssetIDByName("Check"))
}}
/>
}
<Button
text="Copy ID to clipboard"
color="brand"
size="small"
style={style}
onPress={() => {
clipboard.setString(sticker.id)
hideActionSheet()
return showToast(`Copied ${sticker.name}'s ID to clipboard`, getAssetIDByName("ic_copy_message_link"))
}}
/>
<Button
text="Copy URL to clipboard"
color="brand"
size="small"
style={style}
onPress={() => {
clipboard.setString(stickerUrl)
hideActionSheet()
return showToast(`Copied ${sticker.name}'s URL to clipboard`, getAssetIDByName("ic_copy_message_link"))
}}
/>
<Button
text="Save image"
color="brand"
size="small"
style={style}
onPress={() => {
downloadMediaAsset(stickerUrl, 0)
hideActionSheet()
return showToast(`Saved ${sticker.name}'s image`, getAssetIDByName("toast_image_saved"))
}}
/>
</>
})

export const onUnload = () => unpatch()

0 comments on commit faf6cd8

Please sign in to comment.