Added 'Creator Username' section for webhookinfo and adding text to speech on sending webhook message

This commit is contained in:
byron 2024-03-12 10:24:23 -04:00 committed by GitHub
parent 0207b9fa12
commit 369f66e810
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,7 +7,6 @@ import { ApplicationCommandInputType, ApplicationCommandOptionType, sendBotMessa
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { RestAPI } from "@webpack/common"; import { RestAPI } from "@webpack/common";
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.",
@ -28,6 +27,8 @@ export default definePlugin({
} }
], ],
execute: async (option, ctx) => { execute: async (option, ctx) => {
// const res = await REST.delete(findOption(option, "url"));
try { try {
await RestAPI.delete({ await RestAPI.delete({
url: "" + findOption(option, "url") url: "" + findOption(option, "url")
@ -71,7 +72,8 @@ export default definePlugin({
"Webhook Type: " + response.type + "\n \n" + "Webhook Type: " + response.type + "\n \n" +
"# Webhook Creator Information: \n " + "# Webhook Creator Information: \n " +
"Creator UserID: " + response.user.id + "\n" + "Creator UserID: " + response.user.id + "\n " +
"Creator Username: " + response.user.name + "\n " +
"Creator Profile: [Click Me](https://img.discord.dog/" + response.user.id + ") \n" "Creator Profile: [Click Me](https://img.discord.dog/" + response.user.id + ") \n"
}); });
}); });
@ -102,26 +104,24 @@ export default definePlugin({
} }
], ],
execute: async (option, ctx) => { execute: async (option, ctx) => {
// discord seems to have updated their webhook api, sending messages has changed, will work on soon // discord seems to have updated their webhook api, sending messages has changed
const request = new XMLHttpRequest(); const request = new XMLHttpRequest();
request.open("POST", "" + findOption(option, "url")); request.open("POST", "" + findOption(option, "url"));
request.setRequestHeader('Content-type', 'application/json'); request.setRequestHeader('Content-type', 'application/json');
request.setRequestHeader('Accept', 'application/json');
const headers: Record<string, string> = { request.setRequestHeader('Accept-Language', 'en');
"Accept": "application/json",
"Accept-Language": "en",
};
const params = { const params = {
content: "" + findOption(option, "message"), content: "" + findOption(option, "message"),
tts: "" + findOption(option, "tts") tts: "" + findOption(option, "tts") ?? false
}; };
request.send(JSON.stringify(params)); request.send(JSON.stringify(params));
sendBotMessage(ctx.channel.id, { sendBotMessage(ctx.channel.id, {
content: "Message sent successfully!" content: "Message sent. Check console for an advanced output."
}); });
console.log(params);
console.log(JSON.stringify(request));
} }
} }
] ]