diff --git a/Xiao.js b/Xiao.js index b6f4b0e0..79c07058 100644 --- a/Xiao.js +++ b/Xiao.js @@ -66,14 +66,17 @@ client.on('ready', () => { client.on('message', async msg => { if (!msg.channel.topic || !msg.channel.topic.includes('')) return; - if (msg.author.bot || !msg.content) return; + const hasText = Boolean(msg.content); + const hasImage = msg.attachments.size !== 0; + const hasEmbed = msg.embeds.length !== 0; + if (!hasText && !hasImage && !hasEmbed) return; const origin = client.phone.find(call => call.origin.id === msg.channel.id); const recipient = client.phone.find(call => call.recipient.id === msg.channel.id); if (!origin && !recipient) return; const call = origin || recipient; if (!call.active) return; try { - await call.send(origin ? call.recipient : call.origin, msg); + await call.send(origin ? call.recipient : call.origin, msg, hasText, hasImage, hasEmbed); } catch { return; // eslint-disable-line no-useless-return } diff --git a/package.json b/package.json index 579b2ba1..c77655f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "114.7.1", + "version": "114.7.2", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { diff --git a/structures/phone/PhoneCall.js b/structures/phone/PhoneCall.js index 5087175d..6f4a3fd5 100644 --- a/structures/phone/PhoneCall.js +++ b/structures/phone/PhoneCall.js @@ -52,12 +52,15 @@ module.exports = class PhoneCall { return this; } - send(channel, msg) { - if (msg.content.toLowerCase() === 'hang up') return this.hangup(channel); + send(channel, msg, hasText, hasImage, hasEmbed) { + if (msg.content && msg.content.toLowerCase() === 'hang up') return this.hangup(channel); this.setTimeout(); + const attachments = hasImage ? msg.attachments.map(a => a.url).join('\n') : null; + if (!hasText && hasImage) return channel.send(`☎️ **${msg.author.tag}:**\n${attachments}`); + if (!hasText && hasEmbed) return channel.send(`☎️ **${msg.author.tag}** sent an embed.`); let content = msg.content.replace(inviteRegex, '[redacted invite]'); content = content.length > 1000 ? `${shorten(content, 1000)} (Message too long)` : content; - return channel.send(`☎️ **${msg.author.tag}:** ${content}`); + return channel.send(`☎️ **${msg.author.tag}:** ${content}\n${attachments || ''}`.trim()); } setTimeout() {