/[sudobot]/trunk/src/commands/moderation/MuteCommand.ts
ViewVC logotype

Diff of /trunk/src/commands/moderation/MuteCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 51 by rakin, Mon Jul 29 17:28:23 2024 UTC revision 86 by rakin, Mon Jul 29 17:28:32 2024 UTC
# Line 9  import History from '../../automod/Histo Line 9  import History from '../../automod/Histo
9  import getMember from '../../utils/getMember';  import getMember from '../../utils/getMember';
10  import ms from 'ms';  import ms from 'ms';
11  import { unmute } from './UnmuteCommand';  import { unmute } from './UnmuteCommand';
12    import PunishmentType from '../../types/PunishmentType';
13    
14  export async function mute(client: DiscordClient, dateTime: number | undefined, user: GuildMember, msg: Message | CommandInteraction, timeInterval: number | undefined, reason: string | undefined) {  export async function mute(client: DiscordClient, dateTime: number | undefined, user: GuildMember, msg: Message | CommandInteraction, timeInterval: number | undefined, reason: string | undefined) {
15      try {      try {
16            const { default: Punishment } = await import('../../models/Punishment');
17            
18          if (dateTime) {          if (dateTime) {
19              await client.db.get("INSERT INTO unmutes(user_id, guild_id, time) VALUES(?, ?, ?)", [user.id, msg.guild!.id, new Date(dateTime).toISOString()], async (err: any) => {              await client.db.get("INSERT INTO unmutes(user_id, guild_id, time) VALUES(?, ?, ?)", [user.id, msg.guild!.id, new Date(dateTime).toISOString()], async (err: any) => {
20                  if (err)                  if (err)
# Line 44  export async function mute(client: Disco Line 47  export async function mute(client: Disco
47    
48          const role = await msg.guild!.roles.fetch(client.config.get('mute_role'));          const role = await msg.guild!.roles.fetch(client.config.get('mute_role'));
49          await user.roles.add(role!);          await user.roles.add(role!);
50    
51            await Punishment.create({
52                type: PunishmentType.MUTE,
53                user_id: user.id,
54                guild_id: msg.guild!.id,
55                mod_id: msg.member!.user.id,
56                mod_tag: (msg.member!.user as User).tag,
57                reason,
58                meta: {
59                    time: timeInterval ? ms(timeInterval) : undefined
60                }
61            });
62    
63          await History.create(user.id, msg.guild!, 'mute', msg.member!.user.id, typeof reason === 'undefined' ? null : reason);          await History.create(user.id, msg.guild!, 'mute', msg.member!.user.id, typeof reason === 'undefined' ? null : reason);
64          await client.logger.logMute(user, reason === undefined || reason.trim() === '' ? "*No reason provided*" : reason, timeInterval, msg.member!.user as User);          await client.logger.logMute(user, reason === undefined || reason.trim() === '' ? "*No reason provided*" : reason, timeInterval, msg.member!.user as User);
65          await user.send({          await user.send({

Legend:
Removed from v.51  
changed lines
  Added in v.86

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26