From 2a758004b887bb00077233978cb4145c4dc77d3e Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Wed, 13 May 2020 19:02:17 -0400 Subject: [PATCH] Add various spam prevention features to phone --- commands/other/portal-send.js | 2 +- package.json | 2 +- structures/phone/PhoneCall.js | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/commands/other/portal-send.js b/commands/other/portal-send.js index d774c7c7..88de2d3b 100644 --- a/commands/other/portal-send.js +++ b/commands/other/portal-send.js @@ -12,7 +12,7 @@ module.exports = class PortalSendCommand extends Command { description: 'Send a message to a portal channel.', throttling: { usages: 1, - duration: 10 + duration: 30 }, args: [ { diff --git a/package.json b/package.json index 8ebd2326..4ae6b267 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "114.10.1", + "version": "114.10.2", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { diff --git a/structures/phone/PhoneCall.js b/structures/phone/PhoneCall.js index a1e13ba2..1a9d6257 100644 --- a/structures/phone/PhoneCall.js +++ b/structures/phone/PhoneCall.js @@ -10,6 +10,7 @@ module.exports = class PhoneCall { this.active = false; this.timeout = null; this.ownerOrigin = ownerOrigin || false; + this.cooldown = new Set(); } async start() { @@ -65,12 +66,17 @@ module.exports = class PhoneCall { } return this.hangup(channel); } + if (this.cooldown.has(msg.author.id)) { + return this.recipient.send(`☎️ ${msg.author}, please wait **5** seconds between messages!`); + } this.setTimeout(); + this.cooldown.add(msg.author.id); + setTimeout(() => this.cooldown.delete(msg.author.id), 5000); 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 = stripInvites(msg.content); - content = content.length > 1000 ? `${shorten(content, 1000)} (Message too long)` : content; + content = content.length > 1000 ? `${shorten(content, 500)} (Message too long)` : content; return channel.send(`☎️ **${msg.author.tag}:** ${content}\n${attachments || ''}`.trim()); }