/[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 51 by rakin, Mon Jul 29 17:28:23 2024 UTC revision 106 by rakin, Mon Jul 29 17:28:37 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    
12  export async function unmute(client: DiscordClient, user: GuildMember, msg: Message | CommandInteraction, d: User) {  import PunishmentType from '../../types/PunishmentType';
13    
14    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.props[user.guild.id].mute_role);
19          await user.roles.remove(role!);          await user.roles.remove(role!);
20    
21            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 && timeout.row.filePath.endsWith('unmute-job')) {
34                                await clearTimeoutv2(timeout);
35                            }
36                        }
37                    }
38                    catch (e) {
39                        console.log(e);                    
40                    }
41                }
42            }
43    
44            await Punishment.create({
45                type: PunishmentType.UNMUTE,
46                user_id: user.id,
47                guild_id: user.guild!.id,
48                mod_id: d.id,
49                mod_tag: d.tag,
50            });
51    
52          await user.send({          await user.send({
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 95  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.51  
changed lines
  Added in v.106

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26