if(check)returnthis.error(message.channel,`Redirect key ${args[1].toLowerCase()} already exists. Linked to: ${check.to}`);
try{
consttest=newURL(args[0]);
if(test.protocol!=='https:')returnthis.error(message.channel,'Protocol must be HTTPS.');
}catch{
returnthis.error(message.channel,'This doesn\'t appear to be a valid URL.');
}
if((/^[a-zA-Z0-9]+$/gi.test(args[1].toLowerCase().replace('-','').trim())===false)||args[1].toLowerCase().length>15)returnthis.error(message.channel,'Invalid key. The key must be alphanumeric and less than 16 characters.');
constredirect=newthis.client.db.Redirect({
key: args[1].toLowerCase(),
to: args[0],
visitedCount: 0,
});
awaitredirect.save();
returnthis.success(message.channel,`Redirect https://loc.sh/${args[1].toLowerCase()} -> ${args[0]} is now active.`);