mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-20 06:30:35 +00:00
Plugin now crashes, but im pushing to see if i accidnetally messed with another file
This commit is contained in:
parent
ba0a9d0696
commit
278c4f0d60
2 changed files with 38 additions and 21 deletions
|
@ -2,11 +2,16 @@
|
||||||
Vencord is very swag
|
Vencord is very swag
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin, { PluginNative } from "@utils/types";
|
||||||
import { ApplicationCommandInputType, ApplicationCommandOptionType, sendBotMessage, findOption } from "@api/Commands";
|
import { ApplicationCommandInputType, ApplicationCommandOptionType, sendBotMessage, findOption } from "@api/Commands";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { RestAPI } from "@webpack/common";
|
import { RestAPI } from "@webpack/common";
|
||||||
|
|
||||||
|
export let webhookDefaultName;
|
||||||
|
export let webhookUrlGLOBAL;
|
||||||
|
export let webhookMessageGLOBAL;
|
||||||
|
const Native = VencordNative.pluginHelpers.WebhookManager as PluginNative<typeof import("./native")>;
|
||||||
|
|
||||||
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.",
|
||||||
|
@ -99,33 +104,28 @@ export default definePlugin({
|
||||||
description: "The message you want to send.",
|
description: "The message you want to send.",
|
||||||
type: ApplicationCommandOptionType.STRING,
|
type: ApplicationCommandOptionType.STRING,
|
||||||
required: true
|
required: true
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "tts",
|
|
||||||
description: "Send message with TTS?",
|
|
||||||
type: ApplicationCommandOptionType.BOOLEAN,
|
|
||||||
required: false
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
execute: async (option, ctx) => {
|
execute: async (option, ctx) => {
|
||||||
// discord seems to have updated their webhook api, sending messages has changed
|
|
||||||
const request = new XMLHttpRequest();
|
|
||||||
request.open("POST", "" + findOption(option, "url"));
|
|
||||||
request.setRequestHeader('Content-type', 'application/json');
|
|
||||||
request.setRequestHeader('Accept', 'application/json');
|
|
||||||
request.setRequestHeader('Accept-Language', 'en');
|
|
||||||
|
|
||||||
const params = {
|
var webhookUrl = findOption(option, "url");
|
||||||
content: "" + findOption(option, "message"),
|
var webhookMessage = findOption(option, "message");
|
||||||
tts: "" + findOption(option, "tts") ?? false
|
webhookUrlGLOBAL = webhookUrl;
|
||||||
};
|
webhookMessageGLOBAL = webhookMessage;
|
||||||
|
await fetch("" + webhookUrl).then(response => response.json())
|
||||||
request.send(JSON.stringify(params));
|
.then(response => {
|
||||||
sendBotMessage(ctx.channel.id, {
|
webhookDefaultName = response.name;
|
||||||
content: "Message sent. Check console for an advanced output."
|
|
||||||
});
|
});
|
||||||
console.log(params);
|
|
||||||
console.log(JSON.stringify(request));
|
Native.doSomething();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sendBotMessage(ctx.channel.id, {
|
||||||
|
content: "Message sent.?"
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
17
src/plugins/WebhookManager/native.ts
Normal file
17
src/plugins/WebhookManager/native.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import { webhookDefaultName, webhookMessageGLOBAL, webhookUrlGLOBAL } from ".";
|
||||||
|
const https = require('https');
|
||||||
|
|
||||||
|
|
||||||
|
export function doSomething() {
|
||||||
|
const request = new XMLHttpRequest();
|
||||||
|
request.open("POST", "" + webhookUrlGLOBAL);
|
||||||
|
request.setRequestHeader('Content-type', 'application/json');
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
content: webhookMessageGLOBAL,
|
||||||
|
username: webhookDefaultName ?? "User",
|
||||||
|
avatar_url: ""
|
||||||
|
};
|
||||||
|
request.send(JSON.stringify(params));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue