me when im at school and bored and decide to keep on making improvements :trolley:

This commit is contained in:
byron 2024-03-13 11:03:52 -04:00 committed by GitHub
parent 1c3e33dbbd
commit 2f1c10de3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 14 deletions

View file

@ -68,7 +68,7 @@ export default definePlugin({
}
],
execute: async (option, ctx) => {
var webhookUrl = findOption(option, "url");
let webhookUrl = findOption(option, "url");
await fetch("" + webhookUrl).then(response => response.json())
.then(response => {
console.log(JSON.stringify(response));
@ -105,28 +105,40 @@ export default definePlugin({
description: "The message you want to send.",
type: ApplicationCommandOptionType.STRING,
required: true
}
/*
},
{
name: "username",
description: "Give the webhook a custom name (Leave blank for default).",
type: ApplicationCommandOptionType.STRING,
required: true
required: false
},
{
name: "rawjson",
description: "Send as a raw JSON",
type: ApplicationCommandOptionType.BOOLEAN,
required: false
}
*/
],
execute: async (option, ctx) => {
var webhookUrl = findOption(option, "url");
var webhookMessage = findOption(option, "message");
// var webhookUsername = findOption(option, "username");
let webhookUrl = findOption(option, "url");
let webhookMessage = findOption(option, "message");
let webhookUsername = findOption(option, "username");
if (findOption(option, "rawjson")) {
Native.executeWebhook("" + webhookUrl, {
webhookMessage // doubt it will work but it might, might clash with other options such as the username, but once i'm home i'll continue testing.
});
}
else {
Native.executeWebhook("" + webhookUrl, {
content: webhookMessage,
username: webhookUsername ?? fetch("" + webhookUrl).then(response => response.json()), // still may have issues, supposed to go to webhook name if a custom name is not set, ?? should be the right operator
avatar_url: ""
});
}
Native.executeWebhook("" + webhookUrl, {
content: webhookMessage,
username: fetch("" + webhookUrl).then(response => response.json()), // yea might have issues, sleepy brain as well, will fix tmr
avatar_url: ""
});
sendBotMessage(ctx.channel.id, {
content: "Message sent successfully."

View file

@ -27,4 +27,4 @@ export function executeWebhook(_, url: string, body: object) {
});
req.write(JSON.stringify(body));
req.end();
}
}