From 8991d979b9967c1cfad2b12c1421316f31a27e53 Mon Sep 17 00:00:00 2001 From: GramingFoxTeam Date: Sun, 13 Aug 2023 20:47:10 +0300 Subject: [PATCH] fix(bot-discord): fix again wont be the last time thanks to exile prefixed cmd and unexile not working properly for some fucking reason --- apps/bot-discord/src/commands/unexile.js | 6 ++++-- apps/bot-discord/src/commands/unmute.js | 4 ++-- apps/bot-discord/src/msgCommands/exile.js | 4 ++-- .../src/utils/exileMemberToChannel.js | 18 ++---------------- apps/bot-discord/src/utils/muteMember.js | 2 +- apps/bot-discord/src/utils/unmuteMember.js | 7 +++---- 6 files changed, 14 insertions(+), 27 deletions(-) diff --git a/apps/bot-discord/src/commands/unexile.js b/apps/bot-discord/src/commands/unexile.js index afd7790..59abc2f 100644 --- a/apps/bot-discord/src/commands/unexile.js +++ b/apps/bot-discord/src/commands/unexile.js @@ -22,7 +22,9 @@ export default { await interaction.deferReply(); - const member = interaction.options.getUser('user'); + const user = interaction.options.getUser('user'); + + const member = await interaction.guild.members.fetch(user); const isExiled = await unmuteMember(config, member, true); if (!isExiled) { @@ -35,7 +37,7 @@ export default { reportToLogs(config, interaction.client, 'unmuted', null, { reason: null, - actionTo: member, + actionTo: user, actionBy: interaction.member, channel: interaction.channel, }, interaction); diff --git a/apps/bot-discord/src/commands/unmute.js b/apps/bot-discord/src/commands/unmute.js index cb554d5..7375b14 100644 --- a/apps/bot-discord/src/commands/unmute.js +++ b/apps/bot-discord/src/commands/unmute.js @@ -25,7 +25,7 @@ export default { const user = interaction.options.getUser('user'); const member = await interaction.guild.members.fetch(user); - const isMuted = await unmuteMember(config, member); + const isMuted = await unmuteMember(config, member, false); if (!isMuted) { await interaction.editReply({ @@ -37,7 +37,7 @@ export default { reportToLogs(config, interaction.client, 'unmuted', null, { reason: null, - actionTo: member, + actionTo: user, actionBy: interaction.member, channel: interaction.channel, }, interaction); diff --git a/apps/bot-discord/src/msgCommands/exile.js b/apps/bot-discord/src/msgCommands/exile.js index 113a3c1..d12634e 100644 --- a/apps/bot-discord/src/msgCommands/exile.js +++ b/apps/bot-discord/src/msgCommands/exile.js @@ -13,9 +13,9 @@ export default { if (args && args[0]) { if (isNaN(args[0])) return msg.reply('The argument you entered is not a number!'); - const msgsByAuthor = (await msg.channels.fetch({ limit: 50 })).filter( + const msgsByAuthor = (await msg.channel.messages.fetch({ limit: 50 })).filter( m => m.author.id === referencedMsg.author.id - ); + ).map(m => m.content); message = msgsByAuthor.slice(Number(`-${args[0]}`)); } diff --git a/apps/bot-discord/src/utils/exileMemberToChannel.js b/apps/bot-discord/src/utils/exileMemberToChannel.js index 26b480d..9f7df5e 100644 --- a/apps/bot-discord/src/utils/exileMemberToChannel.js +++ b/apps/bot-discord/src/utils/exileMemberToChannel.js @@ -1,10 +1,10 @@ -export default async function exileMemberToChannel(member, channel, message, config, isSlash) { +export default async function exileMemberToChannel(member, channel, message, config, ) { const redirectChannel = await channel.client.channels.fetch(config.discord.supportChannel); let messageContent = ''; if (Array.isArray(message)) { for (const msg of message) { - messageContent += `${msg.content}\n`; + messageContent += `${msg}\n`; } } else if (!message) message = 'No message provided'; else messageContent = message; @@ -23,18 +23,4 @@ export default async function exileMemberToChannel(member, channel, message, con } ] }); - - const messageParams = { - content: `<@${member.id}>`, - embeds: [ - { - title: '❗ You have been exiled!', - description: 'This is due to you asking support in non-support channels. Please use the support channel next time.' - } - ] - }; - - if (isSlash) channel.editReply(messageParams); - else channel.send(messageParams); - } \ No newline at end of file diff --git a/apps/bot-discord/src/utils/muteMember.js b/apps/bot-discord/src/utils/muteMember.js index 46c90ba..5765c65 100644 --- a/apps/bot-discord/src/utils/muteMember.js +++ b/apps/bot-discord/src/utils/muteMember.js @@ -7,7 +7,7 @@ export default async function muteMember(config, member, { duration, reason, sup let expires; if (supportMute) { - expires = Math.floor((Date.now() + config.mute.supportMuteDuration) / 1000); + expires = Math.floor((Date.now() + config.discord.mute.supportMuteDuration) / 1000); } else { const parsedDuration = parse(duration); expires = Math.floor((Date.now() + parsedDuration) / 1000); diff --git a/apps/bot-discord/src/utils/unmuteMember.js b/apps/bot-discord/src/utils/unmuteMember.js index d0b6e98..23499f4 100644 --- a/apps/bot-discord/src/utils/unmuteMember.js +++ b/apps/bot-discord/src/utils/unmuteMember.js @@ -10,14 +10,13 @@ export default async function unmuteMember(config, member, supportMute) { } member.roles.remove(mute.support_mute ? - config.mute.supportGiveRoles : - config.mute.giveRoles + config.discord.mute.supportGiveRoles : + config.discord.mute.giveRoles ); member.roles.add(mute.taken_roles); - await member.client.db.collection('muted').remove({ - guild_id: member.guild.id, + await member.client.db.collection('muted').deleteOne({ user_id: member.id });