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 { hasPermission, 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 (!(await hasPermission(client, user, msg, null, "You don't have permission to mute this user."))) { |
244 |
|
return; |
245 |
|
} |
246 |
|
|
247 |
|
if (shouldNotModerate(client, user)) { |
248 |
|
await msg.reply({ |
249 |
|
embeds: [ |
250 |
|
{ |
251 |
|
description: "This user cannot be muted." |
252 |
|
} |
253 |
|
] |
254 |
|
}); |
255 |
|
|
256 |
|
return; |
257 |
|
} |
258 |
|
|
259 |
await mute(client, dateTime, user, msg, timeInterval, reason, hard); |
await mute(client, dateTime, user, msg, timeInterval, reason, hard); |
260 |
|
|
261 |
const fields = [ |
const fields = [ |
291 |
] |
] |
292 |
}); |
}); |
293 |
} |
} |
|
} |
|
294 |
|
} |