Files
xiao/commands/text-edit/url-encode.js
T
2018-02-18 15:58:42 +00:00

29 lines
716 B
JavaScript

const { Command } = require('discord.js-commando');
module.exports = class URLEncodeCommand extends Command {
constructor(client) {
super(client, {
name: 'url-encode',
aliases: ['encode-url', 'encode-uri', 'uri-encode', 'encode-uri-component'],
group: 'text-edit',
memberName: 'url-encode',
description: 'Encodes text to URL-friendly characters.',
args: [
{
key: 'text',
prompt: 'What text would you like to encode?',
type: 'string',
validate: text => {
if (encodeURIComponent(text).length < 2000) return true;
return 'Invalid text, your text is too long.';
}
}
]
});
}
run(msg, { text }) {
return msg.say(encodeURIComponent(text));
}
};