diff options
Diffstat (limited to 'src/commands/server/quotemessage.ts')
| -rw-r--r-- | src/commands/server/quotemessage.ts | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/src/commands/server/quotemessage.ts b/src/commands/server/quotemessage.ts deleted file mode 100644 index d421f68..0000000 --- a/src/commands/server/quotemessage.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; -import { MessageEmbed } from 'discord.js'; -const tt = require('../../utils/truncateText.js') -import path from 'path' - -module.exports = class QuoteMessageServer extends Command { - constructor(client: CommandoClient) { - super(client, { - name: 'quotemessage', - aliases: [ - 'quote-message', - 'quotemsg', - 'quote-msg' - ], - group: 'fun', - memberName: 'quotemessage', - description: 'Quote a message from a text channel.', - examples: ['uwu!quotemessage 424936127154094080'], - throttling: { - usages: 5, - duration: 30 - }, - userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], - clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], - args: [ - { - key: 'mMsg', - prompt: 'What message would you like to quote?', - type: 'message', - label: 'message ID' - } - ] - }); - } - run(msg: CommandoMessage, { mMsg }: any) { - let emb = new MessageEmbed() - .setColor(0xFFCC4D) - .setTimestamp(mMsg.createdAt) - .setAuthor(mMsg.author.tag, mMsg.author.avatarUrl) // TODO: fix avatarurl not working - .addFields([ - { - name: 'Channel', - value: mMsg.channel.toString() - }, - { - name: 'Message', - value: `[Jump to](https://discordapp.com/channels/${mMsg.guild.id}/${mMsg.channel.id}/${mMsg.id})` - } - ]) - - // check if msg had content - console.debug('Does the message have content:', Boolean(mMsg.content)) - if (mMsg.content) emb.setDescription(tt(mMsg.content)) - - // get img from msg - let messageImage - // valid img file extensions - const extensions = ['.png', '.jpg', '.jpeg', '.gif', '.webp'] - // regex for url to img - const linkRegex = /https?:\/\/(?:\w+\.)?[\w-]+\.[\w]{2,3}(?:\/[\w-_.]+)+\.(?:png|jpg|jpeg|gif|webp)/; - - // embed (that may or may not exist) with an img in it - const imageEmbed = mMsg.embeds.find((msgEmbed: { type: string; image: { url: string; }; }) => { - msgEmbed.type === 'rich' && msgEmbed.image && extensions.includes(path.extname(msgEmbed.image.url)) - }) - - if (imageEmbed) messageImage = imageEmbed.image.url - - // uploaded img - const attachment = mMsg.attachments.find((file: { url: string; }) => extensions.includes(path.extname(file.url))) - if (attachment) { - messageImage = attachment.url - } - - // if there wasnt an uploaded img check if there was a url to one - if (!messageImage) { - const linkMatch = mMsg.content.match(linkRegex) - if (linkMatch && extensions.includes(path.extname(linkMatch[0]))) { - [messageImage] = linkMatch - } - } - - // if there was an img, set embed image to it - if (messageImage) emb.setImage(messageImage) - - return msg.say(emb) - } -};
\ No newline at end of file |