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

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

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

revision 86 by rakin, Mon Jul 29 17:28:32 2024 UTC revision 102 by rakin, Mon Jul 29 17:28:36 2024 UTC
# Line 11  import ms from 'ms'; Line 11  import ms from 'ms';
11    
12  import PunishmentType from '../../types/PunishmentType';  import PunishmentType from '../../types/PunishmentType';
13    
14  export async function unmute(client: DiscordClient, user: GuildMember, msg: Message | CommandInteraction, d: User) {  export async function unmute(client: DiscordClient, user: GuildMember, d: User) {
15      try {                  try {            
16          await History.create(user.id, msg.guild!, 'unmute', msg.member!.user.id, null);          await History.create(user.id, user.guild!, 'unmute', d.id, null);
17    
18          const role = await msg.guild!.roles.fetch(client.config.get('mute_role'));          const role = await user.guild!.roles.fetch(client.config.get('mute_role'));
19          await user.roles.remove(role!);          await user.roles.remove(role!);
20    
21          const { default: Punishment } = await import('../../models/Punishment');          const { default: Punishment } = await import('../../models/Punishment');
22    
23            const { getTimeouts, clearTimeoutv2 } = await import('../../utils/setTimeout');
24    
25            const timeouts = getTimeouts();
26            
27            for (const timeout of timeouts.values()) {
28                if (timeout.row.params) {
29                    try {
30                        const json = JSON.parse(timeout.row.params);
31    
32                        if (json) {
33                            if (json[1] === user.id) {
34                                await clearTimeoutv2(timeout);
35                            }
36                        }
37                    }
38                    catch (e) {
39                        console.log(e);                    
40                    }
41                }
42            }
43    
44          await Punishment.create({          await Punishment.create({
45              type: PunishmentType.UNMUTE,              type: PunishmentType.UNMUTE,
46              user_id: user.id,              user_id: user.id,
47              guild_id: msg.guild!.id,              guild_id: user.guild!.id,
48              mod_id: d.id,              mod_id: d.id,
49              mod_tag: d.tag,              mod_tag: d.tag,
50          });          });
# Line 32  export async function unmute(client: Dis Line 53  export async function unmute(client: Dis
53              embeds: [              embeds: [
54                  new MessageEmbed()                  new MessageEmbed()
55                  .setAuthor({                  .setAuthor({
56                      iconURL: <string> msg.guild!.iconURL(),                      iconURL: <string> user.guild!.iconURL(),
57                      name: `\tYou have been unmuted in ${msg.guild!.name}`                      name: `\tYou have been unmuted in ${user.guild!.name}`
58                  })                  })
59              ]              ]
60          });          });
# Line 107  export default class UnmuteCommand exten Line 128  export default class UnmuteCommand exten
128              console.log(user);              console.log(user);
129          }          }
130    
131          await unmute(client, user, msg, msg.member!.user as User);          await unmute(client, user, msg.member!.user as User);
132    
133          await msg.reply({          await msg.reply({
134              embeds: [              embeds: [

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26