fix lowercasing issue'
parent
ca003b5ca4
commit
317a752a7c
|
@ -18,7 +18,7 @@ export default class AddRedirect extends Command {
|
||||||
const check = await this.client.db.redirect.findOne({ key: args[1].toLowerCase() });
|
const check = await this.client.db.redirect.findOne({ key: args[1].toLowerCase() });
|
||||||
if (check) return this.error(message.channel, `Redirect key ${args[1].toLowerCase()} already exists. Linked to: ${check.to}`);
|
if (check) return this.error(message.channel, `Redirect key ${args[1].toLowerCase()} already exists. Linked to: ${check.to}`);
|
||||||
try {
|
try {
|
||||||
const test = new URL(args[0].toLowerCase());
|
const test = new URL(args[0]);
|
||||||
if (test.protocol !== 'https:') return this.error(message.channel, 'Protocol must be HTTPS.');
|
if (test.protocol !== 'https:') return this.error(message.channel, 'Protocol must be HTTPS.');
|
||||||
} catch {
|
} catch {
|
||||||
return this.error(message.channel, 'This doesn\'t appear to be a valid URL.');
|
return this.error(message.channel, 'This doesn\'t appear to be a valid URL.');
|
||||||
|
@ -27,10 +27,10 @@ export default class AddRedirect extends Command {
|
||||||
// eslint-disable-next-line new-cap
|
// eslint-disable-next-line new-cap
|
||||||
const redirect = new this.client.db.redirect({
|
const redirect = new this.client.db.redirect({
|
||||||
key: args[1].toLowerCase(),
|
key: args[1].toLowerCase(),
|
||||||
to: args[0].toLowerCase(),
|
to: args[0],
|
||||||
});
|
});
|
||||||
await redirect.save();
|
await redirect.save();
|
||||||
return this.success(message.channel, `Redirect https://loc.sh/${args[1].toLowerCase()} -> ${args[0].toLowerCase()} is now active.`);
|
return this.success(message.channel, `Redirect https://loc.sh/${args[1].toLowerCase()} -> ${args[0]} is now active.`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return this.client.util.handleError(err, message, this);
|
return this.client.util.handleError(err, message, this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue