make it releaseable

This commit is contained in:
nin0dev 2024-12-29 09:19:32 -05:00
parent 36ba3c49cc
commit a63352375f
Signed by: nin0
SSH key fingerprint: SHA256:Is2DvJdw1OkSopR4wKJfdWV0fZhMLxpnCs1P1nPhIgA

View file

@ -1,16 +1,52 @@
import { addPreSendListener } from "@api/MessageEvents"; import { addPreSendListener, removePreSendListener } from "@api/MessageEvents";
import { definePluginSettings, Settings } from "@api/Settings";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin, { PluginNative } from "@utils/types"; import definePlugin, { OptionType, PluginNative } from "@utils/types";
export const Native = VencordNative.pluginHelpers.SentFromMyUname as PluginNative<typeof import("./native")>; export const Native = VencordNative.pluginHelpers.SentFromMyUname as PluginNative<typeof import("./native")>;
async function getWhateverShouldBeSentFromMy() {
if ((IS_DISCORD_DESKTOP || IS_VESKTOP) && Settings.plugins.SentFromMyUname.signatureToUse === "uname") {
try {
return await Native.getUname();
}
catch {
return navigator.userAgent;
}
}
else return navigator.userAgent;
}
export default definePlugin({ export default definePlugin({
name: "SentFromMyUname", name: "SentFromMyUname",
description: "Add your uname to every single message you send", description: "Add your uname/useragent to every single message you send",
authors: [Devs.nin0dev], authors: [Devs.nin0dev],
settings: definePluginSettings({
signatureToUse: {
description: "What to show after 'Sent from my'",
type: OptionType.SELECT,
options: [{
label: "Attempt to use uname, useragent if can't use uname",
value: "uname"
}, {
label: "Always use useragent",
value: "useragent"
}],
default: "uname"
},
channelWhitelist: {
description: "If set, only use plugin in this comma-separated channel whitelist",
type: OptionType.STRING
}
}),
start() { start() {
addPreSendListener(async (c, msg) => { this.preSend = addPreSendListener(async (c, msg) => {
msg.content += `\n\nSent from my ${await Native.getUname()}`; if (Settings.plugins.SentFromMyUname.channelWhitelist && !Settings.plugins.SentFromMyUname.channelWhitelist.includes(c)) return;
if (msg.content.startsWith("nouname ")) { msg.content = msg.content.replace("nouname ", ""); return; }
msg.content += `\n\nSent from my ${await getWhateverShouldBeSentFromMy()}`;
}); });
},
stop() {
removePreSendListener(this.preSend);
} }
}); });