2023-03-15 14:09:09 +00:00
|
|
|
import urlCheck from "../../utils/urlcheck.js";
|
|
|
|
import { request } from "undici";
|
|
|
|
import Command from "../../classes/command.js";
|
|
|
|
|
|
|
|
class LengthenCommand extends Command {
|
2023-03-19 05:10:48 +00:00
|
|
|
static category = "general"
|
2023-03-15 14:09:09 +00:00
|
|
|
async run() {
|
2023-03-17 00:23:01 +00:00
|
|
|
// await this.acknowledge();
|
2023-03-15 14:09:09 +00:00
|
|
|
const input = this.options.url ?? this.args.join(" ");
|
|
|
|
this.success = false;
|
|
|
|
if (!input || !input.trim() || !urlCheck(input)) return "You need to provide a short URL to lengthen!";
|
|
|
|
if (urlCheck(input)) {
|
|
|
|
const url = await request(encodeURI(input), { method: "HEAD" });
|
|
|
|
this.success = true;
|
|
|
|
return url.headers.location || input;
|
|
|
|
} else {
|
|
|
|
return "That isn't a URL!";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static flags = [{
|
|
|
|
name: "url",
|
|
|
|
type: 3,
|
|
|
|
description: "The URL you want to lengthen",
|
|
|
|
required: true
|
|
|
|
}];
|
|
|
|
|
|
|
|
static description = "Lengthens a short URL";
|
|
|
|
static aliases = ["longurl", "lengthenurl", "longuri", "lengthenuri", "unshorten"];
|
|
|
|
static arguments = ["[url]"];
|
|
|
|
}
|
|
|
|
|
2021-08-19 14:19:14 +00:00
|
|
|
export default LengthenCommand;
|