make it releaseable
This commit is contained in:
parent
36ba3c49cc
commit
a63352375f
1 changed files with 41 additions and 5 deletions
46
index.ts
46
index.ts
|
@ -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 definePlugin, { PluginNative } from "@utils/types";
|
||||
import definePlugin, { OptionType, PluginNative } from "@utils/types";
|
||||
|
||||
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({
|
||||
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],
|
||||
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() {
|
||||
addPreSendListener(async (c, msg) => {
|
||||
msg.content += `\n\nSent from my ${await Native.getUname()}`;
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue