fix(bot-discord): embed consistency for exilation (#21)

This commit is contained in:
GramingFoxTeam
2023-08-19 17:53:39 +03:00
parent 9b15f73c3f
commit 8d5b68b9c5
6 changed files with 37 additions and 17 deletions

View File

@@ -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,

View File

@@ -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);
}
};

View File

@@ -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,

View File

@@ -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);
}
}

View File

@@ -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()
}
}
]
});

View File

@@ -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