mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-31 06:51:02 +00:00
feat(bot-discord): mute and unmute command
This commit is contained in:
63
apps/bot-discord/src/commands/mute.js
Normal file
63
apps/bot-discord/src/commands/mute.js
Normal file
@@ -0,0 +1,63 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { checkForPerms } from '../utils/checkModPerms.js';
|
||||
import reportToLogs from '../utils/reportToLogs.js';
|
||||
import muteMember from '../utils/muteMember.js';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('mute')
|
||||
.setDescription('Mute a member.')
|
||||
.setDMPermission(false)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('user')
|
||||
.setDescription('The member to mute')
|
||||
.setRequired(true)
|
||||
)
|
||||
.addIntegerOption(option =>
|
||||
option
|
||||
.setName('duration')
|
||||
.setDescription('The duration of mute')
|
||||
.setRequired(true)
|
||||
)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('reason')
|
||||
.setDescription('The reason of the mute')
|
||||
.setRequired(true)
|
||||
),
|
||||
async execute(_, config, interaction) {
|
||||
if (!checkForPerms(config, interaction.member)) return interaction.reply({
|
||||
epheremal: true,
|
||||
content: 'You don\'t have the required permissions.'
|
||||
});
|
||||
|
||||
await interaction.deferReply();
|
||||
|
||||
let member;
|
||||
try {
|
||||
member = await interaction.guild.members.fetch(interaction.getString('user'));
|
||||
} catch (_) {
|
||||
await interaction.editReply({
|
||||
content: 'Could not find member.'
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const reason = interaction.getString('reason');
|
||||
const parsedDuration = await muteMember(config, member, {
|
||||
duration: interaction.getString('duration'),
|
||||
reason,
|
||||
supportMute: false
|
||||
});
|
||||
|
||||
reportToLogs(config, interaction.client, 'muted', null, {
|
||||
reason,
|
||||
actionTo: await client.users.fetch(interaction.getString('user')),
|
||||
actionBy: interaction.member,
|
||||
channel: interaction.channel,
|
||||
expire: parsedDuration
|
||||
});
|
||||
}
|
||||
};
|
||||
54
apps/bot-discord/src/commands/unmute.js
Normal file
54
apps/bot-discord/src/commands/unmute.js
Normal file
@@ -0,0 +1,54 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { checkForPerms } from '../utils/checkModPerms.js';
|
||||
import reportToLogs from '../utils/reportToLogs.js';
|
||||
import unmuteMember from '../utils/unmuteMember.js';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('unmute')
|
||||
.setDescription('Unmute a member.')
|
||||
.setDMPermission(false)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('user')
|
||||
.setDescription('The member to unmute')
|
||||
.setRequired(true)
|
||||
),
|
||||
async execute(_, config, interaction) {
|
||||
if (!checkForPerms(config, interaction.member)) return interaction.reply({
|
||||
epheremal: true,
|
||||
content: 'You don\'t have the required permissions.'
|
||||
});
|
||||
|
||||
await interaction.deferReply();
|
||||
|
||||
let member;
|
||||
try {
|
||||
member = await interaction.guild.members.fetch(interaction.getString('user'));
|
||||
} catch (_) {
|
||||
await interaction.editReply({
|
||||
content: 'Could not find member.'
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const reason = interaction.getString('reason');
|
||||
const isMuted = await unmuteMember(config, member);
|
||||
|
||||
if (!isMuted) {
|
||||
await interaction.editReply({
|
||||
content: 'Member was not muted.'
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
reportToLogs(config, interaction.client, 'unmuted', null, {
|
||||
reason,
|
||||
actionTo: await client.users.fetch(interaction.getString('user')),
|
||||
actionBy: interaction.member,
|
||||
channel: interaction.channel,
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user