From 8d5b68b9c57d918d5d51e78caa85b5126845eac9 Mon Sep 17 00:00:00 2001 From: GramingFoxTeam Date: Sat, 19 Aug 2023 17:53:39 +0300 Subject: [PATCH] fix(bot-discord): embed consistency for exilation (#21) --- apps/bot-discord/src/commands/exile.js | 4 +- .../src/commands/exileMemberCtx.js | 2 +- apps/bot-discord/src/commands/unexile.js | 2 +- apps/bot-discord/src/msgCommands/exile.js | 2 +- .../src/utils/exileMemberToChannel.js | 42 ++++++++++++++----- apps/bot-discord/src/utils/reportToLogs.js | 2 +- 6 files changed, 37 insertions(+), 17 deletions(-) diff --git a/apps/bot-discord/src/commands/exile.js b/apps/bot-discord/src/commands/exile.js index 8c6a860..9ed8f41 100644 --- a/apps/bot-discord/src/commands/exile.js +++ b/apps/bot-discord/src/commands/exile.js @@ -39,9 +39,9 @@ export default { guild: interaction.guild }); - exileMemberToChannel(member, interaction.channel, null, config, true); + exileMemberToChannel(member, interaction.channel, null, reason, config); - reportToLogs(config, interaction.client, 'muted', null, { + reportToLogs(config, interaction.client, 'exiled', null, { reason, actionTo: user, actionBy: interaction.member, diff --git a/apps/bot-discord/src/commands/exileMemberCtx.js b/apps/bot-discord/src/commands/exileMemberCtx.js index bbab464..805d7d2 100644 --- a/apps/bot-discord/src/commands/exileMemberCtx.js +++ b/apps/bot-discord/src/commands/exileMemberCtx.js @@ -26,6 +26,6 @@ export default { guild: interaction.guild }); - exileMemberToChannel(targetMsg.author, interaction.channel, targetMsg.content, config, true); + exileMemberToChannel(targetMsg.author, interaction.channel, targetMsg.content, null, config); } }; diff --git a/apps/bot-discord/src/commands/unexile.js b/apps/bot-discord/src/commands/unexile.js index 59abc2f..023e060 100644 --- a/apps/bot-discord/src/commands/unexile.js +++ b/apps/bot-discord/src/commands/unexile.js @@ -35,7 +35,7 @@ export default { return; } - reportToLogs(config, interaction.client, 'unmuted', null, { + reportToLogs(config, interaction.client, 'unexiled', null, { reason: null, actionTo: user, actionBy: interaction.member, diff --git a/apps/bot-discord/src/msgCommands/exile.js b/apps/bot-discord/src/msgCommands/exile.js index d12634e..86bb067 100644 --- a/apps/bot-discord/src/msgCommands/exile.js +++ b/apps/bot-discord/src/msgCommands/exile.js @@ -24,6 +24,6 @@ export default { guild: msg.guild }); - exileMemberToChannel(referencedMsg.author, msg.channel, message, config, false); + exileMemberToChannel(referencedMsg.author, msg.channel, message, null, config, false); } } \ No newline at end of file diff --git a/apps/bot-discord/src/utils/exileMemberToChannel.js b/apps/bot-discord/src/utils/exileMemberToChannel.js index 9f7df5e..aced8fb 100644 --- a/apps/bot-discord/src/utils/exileMemberToChannel.js +++ b/apps/bot-discord/src/utils/exileMemberToChannel.js @@ -1,25 +1,45 @@ -export default async function exileMemberToChannel(member, channel, message, config, ) { +export default async function exileMemberToChannel(member, channel, message, reason, config) { const redirectChannel = await channel.client.channels.fetch(config.discord.supportChannel); let messageContent = ''; if (Array.isArray(message)) { for (const msg of message) { messageContent += `${msg}\n`; - } - } else if (!message) message = 'No message provided'; - else messageContent = message; + } + } else if (!message) { + message = 'No message provided' + } else messageContent = message; + + const embedFields = [ + { + name: 'Orginal message', + value: messageContent + } + ]; + + if (reason) { + embedFields.push( + { + name: 'Reason', + value: reason + } + ); + } + await redirectChannel.send({ content: `<@${member.id}>`, embeds: [ { - title: '❗ An exiled member appears!', - fields: [ - { - name: 'Their message', - value: messageContent - } - ] + title: `Restricted to <#${redirectChannel.id}>`, + fields: embedFields, + thumbnail: { + url: member.avatarURL() + }, + footer: { + text: 'ReVanced', + icon_url: channel.client.user.avatarURL() + } } ] }); diff --git a/apps/bot-discord/src/utils/reportToLogs.js b/apps/bot-discord/src/utils/reportToLogs.js index 01ff74a..91c5f9c 100644 --- a/apps/bot-discord/src/utils/reportToLogs.js +++ b/apps/bot-discord/src/utils/reportToLogs.js @@ -13,7 +13,7 @@ export default async function reportToLogs(config, client, action, message, { re { name: 'Action', value: `${actionTo.toString()} was ${action} by ${actionBy.toString()}` } ]; - if (action === 'banned' || action === 'muted') fields.push({ + if (action === 'banned' || action === 'muted' || action === 'exiled') fields.push({ name: 'Reason', value: reason ? reason : 'No reason provided', inline: true