Compare commits

..

1 commit
main ... main

Author SHA1 Message Date
1231b1b5a4 massive improvement 2024-12-29 11:57:25 -05:00

View file

@ -1,3 +1,4 @@
import { addPreSendListener, removePreSendListener } from "@api/MessageEvents";
import { definePluginSettings, Settings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType, PluginNative } from "@utils/types";
@ -5,6 +6,10 @@ import definePlugin, { OptionType, PluginNative } from "@utils/types";
export const Native = VencordNative.pluginHelpers.SentFromMyUname as PluginNative<typeof import("./native")>;
async function getWhateverShouldBeSentFromMy() {
if (Settings.plugins.SentFromMyUname.signatureToUse === "iPhone") {
return "iPhone";
}
if ((IS_DISCORD_DESKTOP || IS_VESKTOP) && Settings.plugins.SentFromMyUname.signatureToUse === "uname") {
try {
return await Native.getUname();
@ -30,6 +35,9 @@ export default definePlugin({
}, {
label: "Always use useragent",
value: "useragent"
}, {
label: "Sent from my iPhone",
value: "iPhone"
}],
default: "uname"
},
@ -38,9 +46,14 @@ export default definePlugin({
type: OptionType.STRING
}
}),
onBeforeMessageSend: async (c, msg) => {
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()}`;
start() {
this.preSend = addPreSendListener(async (c, msg) => {
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);
}
});