/* eslint-disable simple-header/header */ /* eslint-disable indent */ /* * Vencord, a modification for Discord's desktop app * Copyright (c) 2023 your mom lol * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import { addButton, removeButton } from "@api/MessagePopover"; import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import { classes } from "@utils/misc"; import definePlugin, { OptionType } from "@utils/types"; import { ChannelStore, EmojiStore, RestAPI } from "@webpack/common"; import type { SVGProps } from "react"; // eslint-disable-next-line no-duplicate-imports import { PropsWithChildren } from "react"; interface BaseIconProps extends IconProps { viewBox: string; } interface IconProps extends SVGProps { className?: string; height?: string | number; width?: string | number; } function Icon({ height = 24, width = 24, className, children, viewBox, ...svgProps }: PropsWithChildren) { return ( {children} ); } export function Husk(props: IconProps) { return ( ); } export default definePlugin({ name: "Husk", description: "Adds Husk button (check settings to change used emoji)", authors: [Devs.nin0dev], dependencies: ["MessagePopoverAPI"], settings: definePluginSettings({ findInServer: { description: "Attempt to find emoji of same name in server before using ID in settings (useful if no nitro)", type: OptionType.BOOLEAN, default: true }, emojiName: { description: "Emoji name (default (from Vencord Server): husk)", type: OptionType.STRING, default: "husk" }, emojiID: { description: "Emoji ID (default (from Vencord Server): 1026532993923293184)", type: OptionType.BIGINT, default: 1026532993923293184n } }), getEmojiIdThatShouldBeUsed(guildId: string) { if (!this.settings.store.findInServer || guildId === "") return this.settings.store.emojiID; let id = ""; EmojiStore.getGuildEmoji(guildId).forEach(emoji => { if (emoji.name === this.settings.store.emojiName) { id = emoji.id; } }); return id !== "" ? id : this.settings.store.emojiID; }, async start() { addButton("Husk", msg => { return { label: "Husk", icon: Husk, message: msg, channel: ChannelStore.getChannel(msg.channel_id), onClick: () => { const guildId = ChannelStore.getChannel(msg.channel_id).guild_id !== null ? ChannelStore.getChannel(msg.channel_id).guild_id : ""; RestAPI.put({ url: `/channels/${msg.channel_id}/messages/${msg.id}/reactions/${this.settings.store.emojiName}:${this.getEmojiIdThatShouldBeUsed(guildId)}/@me` } ); } }; }); }, stop() { removeButton("Husk"); }, });