fix embed color not being blue, fix webhook profile picture not appearing, fix deleting webhooks not working, general code and QoL improvements

This commit is contained in:
byron 2024-05-01 18:02:14 -04:00
parent 6d704d603e
commit 28f70e2942
2 changed files with 11 additions and 24 deletions

View file

@ -8,7 +8,6 @@ import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption,
import { Devs } from "@utils/constants";
import { Logger } from "@utils/Logger";
import definePlugin, { PluginNative } from "@utils/types";
import { RestAPI } from "@webpack/common";
const Native = VencordNative.pluginHelpers.WebhookManager as PluginNative<typeof import("./native")>;
const WMLogger = new Logger("WebhookManager");
@ -32,18 +31,8 @@ export default definePlugin({
}
],
execute: async (option, ctx) => {
const res = await RestAPI.delete({ url: "" + findOption(option, "url") });
try {
if (res.ok) {
sendBotMessage(ctx.channel.id, {
content: "Webhook deleted successfully."
});
}
else {
sendBotMessage(ctx.channel.id, {
content: "There was an error with deleting the webhook, Error: " + res.status
});
}
await fetch("" + findOption(option, "url"), { method: 'DELETE' }).then(() => sendBotMessage(ctx.channel.id, { content: "The webhook has deleted successfully." }));
}
catch (error) {
sendBotMessage(ctx.channel.id, {
@ -70,18 +59,22 @@ export default definePlugin({
.then(response => {
WMLogger.info(JSON.stringify(response));
sendBotMessage(ctx.channel.id, {
content: `This webhook was created by <@${response.user.id}>.`,
content: `This webhook was created by ${response.user?.name}.`,
embeds: [
{
// @ts-ignore
title: "Webhook Information",
color: "#00007d",
color: "1323",
//@ts-ignore
author: {
// @ts-ignore
icon_url: `https://cdn.discordapp.com/avatars/${response.id}/${response.avatar}.png`,
name: response.name,
url: ""
},
thumbnail: {
url: `https://cdn.discordapp.com/avatars/${response.id}/${response.avatar}.png`,
proxyURL: `https://cdn.discordapp.com/avatars/${response.id}/${response.avatar}.png`,
height: 128,
width: 128
},
description: `
Webhook ID: ${response.id}
Webhook Token: ${response.token}

View file

@ -13,13 +13,7 @@ export function executeWebhook(_, url: string, body: object) {
throw new Error("This URL is not a valid webhook.");
}
const req = https.request(url,
{
method: "POST",
headers: {
"Content-Type": "application/json",
}
});
const req = https.request(url, { method: "POST", headers: { "Content-Type": "application/json", } });
req.write(JSON.stringify(body));
req.end();
}