1 |
import { BanOptions, CommandInteraction, GuildMember, Interaction, Message, User } from 'discord.js'; |
import { BanOptions, CommandInteraction, GuildMember, Interaction, Message, Permissions, User } from 'discord.js'; |
2 |
import BaseCommand from '../../utils/structures/BaseCommand'; |
import BaseCommand from '../../utils/structures/BaseCommand'; |
3 |
import DiscordClient from '../../client/Client'; |
import DiscordClient from '../../client/Client'; |
4 |
import CommandOptions from '../../types/CommandOptions'; |
import CommandOptions from '../../types/CommandOptions'; |
5 |
import InteractionOptions from '../../types/InteractionOptions'; |
import InteractionOptions from '../../types/InteractionOptions'; |
6 |
import MessageEmbed from '../../client/MessageEmbed'; |
import MessageEmbed from '../../client/MessageEmbed'; |
|
import getUser from '../../utils/getUser'; |
|
|
import History from '../../automod/History'; |
|
7 |
import getMember from '../../utils/getMember'; |
import getMember from '../../utils/getMember'; |
8 |
import ms from 'ms'; |
import ms from 'ms'; |
|
import { unmute } from './UnmuteCommand'; |
|
9 |
import PunishmentType from '../../types/PunishmentType'; |
import PunishmentType from '../../types/PunishmentType'; |
10 |
import { shouldNotModerate } from '../../utils/util'; |
import { hasPermission, shouldNotModerate } from '../../utils/util'; |
11 |
|
|
12 |
export async function mute(client: DiscordClient, dateTime: number | undefined, user: GuildMember, msg: Message | CommandInteraction, timeInterval: number | undefined, reason: string | undefined, hard: boolean = false) { |
export async function mute(client: DiscordClient, dateTime: number | undefined, user: GuildMember, msg: Message | CommandInteraction, timeInterval: number | undefined, reason: string | undefined, hard: boolean = false) { |
13 |
try { |
try { |
54 |
user_id: user.id, |
user_id: user.id, |
55 |
roles: roles.map(role => role.id), |
roles: roles.map(role => role.id), |
56 |
guild_id: msg.guild!.id, |
guild_id: msg.guild!.id, |
57 |
|
createdAt: new Date() |
58 |
}); |
}); |
59 |
} |
} |
60 |
|
|
70 |
reason, |
reason, |
71 |
meta: { |
meta: { |
72 |
time: timeInterval ? ms(timeInterval) : undefined |
time: timeInterval ? ms(timeInterval) : undefined |
73 |
} |
}, |
74 |
|
createdAt: new Date() |
75 |
}); |
}); |
76 |
|
|
77 |
await client.logger.logMute(user, reason === undefined || reason.trim() === '' ? "*No reason provided*" : reason, timeInterval, msg.member!.user as User, hard); |
await client.logger.logMute(user, reason === undefined || reason.trim() === '' ? "*No reason provided*" : reason, timeInterval, msg.member!.user as User, hard); |
118 |
|
|
119 |
export default class MuteCommand extends BaseCommand { |
export default class MuteCommand extends BaseCommand { |
120 |
supportsInteractions: boolean = true; |
supportsInteractions: boolean = true; |
121 |
|
permissions = [Permissions.FLAGS.MODERATE_MEMBERS]; |
122 |
|
|
123 |
constructor() { |
constructor() { |
124 |
super('mute', 'moderation', []); |
super('mute', 'moderation', []); |
240 |
dateTime = Date.now() + timeInterval; |
dateTime = Date.now() + timeInterval; |
241 |
} |
} |
242 |
|
|
243 |
|
if (!(await hasPermission(client, user, msg, null, "You don't have permission to mute this user."))) { |
244 |
|
return; |
245 |
|
} |
246 |
|
|
247 |
if (shouldNotModerate(client, user)) { |
if (shouldNotModerate(client, user)) { |
248 |
await msg.reply({ |
await msg.reply({ |
249 |
embeds: [ |
embeds: [ |