diff --git a/.gitignore b/.gitignore index bbb3670c..02b69e37 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ command-last-run.json *.traineddata # In-Development Commands +commands/music/ diff --git a/package.json b/package.json index 942e2519..3864c275 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,8 @@ "text-diff": "^1.0.1", "tictactoe-minimax-ai": "^1.2.1", "valid-url": "^1.0.9", - "winston": "^3.3.3" + "winston": "^3.3.3", + "ytdl-core": "^4.4.5" }, "optionalDependencies": { "bufferutil": "^4.0.3", diff --git a/structures/phone/PhoneCall.js b/structures/phone/PhoneCall.js index 787e0abb..f80c5788 100644 --- a/structures/phone/PhoneCall.js +++ b/structures/phone/PhoneCall.js @@ -1,7 +1,7 @@ const { stripIndents } = require('common-tags'); const moment = require('moment'); require('moment-duration-format'); -const { shorten, stripInvites, verify } = require('../../util/Util'); +const { shorten, stripInvites, preventURLEmbeds, verify } = require('../../util/Util'); module.exports = class PhoneCall { constructor(client, startUser, origin, recipient, adminCall) { @@ -133,18 +133,17 @@ module.exports = class PhoneCall { setTimeout(() => this.ratelimitMeters.set(msg.author.id, 0), 5000); } } - const attachments = hasImage ? msg.attachments.map(a => a.url).join('\n') : null; + const attachments = hasImage ? msg.attachments.map(a => this.cleanContent(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 = stripInvites(msg.content); - content = content.length > 1000 ? `${shorten(content, 500)} (Message too long)` : content; - return channel.send(`☎️ **${msg.author.tag}:** ${content}\n${attachments || ''}`.trim()); + const content = content.length > 1000 ? `${shorten(content, 500)} (Message too long)` : content; + return channel.send(`☎️ **${msg.author.tag}:** ${this.cleanContent(content)}\n${attachments || ''}`.trim()); } sendVoicemail(channel, msg) { return channel.send(stripIndents` ☎️ New Voicemail from **${this.originDM ? `${this.startUser.tag}'s DMs` : this.origin.guild.name}:** - **${msg.author.tag}:** ${stripInvites(msg.content)} + **${msg.author.tag}:** ${this.cleanContent(msg.content)} `); } @@ -157,4 +156,10 @@ module.exports = class PhoneCall { get durationDisplay() { return moment.duration(Date.now() - this.timeStarted).format('hh[h]mm[m]ss[s]'); } + + cleanContent(str) { + str = stripInvites(str); + str = preventURLEmbeds(str); + return str; + } }; diff --git a/util/Util.js b/util/Util.js index 519c985f..6dba09fd 100644 --- a/util/Util.js +++ b/util/Util.js @@ -200,6 +200,10 @@ module.exports = class Util { return str; } + static preventURLEmbeds(str) { + return str.replace(/(https?:\/\/\S+)/g, '<$1>'); + } + static async reactIfAble(msg, user, emoji, fallbackEmoji) { const dm = !msg.guild; if (fallbackEmoji && (!dm && !msg.channel.permissionsFor(user).has('USE_EXTERNAL_EMOJIS'))) {