Skip to content

Commit

Permalink
url shortener yeeeee
Browse files Browse the repository at this point in the history
  • Loading branch information
RatWasHere committed Feb 18, 2024
1 parent d84217d commit 01bacad
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Actions/urlShortener_MOD.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module.exports = {
data: {
name: "URL Shortener",
},
UI: [
{
element: "input",
storeAs: "sourceURL",
name: "URL To Shorten"
},
"_",
{
element: "dropdown",
storeAs: "shortenType",
name: "Shorten Type",
extraField: "shortenedCode",
choices: [
{name: "Randomize"},
{name: "Custom", field: true},
]
},
"-",
{
element: "storageInput",
storeAs: "store",
name: "Store Shortened URL As"
},
],

async run(values, interaction, client, bridge) {
await fetch("https://csclub.uwaterloo.ca/~phthakka/1pt-express", {
body: {
long: bridge.transf(values.sourceURL),
short: values.shortenType == "Randomize" ? undefined : bridge.transf(values.shortenedCode)
}
}).then(
async (response) => {
let res = await response.json();
let url = res[0].long;

bridge.store(values.store, url);
}
);
},
};

0 comments on commit 01bacad

Please sign in to comment.