Could simplify this to one variable instead

This commit is contained in:
byron 2024-03-15 21:00:40 -04:00
parent 9c7c3d0c5d
commit 8a09cb533b

View file

@ -13,7 +13,6 @@ import { RestAPI } from "@webpack/common";
const Native = VencordNative.pluginHelpers.WebhookManager as PluginNative<typeof import("./native")>; const Native = VencordNative.pluginHelpers.WebhookManager as PluginNative<typeof import("./native")>;
const WMLogger = new Logger("WebhookManager"); const WMLogger = new Logger("WebhookManager");
let sourceGuildGet; let sourceGuildGet;
let sourceChannelGet;
export default definePlugin({ export default definePlugin({
name: "WebhookManager", name: "WebhookManager",
description: "Manage your webhooks easily; delete, send messages, get detailed info and more.", description: "Manage your webhooks easily; delete, send messages, get detailed info and more.",
@ -74,20 +73,16 @@ export default definePlugin({
.then(response => { .then(response => {
WMLogger.info(JSON.stringify(response)); WMLogger.info(JSON.stringify(response));
if (response.type === 2) { if (response.type === 2) {
const sourceGuild = ` const sourceWebhook = `
Source Server ID: ${response.source_guild.id} Source Server ID: ${response.source_guild.id}
Source Server Name: ${response.source_guild.name} Source Server Name: ${response.source_guild.name}
`;
sourceGuildGet = sourceGuild;
const sourceChannel = `
Source Channel ID: ${response.source_channel.id} Source Channel ID: ${response.source_channel.id}
Source Channel Name: ${response.source_channel.name} Source Channel Name: ${response.source_channel.name}
`; `;
sourceChannelGet = sourceChannel; sourceGuildGet = sourceWebhook;
} }
else { else {
sourceGuildGet = ""; sourceGuildGet = "";
sourceChannelGet = "";
} }
sendBotMessage(ctx.channel.id, { sendBotMessage(ctx.channel.id, {
content: `This webhook was created by <@${response.user.id}>.`, content: `This webhook was created by <@${response.user.id}>.`,
@ -110,7 +105,6 @@ export default definePlugin({
Channel ID: ${response.channel_id} Channel ID: ${response.channel_id}
Server ID: ${response.guild_id} Server ID: ${response.guild_id}
${sourceGuildGet} ${sourceGuildGet}
${sourceChannelGet}
Creator UserID: ${response.user.id}` Creator UserID: ${response.user.id}`
}] }]
@ -173,6 +167,7 @@ export default definePlugin({
avatar_url: "", avatar_url: "",
tts: findOption(option, "tts") tts: findOption(option, "tts")
}); });
} }
sendBotMessage(ctx.channel.id, { sendBotMessage(ctx.channel.id, {
content: "Message sent successfully." content: "Message sent successfully."