From 7ac48975c1c11ebb200014ae321c332465de21ed Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Sun, 30 Apr 2023 16:57:02 +0500 Subject: [PATCH] v4.2.4 - http://jababot.duckdns.org/docs --- dashboard/public/docs/updates.md | 4 +++ events/MessageHandler.js | 57 +++++++++++++++++++++++++++++++- languages/ru-RU/misc.json | 5 +++ 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/dashboard/public/docs/updates.md b/dashboard/public/docs/updates.md index 5c09571d..e8c74f16 100644 --- a/dashboard/public/docs/updates.md +++ b/dashboard/public/docs/updates.md @@ -1,3 +1,7 @@ +### JaBa v4.2.4 +* Добавлено + * Бот цитирует сообщение если отправлена ссылка на него. + ### JaBa v4.2.3 * Удалено * Команда *chat* - Я передумал, а вы даже и не заметили =) diff --git a/events/MessageHandler.js b/events/MessageHandler.js index f8690c62..fb73f288 100644 --- a/events/MessageHandler.js +++ b/events/MessageHandler.js @@ -1,4 +1,4 @@ -const { PermissionsBitField } = require("discord.js"); +const { PermissionsBitField, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js"); const BaseEvent = require("../base/BaseEvent"), xpCooldown = {}, usersMap = new Map(), @@ -49,6 +49,61 @@ class MessageCreate extends BaseEvent { if (message.guild) { await updateXp(client, message, data); + if (message.content.includes("discord.com/channels/")) { + const ids = message.content.match(/\d+/g); + const channelId = ids[1], + messageId = ids[2]; + + const msg = await client.channels.cache.get(channelId).messages.fetch(messageId); + const embed = new EmbedBuilder() + .setAuthor({ + name: message.translate("misc:QUOTE_TITLE", { + user: msg.author.tag, + }), + iconURL: "https://wynem.com/assets/images/icons/quote.webp", + }) + .setThumbnail(msg.author.avatarURL()) + .setDescription(msg.content !== "" ? msg.content : `*${message.translate("common:MISSING")}*`) + .addFields([ + { + name: message.translate("misc:QUOTE_ATTACHED"), + value: msg.attachments.size > 0 ? msg.attachments.map(a => { + return `[${a.name}](${a.url})`; + }).join("\n") : `*${message.translate("common:MISSING")}*`, + }, + ]) + .setFooter({ + text: message.translate("misc:QUOTE_FOOTER", { user: message.author.tag }), + }) + .setColor(client.config.embed.color) + .setTimestamp(msg.createdTimestamp); + + const row = new ActionRowBuilder() + .addComponents( + new ButtonBuilder() + .setLabel(message.translate("misc:QUOTE_JUMP")) + .setStyle(ButtonStyle.Link) + .setURL(msg.url), + new ButtonBuilder() + .setCustomId("quote_delete") + .setEmoji("1102200816582000750") + .setStyle(ButtonStyle.Danger), + ); + + const reply = await message.reply({ + embeds: [embed], + components: [row], + }); + + const filter = i => i.user.id === message.author.id; + const collector = message.channel.createMessageComponentCollector({ filter, time: (60 * 1000) }); + + collector.on("collect", async i => { + if (i.isButton() && i.customId === "quote_delete") + if (reply.deletable) await reply.delete(); + }); + } + if (data.guildData.plugins.automod.enabled && !data.guildData.plugins.automod.ignored.includes(message.channel.id)) if (/(discord\.(gg|io|me|li)\/.+|discordapp\.com\/invite\/.+)/i.test(message.content)) if (!message.channel.permissionsFor(message.member).has(PermissionsBitField.Flags.ManageMessages)) { diff --git a/languages/ru-RU/misc.json b/languages/ru-RU/misc.json index 9a1c63dd..607f3ee7 100644 --- a/languages/ru-RU/misc.json +++ b/languages/ru-RU/misc.json @@ -15,6 +15,11 @@ "TIMED_OUT": "Время вышло", "JUMP_TO_PAGE": "Укажите страницу к которой хотите перейти (максимум **{{length}}**):", + "QUOTE_TITLE": "Сообщение от {{user}}", + "QUOTE_ATTACHED": "Прикреплённые файлы", + "QUOTE_JUMP": "Перейти", + "QUOTE_FOOTER": "Цитировал {{user}}", + "PERMISSIONS": { "CreateInstantInvite": "Создание приглашения", "KickMembers": "Выгонять участников",