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) => { execute: async (option, ctx) => {
var webhookUrl = findOption(option, "url"); let webhookUrl = findOption(option, "url");
await fetch("" + webhookUrl).then(response => response.json()) await fetch("" + webhookUrl).then(response => response.json())
.then(response => { .then(response => {
console.log(JSON.stringify(response)); console.log(JSON.stringify(response));
@ -105,28 +105,40 @@ 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: "username", name: "username",
description: "Give the webhook a custom name (Leave blank for default).", description: "Give the webhook a custom name (Leave blank for default).",
type: ApplicationCommandOptionType.STRING, type: ApplicationCommandOptionType.STRING,
required: true required: false
},
{
name: "rawjson",
description: "Send as a raw JSON",
type: ApplicationCommandOptionType.BOOLEAN,
required: false
} }
*/
], ],
execute: async (option, ctx) => { execute: async (option, ctx) => {
var webhookUrl = findOption(option, "url"); let webhookUrl = findOption(option, "url");
var webhookMessage = findOption(option, "message"); let webhookMessage = findOption(option, "message");
// var webhookUsername = findOption(option, "username"); 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, { Native.executeWebhook("" + webhookUrl, {
content: webhookMessage, content: webhookMessage,
username: fetch("" + webhookUrl).then(response => response.json()), // yea might have issues, sleepy brain as well, will fix tmr 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: "" avatar_url: ""
}); });
}
sendBotMessage(ctx.channel.id, { sendBotMessage(ctx.channel.id, {
content: "Message sent successfully." content: "Message sent successfully."