mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Strip Invites in portal send, strip bot invites
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
|
const { stripInvites } = require('../../util/Util');
|
||||||
const { PORTAL_EMOJI_ID, PORTAL_EMOJI_NAME } = process.env;
|
const { PORTAL_EMOJI_ID, PORTAL_EMOJI_NAME } = process.env;
|
||||||
|
|
||||||
module.exports = class PortalSendCommand extends Command {
|
module.exports = class PortalSendCommand extends Command {
|
||||||
@@ -18,14 +19,14 @@ module.exports = class PortalSendCommand extends Command {
|
|||||||
key: 'message',
|
key: 'message',
|
||||||
prompt: 'What message would you like to send?',
|
prompt: 'What message would you like to send?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
max: 1000
|
max: 1000,
|
||||||
|
parse: message => stripInvites(message)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(msg, { message }) {
|
async run(msg, { message }) {
|
||||||
if (/discord(\.gg|app\.com\/invite|\.me)\//gi.test(message)) return msg.reply('Please do not send invites.');
|
|
||||||
let channels = this.client.channels.cache.filter(
|
let channels = this.client.channels.cache.filter(
|
||||||
channel => channel.guild && channel.topic && channel.topic.includes('<xiao:portal>')
|
channel => channel.guild && channel.topic && channel.topic.includes('<xiao:portal>')
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "114.8.2",
|
"version": "114.8.3",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
const { shorten, verify } = require('../../util/Util');
|
const { shorten, stripInvites, verify } = require('../../util/Util');
|
||||||
const inviteRegex = /(https?:\/\/)?(www\.|canary\.|ptb\.)?discord(\.gg|app\.com\/invite|\.me)\/([^ ]+)\/?/gi;
|
|
||||||
|
|
||||||
module.exports = class PhoneCall {
|
module.exports = class PhoneCall {
|
||||||
constructor(client, origin, recipient) {
|
constructor(client, origin, recipient) {
|
||||||
@@ -58,7 +57,7 @@ module.exports = class PhoneCall {
|
|||||||
const attachments = hasImage ? msg.attachments.map(a => a.url).join('\n') : null;
|
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 && hasImage) return channel.send(`☎️ **${msg.author.tag}:**\n${attachments}`);
|
||||||
if (!hasText && hasEmbed) return channel.send(`☎️ **${msg.author.tag}** sent an embed.`);
|
if (!hasText && hasEmbed) return channel.send(`☎️ **${msg.author.tag}** sent an embed.`);
|
||||||
let content = msg.content.replace(inviteRegex, '[redacted invite]');
|
let content = stripInvites(msg.content);
|
||||||
content = content.length > 1000 ? `${shorten(content, 1000)} (Message too long)` : content;
|
content = content.length > 1000 ? `${shorten(content, 1000)} (Message too long)` : content;
|
||||||
return channel.send(`☎️ **${msg.author.tag}:** ${content}\n${attachments || ''}`.trim());
|
return channel.send(`☎️ **${msg.author.tag}:** ${content}\n${attachments || ''}`.trim());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const yes = ['yes', 'y', 'ye', 'yeah', 'yup', 'yea', 'ya', 'hai', 'si', 'sí', 'oui', 'はい', 'correct'];
|
const yes = ['yes', 'y', 'ye', 'yeah', 'yup', 'yea', 'ya', 'hai', 'si', 'sí', 'oui', 'はい', 'correct'];
|
||||||
const no = ['no', 'n', 'nah', 'nope', 'nop', 'iie', 'いいえ', 'non', 'fuck off'];
|
const no = ['no', 'n', 'nah', 'nope', 'nop', 'iie', 'いいえ', 'non', 'fuck off'];
|
||||||
|
const inviteRegex = /(https?:\/\/)?(www\.|canary\.|ptb\.)?discord(\.gg|(app)?\.com\/invite|\.me)\/([^ ]+)\/?/gi;
|
||||||
|
const botInvRegex = /(https?:\/\/)?(www\.|canary\.|ptb\.)?discord(app)\.com\/oauth2\/authorize\?([^ ]+)\/?/gi;
|
||||||
|
|
||||||
module.exports = class Util {
|
module.exports = class Util {
|
||||||
static delay(ms) {
|
static delay(ms) {
|
||||||
@@ -150,6 +152,12 @@ module.exports = class Util {
|
|||||||
return `[${title}](${url.replace(/\)/g, '%27')}${display ? ` "${display}"` : ''})`;
|
return `[${title}](${url.replace(/\)/g, '%27')}${display ? ` "${display}"` : ''})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static stripInvites(str, { guild = true, bot = true, text = '[redacted invite]' }) {
|
||||||
|
if (guild) str = str.replace(inviteRegex, text);
|
||||||
|
if (bot) str = str.replace(botInvRegex, text);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
static async verify(channel, user, { time = 30000, extraYes = [], extraNo = [] } = {}) {
|
static async verify(channel, user, { time = 30000, extraYes = [], extraNo = [] } = {}) {
|
||||||
const filter = res => {
|
const filter = res => {
|
||||||
const value = res.content.toLowerCase();
|
const value = res.content.toLowerCase();
|
||||||
|
|||||||
Reference in New Issue
Block a user