summaryrefslogtreecommitdiff
path: root/src/utils/stripWebhookURL.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/stripWebhookURL.ts')
-rw-r--r--src/utils/stripWebhookURL.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/utils/stripWebhookURL.ts b/src/utils/stripWebhookURL.ts
new file mode 100644
index 0000000..fa8c240
--- /dev/null
+++ b/src/utils/stripWebhookURL.ts
@@ -0,0 +1,11 @@
+/**
+* Gets the ID and token for a webhook from a webhook URL from the Discord client
+* @param {string} url URL for the webhook from the Discord client
+* @returns {Object} Object with the webhook ID and token
+*/
+module.exports = url => {
+ const regex = /https:\/\/discordapp\.com\/api\/webhooks\/(\d{1,})\/([\w-_]{1,})/;
+ const matches = regex.exec(url);
+
+ return { id: matches[1], token: matches[2] };
+}; \ No newline at end of file