Added local emoji use
This commit is contained in:
parent
0419f102f8
commit
8cd85569e1
1 changed files with 22 additions and 9 deletions
31
index.tsx
31
index.tsx
|
@ -20,9 +20,10 @@
|
||||||
|
|
||||||
import { addButton, removeButton } from "@api/MessagePopover";
|
import { addButton, removeButton } from "@api/MessagePopover";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { ChannelStore, RestAPI } from "@webpack/common";
|
import { ChannelStore, EmojiStore, RestAPI } from "@webpack/common";
|
||||||
import type { SVGProps } from "react";
|
import type { SVGProps } from "react";
|
||||||
// eslint-disable-next-line no-duplicate-imports
|
// eslint-disable-next-line no-duplicate-imports
|
||||||
import { PropsWithChildren } from "react";
|
import { PropsWithChildren } from "react";
|
||||||
|
@ -72,24 +73,35 @@ export function Husk(props: IconProps) {
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "Husk",
|
name: "Husk",
|
||||||
description: "Adds Husk button (check settings to change used emoji)",
|
description: "Adds Husk button (check settings to change used emoji)",
|
||||||
authors: [{
|
authors: [Devs.nin0dev],
|
||||||
name: "nina",
|
|
||||||
id: 886685857560539176n
|
|
||||||
}],
|
|
||||||
dependencies: ["MessagePopoverAPI"],
|
dependencies: ["MessagePopoverAPI"],
|
||||||
settings: definePluginSettings({
|
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: {
|
emojiName: {
|
||||||
description: "Default (from Vencord Server): husk",
|
description: "Emoji name (default (from Vencord Server): husk)",
|
||||||
type: OptionType.STRING,
|
type: OptionType.STRING,
|
||||||
default: "husk"
|
default: "husk"
|
||||||
},
|
},
|
||||||
emojiID: {
|
emojiID: {
|
||||||
description: "Default (from Vencord Server): 1026532993923293184",
|
description: "Emoji ID (default (from Vencord Server): 1026532993923293184)",
|
||||||
type: OptionType.BIGINT,
|
type: OptionType.BIGINT,
|
||||||
default: 1026532993923293184n
|
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() {
|
async start() {
|
||||||
addButton("Husk", msg => {
|
addButton("Husk", msg => {
|
||||||
return {
|
return {
|
||||||
|
@ -98,8 +110,9 @@ export default definePlugin({
|
||||||
message: msg,
|
message: msg,
|
||||||
channel: ChannelStore.getChannel(msg.channel_id),
|
channel: ChannelStore.getChannel(msg.channel_id),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
|
const guildId = ChannelStore.getChannel(msg.channel_id).guild_id !== null ? ChannelStore.getChannel(msg.channel_id).guild_id : "";
|
||||||
RestAPI.put({
|
RestAPI.put({
|
||||||
url: `/channels/${msg.channel_id}/messages/${msg.id}/reactions/${this.settings.store.emojiName}:${this.settings.store.emojiID}/@me`
|
url: `/channels/${msg.channel_id}/messages/${msg.id}/reactions/${this.settings.store.emojiName}:${this.getEmojiIdThatShouldBeUsed(guildId)}/@me`
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue