Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin) WebhookManager #2256

Open
wants to merge 145 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
ccce495
create plugin, haven't tested yet but will soon
byeoon Mar 11, 2024
bde85e0
added second command, also added to devs for simplicity not sure if i…
byeoon Mar 11, 2024
ff6f24b
Fixed bugs with plugin, on pc now & i use other plugins so i put it i…
byeoon Mar 11, 2024
2c20a85
Webhook info works, deleting also works, sending is still a WIP.
byeoon Mar 12, 2024
0207b9f
[style]fix missing line
byeoon Mar 12, 2024
369f66e
Added 'Creator Username' section for webhookinfo and adding text to s…
byeoon Mar 12, 2024
3dd65d5
/webhookinfo has the ability to get a pingable version of the creator…
byeoon Mar 12, 2024
87e8627
Forgot to add error to console, removed dumb note I added in badge thing
byeoon Mar 12, 2024
f41c6f4
Learned that I'm supposed to actually put the plugins in /plugins and…
byeoon Mar 12, 2024
ba0a9d0
Fixed issues with plugin not loading, and fixed bugs
byeoon Mar 12, 2024
278c4f0
Plugin now crashes, but im pushing to see if i accidnetally messed wi…
byeoon Mar 12, 2024
4f68631
Finally did it, fixed the sending bug
byeoon Mar 13, 2024
cedf10b
removed personal plugin i use before pull request (its in .gitignore …
byeoon Mar 13, 2024
d02a241
(also fixed small bug where creator username would be undefined)
byeoon Mar 13, 2024
284a951
Discard changes to .gitignore
Vendicated Mar 13, 2024
4ea2d1c
Fixed a ton of things, thank you suggestions and code reviews
byeoon Mar 13, 2024
9060352
re-discarded changes to .gitignore (sorry)
byeoon Mar 13, 2024
1c3e33d
Logger for error handling instead of console.log
byeoon Mar 13, 2024
2f1c10d
me when im at school and bored and decide to keep on making improveme…
byeoon Mar 13, 2024
f2b22bc
Removed notes, fully moved logging to Logger, fixed everything back t…
byeoon Mar 13, 2024
0fd7a59
literal string for webhookinfo, also inside of an embed, better way t…
byeoon Mar 13, 2024
4cb2661
Also fixed the commands to be better
byeoon Mar 13, 2024
a6c7cb9
Also added the ability to send webhooks with TTS (For the sillies and…
byeoon Mar 13, 2024
6df510d
Added title to embed, fixed accidental leftover symbols
byeoon Mar 13, 2024
9b600b9
*quickly changed some grammar*
byeoon Mar 13, 2024
1225861
Fixed bug that was caused when doing /webhook info, also updated the …
byeoon Mar 13, 2024
9fab414
Added extra information for 'Type 2' Webhooks (Server Following / Ann…
byeoon Mar 13, 2024
2da6a64
Ready for reviews / feedback
byeoon Mar 13, 2024
73a2f55
now* it's ready
byeoon Mar 13, 2024
f43f404
put the pingable text into 'content' and not the embed, also added th…
byeoon Mar 14, 2024
9c7c3d0
fixed that god-awful annoying bug where you couldnt use the default w…
byeoon Mar 15, 2024
8a09cb5
Could simplify this to one variable instead
byeoon Mar 16, 2024
736fef8
removed unneeded / unreachable code, changed 'rawjson' to just 'raw',…
byeoon Mar 16, 2024
610c48f
hope this adds attachment support, if not i may need help
byeoon Mar 16, 2024
1947ced
oops forgot to add back the if statement
byeoon Mar 16, 2024
2ac335c
handle if there is no profile pic option, also making it string only …
byeoon Mar 18, 2024
7c71d9f
added url validation
byeoon Mar 21, 2024
3ec9f7c
test push that hopefully fixes something
byeoon Mar 21, 2024
c2a8671
linting and testing all over the place
byeoon Mar 21, 2024
1a106e7
TEMP DOING THIS JUST TO FIX BRANCH ISSUE
byeoon Mar 22, 2024
1d93a03
revert
byeoon Mar 22, 2024
c542a81
Merge branch 'main' into main
Nuckyz Mar 22, 2024
9edb4c0
test
byeoon Mar 22, 2024
83fedd4
remove empty lines
byeoon Mar 27, 2024
39b3e74
also updating dev label to be on proper account
byeoon Mar 27, 2024
82cc75e
Merge branch 'main' into main
byeoon Mar 28, 2024
04c4c85
Merge branch 'main' into main
byeoon Mar 28, 2024
f87c736
Merge branch 'main' into main
byeoon Mar 28, 2024
0822273
Merge branch 'main' into main
byeoon Mar 29, 2024
e608170
Merge branch 'main' into main
byeoon Mar 30, 2024
b722513
add debug to check sticker output
byeoon Apr 1, 2024
570e41b
bruh moment i should probably change forks
byeoon Apr 1, 2024
2c11a7a
Set the default sticker size to 2048 to prevent downscaling, also, ti…
byeoon Apr 1, 2024
abf48db
(fix)Fixed a bug where EmoteCloner would clone stickers at the lowest…
byeoon Apr 1, 2024
c5d03ba
oopsie idk why i added words there
byeoon Apr 1, 2024
3864708
update to actual highest quality
byeoon Apr 2, 2024
bc64dd4
fixed a bug where external emotes counted towards the limit (twitch)
byeoon Apr 3, 2024
23992bd
fixed an issue where external emotes would count towards the max emot…
byeoon Apr 3, 2024
521647b
merged into above statement
byeoon Apr 3, 2024
e24d5d3
Update src/plugins/emoteCloner/index.tsx
byeoon Apr 3, 2024
522d2fd
lossless
Vendicated Apr 9, 2024
4c466e9
Update index.tsx
Vendicated Apr 9, 2024
6266d03
Merge branch 'dev' into fixEmoteCloneQuality
Vendicated Apr 9, 2024
1dc9872
Instead of logging to console when there's an error, log it to the we…
byeoon Apr 9, 2024
31993c0
oops readme was broken fixed it again
byeoon Apr 9, 2024
8c48731
this shit is confusing me
byeoon Apr 9, 2024
f801ab3
Discard changes to src/plugins/emoteCloner/index.tsx
byeoon Apr 9, 2024
8f0204b
Discard changes to src/utils/constants.ts
byeoon Apr 9, 2024
6022317
Merge pull request #1 from byeoon/fixEmoteCloneQuality
byeoon Apr 9, 2024
2462544
Merge branch 'dev' into main
byeoon Apr 9, 2024
d739675
Merge branch 'dev' into main
byeoon Apr 9, 2024
70ae9ea
Merge branch 'dev' into main
byeoon Apr 9, 2024
b4366bd
small code refactors and changes to text
byeoon Apr 9, 2024
209c64a
Merge branch 'dev' into main
byeoon Apr 9, 2024
73ca8dc
Merge branch 'Vendicated:main' into main
byeoon Apr 17, 2024
6578784
Merge branch 'dev' into main
byeoon Apr 22, 2024
6d704d6
Merge branch 'dev' into main
byeoon May 1, 2024
28f70e2
fix embed color not being blue, fix webhook profile picture not appea…
byeoon May 1, 2024
7f36d85
fixed lint
byeoon May 1, 2024
530e19e
Merge branch 'dev' into main
byeoon May 2, 2024
acf7712
Merge branch 'dev' into main
byeoon May 4, 2024
f04bd8a
useStateFromStores: Document 3rd param and fix JSDoc
Nuckyz May 7, 2024
720aaf6
Merge branch 'dev' into main
byeoon May 7, 2024
13119c0
extra error handling - will add more later
byeoon May 15, 2024
f0483f9
why cant i remove the stores.ts conflict
byeoon May 15, 2024
e9cb2ec
Merge branch 'dev' into main
byeoon May 15, 2024
46e4fc6
oopsie
byeoon May 15, 2024
d29d5e9
revert error change
byeoon May 20, 2024
dec282b
Merge branch 'dev' into main
byeoon May 20, 2024
e04225d
Merge branch 'main' of https://github.com/byeoon/Vencord
byeoon May 20, 2024
c3af902
Merge branch 'dev' into main
byeoon May 21, 2024
de2598a
Merge branch 'dev' into main
byeoon May 24, 2024
c88ac8d
Merge branch 'dev' into main
byeoon May 29, 2024
c8602ef
Fix reporter breaking because of ConsoleShortcuts
Nuckyz May 29, 2024
892de53
Fix extractAndLoadChunks issue with 2 match groups; Improve testing o…
Nuckyz May 30, 2024
9a9c1b0
Reporter: Properly implement reporter build of Vencord; Test more plu…
Nuckyz May 30, 2024
adc6064
Merge branch 'dev' into main
byeoon May 30, 2024
8d2fa0e
Merge branch 'dev' into main
byeoon May 31, 2024
249ea30
holy shit since when coild READMEs look this good
byeoon Jun 6, 2024
2728102
Merge branch 'dev' into main
byeoon Jun 6, 2024
0df09f2
blep small fix
byeoon Jun 6, 2024
0d4ec94
Merge branch 'dev' into main
byeoon Jun 6, 2024
9ee1b5b
Update src/plugins/WebhookManager/index.tsx
byeoon Jun 7, 2024
d7036c5
shorter lines
byeoon Jun 7, 2024
422c18c
Merge branch 'dev' into main
byeoon Jun 7, 2024
cafe4b1
fix folder name
Vendicated Jun 8, 2024
e764018
Merge branch 'dev' into main
byeoon Jun 8, 2024
b3a9d33
clean up
Vendicated Jun 8, 2024
61eacb2
fix folder name part 2
Vendicated Jun 8, 2024
ae10dea
fix
Vendicated Jun 8, 2024
7a1a9d2
Merge branch 'dev' into main
byeoon Jun 8, 2024
b63becf
Merge branch 'dev' into main
byeoon Jun 8, 2024
6c19f52
Merge branch 'dev' into main
byeoon Jun 8, 2024
bc3093a
removed tts thing because i think most people have tts muted anyways …
byeoon Jun 8, 2024
dcb9402
Merge branch 'main' of https://github.com/byeoon/Vencord
byeoon Jun 8, 2024
90c9dd2
change name in constants
byeoon Jun 8, 2024
070b25e
Merge branch 'dev' into main
byeoon Jun 10, 2024
8696ca0
fix: small bug with webhook execution & added vee to devs because the…
byeoon Jun 10, 2024
1da50eb
todo: add modal
byeoon Jun 10, 2024
2721cd3
fix lint breaking
byeoon Jun 10, 2024
fc36186
fix: lint and code error with modal template
byeoon Jun 10, 2024
c0842cb
forgot imports!
byeoon Jun 10, 2024
9ad6e1b
???????
byeoon Jun 10, 2024
56be5eb
i swear to god if this doesnt fix it
byeoon Jun 10, 2024
588a40c
fuck lint.
byeoon Jun 10, 2024
f84220e
feat: modal!! (still wip)
byeoon Jun 10, 2024
5180df7
todo: add finishing touches and fix bugs because webhooks arent sendi…
byeoon Jun 10, 2024
f045554
yay its undefined for some reason
byeoon Jun 10, 2024
c93f694
found switch / checkbox element
byeoon Jun 11, 2024
1de442a
Merge branch 'dev' into main
byeoon Jun 12, 2024
db4c0d1
test
byeoon Jun 12, 2024
e88e3b3
Merge branch 'dev' into main
byeoon Jun 15, 2024
2cd661f
YAY this should work!!
byeoon Jun 22, 2024
5e52a34
hewlp vinneie vnecord no work
byeoon Jun 22, 2024
3b20759
Merge branch 'dev' into main
byeoon Jun 22, 2024
ec4e97b
might fully work now!!
byeoon Jun 22, 2024
0561b38
fix thing no work
byeoon Jun 22, 2024
ae6290a
Merge branch 'dev' into main
byeoon Jul 4, 2024
cb4be3d
wtf lint
byeoon Jul 4, 2024
a3d4c19
Merge branch 'dev' into main
byeoon Jul 10, 2024
187ca43
Merge branch 'dev' into main
byeoon Jul 13, 2024
e7faf33
Merge branch 'dev' into main
byeoon Aug 17, 2024
4f6e980
Merge branch 'dev' into main
byeoon Aug 29, 2024
94710db
Merge branch 'Vendicated:main' into main
byeoon Oct 10, 2024
1a86a61
Merge branch 'dev' into main
byeoon Oct 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ lerna-debug.log*
.pnpm-debug.log*
*.tsbuildinfo

src/userplugins
src/userplugins/
byeoon marked this conversation as resolved.
Show resolved Hide resolved
byeoon marked this conversation as resolved.
Show resolved Hide resolved

ExtensionCache/
settings/
25 changes: 25 additions & 0 deletions src/plugins/WebhookManager/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div align='center'>
<h1> WebhookManager </h1>
Manage your webhooks easily; delete, send messages, get detailed info and more.
</div>
byeoon marked this conversation as resolved.
Show resolved Hide resolved

## Commands
- /sendwebhookmessage - *Sends a message through a webhook.*


- /deletewebhook - *Deletes a webhook.*


- /webhookinfo - *Gets advanced details on the webhook such as the name, profile pic, server and channel ID, and additionally, information on person who created it*
<details><summary>Full /webhookinfo Output</summary>
- Webhook Username <br>
byeoon marked this conversation as resolved.
Show resolved Hide resolved
- Webhook ID<br>
- Webhook Token<br>
- Channel ID<br>
- Server ID<br>
- Webhook Profile Picture<br>
- Webhook Type<br>
- Creator UserID<br>
- Creator Username<br>
- Creator Profile<br>
</details>
146 changes: 146 additions & 0 deletions src/plugins/WebhookManager/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands";
import { Devs } from "@utils/constants";
import definePlugin, { PluginNative } from "@utils/types";
import { RestAPI } from "@webpack/common";

export let webhookDefaultName;
byeoon marked this conversation as resolved.
Show resolved Hide resolved
export let webhookUrlGLOBAL;
export let webhookMessageGLOBAL;
const Native = VencordNative.pluginHelpers.WebhookManager as PluginNative<typeof import("./native")>;

export default definePlugin({
name: "WebhookManager",
description: "Manage your webhooks easily; delete, send messages, get detailed info and more.",
authors: [Devs.Byron],
dependencies: ["CommandsAPI"],

commands: [
byeoon marked this conversation as resolved.
Show resolved Hide resolved
{
name: "deletewebhook",
description: "Delete a webhook.",
inputType: ApplicationCommandInputType.BUILT_IN,
options: [
{
name: "url",
description: "The URL of the webhook.",
type: ApplicationCommandOptionType.STRING,
required: true
}
],
execute: async (option, ctx) => {
const res = await RestAPI.delete({ url: "" + findOption(option, "url") });
try {
if (res.ok === true) {
byeoon marked this conversation as resolved.
Show resolved Hide resolved
sendBotMessage(ctx.channel.id, {
content: "Webhook deleted successfully."
});
}
else {
console.log("WebhookManager encountered an error deleting a webhook. " + res.status);
sendBotMessage(ctx.channel.id, {
content: "There was an error deleting the webhook. Check the console for more info."
});
}
}
catch (error) {
console.log("WebhookManager encountered an error deleting a webhook. " + error);
byeoon marked this conversation as resolved.
Show resolved Hide resolved
sendBotMessage(ctx.channel.id, {
content: "There was an error deleting the webhook. Check the console for more info. Did you input a valid webhook URL?"
});
}
}
},
{
name: "webhookinfo",
description: "Retrieve information about a webhook.",
inputType: ApplicationCommandInputType.BUILT_IN,
options: [
{
name: "url",
description: "The URL of the webhook.",
type: ApplicationCommandOptionType.STRING,
required: true
}
],
execute: async (option, ctx) => {
var webhookUrl = findOption(option, "url");
byeoon marked this conversation as resolved.
Show resolved Hide resolved
await fetch("" + webhookUrl).then(response => response.json())
.then(response => {
console.log(JSON.stringify(response));
sendBotMessage(ctx.channel.id, {
byeoon marked this conversation as resolved.
Show resolved Hide resolved
content: "# Webhook Information: \n" +
byeoon marked this conversation as resolved.
Show resolved Hide resolved
"Webhook Username: " + response.name + "\n " +
"Webhook ID: " + response.id + "\n " +
"Webhook Token: " + response.token + "\n " +
"Channel ID: " + response.channel_id + "\n " +
"Server ID: " + response.guild_id + "\n " +
"Webhook Profile Picture: " + "[Click Me](https://cdn.discordapp.com/avatars/" + response.id + "/" + response.avatar + ".png)" + "\n " +
"Webhook Type: " + response.type + "\n \n" +

"# Webhook Creator Information: \n " +
"Creator UserID: " + response.user.id + "\n " +
"Creator Username: " + response.user.username + " | ( <@" + response.user.id + "> )" + "\n " +
"Creator Profile: [Click Me](https://img.discord.dog/" + response.user.id + ") \n"
byeoon marked this conversation as resolved.
Show resolved Hide resolved
});
});
}
},
{
name: "sendwebhookmessage",
byeoon marked this conversation as resolved.
Show resolved Hide resolved
description: "Send a message through a webhook.",
inputType: ApplicationCommandInputType.BUILT_IN,
options: [
{
name: "url",
description: "The URL of the webhook.",
type: ApplicationCommandOptionType.STRING,
required: true
},
{
name: "message",
description: "The message you want to send.",
type: ApplicationCommandOptionType.STRING,
required: true
}
/*
{
name: "username",
byeoon marked this conversation as resolved.
Show resolved Hide resolved
description: "Give the webhook a custom name (Leave blank for default).",
type: ApplicationCommandOptionType.STRING,
required: true
}
*/
byeoon marked this conversation as resolved.
Show resolved Hide resolved

],
execute: async (option, ctx) => {
byeoon marked this conversation as resolved.
Show resolved Hide resolved

var webhookUrl = findOption(option, "url");
var webhookMessage = findOption(option, "message");
// var webhookUsername = findOption(option, "username");
webhookUrlGLOBAL = webhookUrl;
webhookMessageGLOBAL = webhookMessage;
byeoon marked this conversation as resolved.
Show resolved Hide resolved
byeoon marked this conversation as resolved.
Show resolved Hide resolved
await fetch("" + webhookUrl).then(response => response.json())
.then(response => {
webhookDefaultName = response.name;
});

Native.executeWebhook("" + webhookUrl, {
content: webhookMessage,
username: webhookDefaultName,
byeoon marked this conversation as resolved.
Show resolved Hide resolved
avatar_url: ""
});

sendBotMessage(ctx.channel.id, {
content: "Message sent successfully."
});

}
}
]
});
30 changes: 30 additions & 0 deletions src/plugins/WebhookManager/native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/


/*
todo: also add web support (should be as easy as if navigator is on web or smthn like that, might even have a variable for that somewhere)
(thank you official vendicated vending machine 2024 real)
const iframe = document.createElement("iframe")
iframe.sandbox = "allow-scripts"
iframe.srcdoc = `<script nonce="NDEsMjksMTM0LDU4LDIzNyw4OSw0NiwyMTY="> fetch("http://localhost:8080") </script>`
document.body.append(iframe);
setTimeout(() => iframe.remove(), 1000);
*/
import https from "https";


export function executeWebhook(_, url: string, body: object) {
Vendicated marked this conversation as resolved.
Show resolved Hide resolved
const req = https.request(url,
byeoon marked this conversation as resolved.
Show resolved Hide resolved
byeoon marked this conversation as resolved.
Show resolved Hide resolved
{
method: "POST",
headers: {
'Content-Type': 'application/json',
}
});
req.write(JSON.stringify(body));
req.end();
}
4 changes: 4 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
Elvyra: {
name: "Elvyra",
id: 708275751816003615n,
},
Byron: {
name: "byron",
id: 639577344276692992n
}
} satisfies Record<string, Dev>);

Expand Down