/[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 86 by rakin, Mon Jul 29 17:28:32 2024 UTC revision 102 by rakin, Mon Jul 29 17:28:36 2024 UTC
# Line 15  export async function mute(client: Disco Line 15  export async function mute(client: Disco
15      try {      try {
16          const { default: Punishment } = await import('../../models/Punishment');          const { default: Punishment } = await import('../../models/Punishment');
17                    
18          if (dateTime) {          const { getTimeouts, clearTimeoutv2, setTimeoutv2 } = await import('../../utils/setTimeout');
19    
20            const timeouts = getTimeouts();
21            
22            for (const timeout of timeouts.values()) {
23                if (timeout.row.params) {
24                    try {
25                        const json = JSON.parse(timeout.row.params);
26    
27                        if (json) {
28                            if (json[1] === user.id) {
29                                await clearTimeoutv2(timeout);
30                            }
31                        }
32                    }
33                    catch (e) {
34                        console.log(e);                    
35                    }
36                }
37            }
38    
39            if (dateTime && timeInterval) {
40              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) => {
41                  if (err)                  if (err)
42                      console.log(err);                      console.log(err);
43                                    
44                      console.log('A timeout has been set.');                      console.log('A timeout has been set.');
45    
46                      setTimeout(async () => {                      await setTimeoutv2('unmute-job', timeInterval, msg.guild!.id, `unmute ${user.id}`, msg.guild!.id, user.id);
                         await client.db.get("SELECT * FROM unmutes WHERE time = ?", [new Date(dateTime!).toISOString()], async (err: any, data: any) => {  
                             if (err)  
                                 console.log(err);  
                               
                             if (data) {  
                                 await client.db.get('DELETE FROM unmutes WHERE id = ?', [data.id], async (err: any) => {  
                                     let guild = await client.guilds.cache.find(g => g.id === data.guild_id);  
                                     let member = await guild?.members.cache.find(m => m.id === data.user_id);  
           
                                     if (member) {  
                                         await unmute(client, member, msg, client.user!);  
                                         await History.create(member.id, msg.guild!, 'unmute', client.user!.id, null);  
                                     }  
           
                                     console.log(data);  
                                 });  
                             }  
                         });  
                     }, timeInterval);  
47              });              });
48          }          }
49            
50          const role = await msg.guild!.roles.fetch(client.config.get('mute_role'));          const role = await msg.guild!.roles.fetch(client.config.get('mute_role'));
51          await user.roles.add(role!);          await user.roles.add(role!);
52    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26