10 |
import ms from 'ms'; |
import ms from 'ms'; |
11 |
import { unmute } from './UnmuteCommand'; |
import { unmute } from './UnmuteCommand'; |
12 |
import PunishmentType from '../../types/PunishmentType'; |
import PunishmentType from '../../types/PunishmentType'; |
13 |
|
import { shouldNotModerate } from '../../utils/util'; |
14 |
|
|
15 |
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) { |
16 |
try { |
try { |
76 |
}); |
}); |
77 |
|
|
78 |
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); |
79 |
await user.send({ |
|
80 |
embeds: [ |
try { |
81 |
new MessageEmbed() |
await user.send({ |
82 |
.setAuthor({ |
embeds: [ |
83 |
iconURL: <string> msg.guild!.iconURL(), |
new MessageEmbed() |
84 |
name: `\tYou have been muted in ${msg.guild!.name}` |
.setAuthor({ |
85 |
}) |
iconURL: <string> msg.guild!.iconURL(), |
86 |
.addField("Reason", reason === undefined || reason.trim() === '' ? "*No reason provided*" : reason) |
name: `\tYou have been muted in ${msg.guild!.name}` |
87 |
] |
}) |
88 |
}); |
.addField("Reason", reason === undefined || reason.trim() === '' ? "*No reason provided*" : reason) |
89 |
|
] |
90 |
|
}); |
91 |
|
} |
92 |
|
catch (e) { |
93 |
|
console.log(e); |
94 |
|
} |
95 |
} |
} |
96 |
catch (e) { |
catch (e) { |
97 |
console.log(e); |
console.log(e); |
240 |
dateTime = Date.now() + timeInterval; |
dateTime = Date.now() + timeInterval; |
241 |
} |
} |
242 |
|
|
243 |
|
if (shouldNotModerate(client, user)) { |
244 |
|
await msg.reply({ |
245 |
|
embeds: [ |
246 |
|
{ |
247 |
|
description: "This user cannot be muted." |
248 |
|
} |
249 |
|
] |
250 |
|
}); |
251 |
|
|
252 |
|
return; |
253 |
|
} |
254 |
|
|
255 |
await mute(client, dateTime, user, msg, timeInterval, reason, hard); |
await mute(client, dateTime, user, msg, timeInterval, reason, hard); |
256 |
|
|
257 |
const fields = [ |
const fields = [ |
287 |
] |
] |
288 |
}); |
}); |
289 |
} |
} |
|
} |
|
290 |
|
} |