diff --git a/package.json b/package.json index c343bb56..b5a29402 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "spudnik", "description": "An awesome chat bot for Discord.", - "version": "0.6.2", + "version": "0.6.3", "license": "Apache-2.0", "readme": "README.md", "engines": { diff --git a/src/lib/spudnik.ts b/src/lib/spudnik.ts index fa694f0d..9cbf2ae2 100644 --- a/src/lib/spudnik.ts +++ b/src/lib/spudnik.ts @@ -1,5 +1,5 @@ import chalk from 'chalk'; -import { Channel, Guild, GuildChannel, GuildMember, Message, MessageAttachment, MessageEmbed, MessageReaction, PresenceData, TextChannel } from 'discord.js'; +import { Channel, Guild, GuildChannel, GuildMember, Message, MessageEmbed, MessageReaction, PresenceData, TextChannel } from 'discord.js'; import { CommandoClient } from 'discord.js-commando'; import * as http from 'http'; import Mongoose = require('mongoose'); diff --git a/src/modules/mod/move.ts b/src/modules/mod/move.ts index 9592e509..45d73bf2 100644 --- a/src/modules/mod/move.ts +++ b/src/modules/mod/move.ts @@ -1,4 +1,4 @@ -import { Channel, GuildMember, Message, MessageEmbed, TextChannel } from 'discord.js'; +import { Channel, GuildMember, Message, MessageEmbed, TextChannel, MessageAttachment } from 'discord.js'; import { Command, CommandMessage, CommandoClient } from 'discord.js-commando'; import { getEmbedColor } from '../../lib/custom-helpers'; import { sendSimpleEmbeddedError } from '../../lib/helpers'; @@ -82,48 +82,57 @@ export default class MoveCommand extends Command { if (originalMessage !== undefined) { const destinationChannel = args.channel; - if (originalMessage.embeds.length === 0) { - if (destinationChannel && destinationChannel.type === 'text') { - const moveMessage = new MessageEmbed({ - author: { - icon_url: `${originalMessage.author.displayAvatarURL()}`, - name: `${originalMessageAuthor.displayName}` - }, - color: getEmbedColor(msg), - description: `${originalMessage.content}`, - footer: { - text: `Originally posted at ${originalMessage.createdAt}` - } - }); + if (destinationChannel && destinationChannel.type === 'text') { + const moveMessage = new MessageEmbed({ + author: { + icon_url: `${originalMessage.author.displayAvatarURL()}`, + name: `${originalMessageAuthor.displayName}` + }, + color: getEmbedColor(msg), + description: `${originalMessage.content}`, + footer: { + text: `Originally posted at ${originalMessage.createdAt}` + } + }); + + const fields: any = []; - const fields: any = []; + fields.push({ + inline: true, + name: 'Original post by:', + value: `<@${originalMessageAuthor.id}> in <#${originalChannel.id}>` + }); + if (args.reason) { fields.push({ inline: true, - name: 'Original post by:', - value: `<@${originalMessageAuthor.id}> in <#${originalChannel.id}>` + name: 'Moved for:', + value: `${args.reason}` }); + } - if (args.reason) { - fields.push({ - inline: true, - name: 'Moved for:', - value: `${args.reason}` - }); - } + if (fields !== []) { + moveMessage.fields = fields; + } - if (fields !== []) { - moveMessage.fields = fields; - } + moveMessage.attachFiles(originalMessage.attachments.map(a => a.attachment.toString())); - (destinationChannel as TextChannel).send(moveMessage); + if (originalMessage.embeds.length === 0) { + await (destinationChannel as TextChannel).send(moveMessage); return originalMessage.delete(); } else { - return sendSimpleEmbeddedError(msg, 'Cannot move a text message to a non-text channel.'); + const messages: MessageEmbed[] = new Array(); + + messages.push(moveMessage); + messages.concat(originalMessage.embeds); + + await (destinationChannel as TextChannel).send(messages); + + return originalMessage.delete(); } } else { - return sendSimpleEmbeddedError(msg, 'Cannot move a message that contains an embed to a different channel.'); + return sendSimpleEmbeddedError(msg, 'Cannot move a text message to a non-text channel.'); } } else {