woah that was easier than i expected
This commit is contained in:
parent
dffe4f5aee
commit
3f3dc42332
1 changed files with 43 additions and 0 deletions
43
commands/Utility/image.js
Normal file
43
commands/Utility/image.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
const IMAGE_NAME = /\.(jpe?g|png|gif|webp)$/i;
|
||||
|
||||
exports.run = async (client, message, args, level) => {
|
||||
if (!args[0]) {
|
||||
message.reply("please provide an image URL to send.")
|
||||
message.delete();
|
||||
return;
|
||||
}
|
||||
|
||||
message.delete();
|
||||
|
||||
const url = args[0];
|
||||
let name;
|
||||
|
||||
if (!IMAGE_NAME.test(url)) {
|
||||
name = 'image.png';
|
||||
}
|
||||
|
||||
try {
|
||||
let msg = await message.channel.send({
|
||||
file: {
|
||||
name,
|
||||
attachment: url
|
||||
}
|
||||
});
|
||||
} catch (ignore) {
|
||||
return msg.edit('Failed to send image.');
|
||||
}
|
||||
};
|
||||
|
||||
exports.conf = {
|
||||
enabled: true,
|
||||
guildOnly: false,
|
||||
aliases: [],
|
||||
permLevel: "User"
|
||||
};
|
||||
|
||||
exports.help = {
|
||||
name: "image",
|
||||
category: "Utiltiy",
|
||||
description: "Sends an image from a URL.",
|
||||
usage: "image <url>"
|
||||
};
|
Loading…
Reference in a new issue