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

Diff of /trunk/src/commands/moderation/UnlockCommand.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 103 by rakin, Mon Jul 29 17:28:36 2024 UTC
# Line 73  export default class UnlockCommand exten Line 73  export default class UnlockCommand exten
73          }          }
74    
75          try {          try {
76              client.db.get('SELECT * FROM locks WHERE channel_id = ?', [channel.id], async (err: any, data: any) => {              await client.db.get('SELECT * FROM locks WHERE channel_id = ?', [channel.id], async (err: any, data: any) => {
77                  if (data || force) {                  if (data || force) {
                     let perm1;  
78                      let perm;                      let perm;
79                      const data1 = data?.perms?.split(',');                      const data1 = data?.perms;
80    
81                      if (data1) {                      if (data1) {
82                          if (data1[0] === 'DENY') {                          if (data1 === 'DENY') {
83                              await (perm = false);                              await (perm = false);
84                          }                          }
85                          else if (data1[0] === 'NULL') {                          else if (data1 === 'NULL') {
86                              await (perm = null);                              await (perm = null);
87                          }                          }
88                          else if (data1[0] === 'ALLOW') {                          else if (data1 === 'ALLOW') {
89                              await (perm = true);                              await (perm = true);
90                          }                          }
   
                         if (data1[1] === 'DENY') {  
                             await (perm1 = false);  
                         }  
                         else if (data1[1] === 'NULL') {  
                             await (perm1 = null);  
                         }  
                         else if (data1[1] === 'ALLOW') {  
                             await (perm1 = true);  
                         }  
91                      }                      }
92    
93                        console.log(data1, perm);                    
94                                            
95                      if (force) {                      if (force) {
                         await (perm1 = true);  
96                          await (perm = true);                          await (perm = true);
97                      }                      }
98    
99                      await console.log(channel.name);                      await console.log(channel.name, role.name);
100    
101                      try {                      try {
102                          await channel.permissionOverwrites.edit(role, {                          await channel.permissionOverwrites.edit(role, {
103                              SEND_MESSAGES: perm,                              SEND_MESSAGES: perm,
104                          });                          });
   
                         const gen = await msg.guild!.roles.fetch(client.config.props[msg.guild!.id].gen_role);  
   
                         await channel.permissionOverwrites.edit(gen!, {  
                             SEND_MESSAGES: perm1,  
                         });  
105                      }                      }
106                      catch (e) {                      catch (e) {
107                          console.log(e);                          console.log(e);
108                      }                      }
109    
                     await console.log(perm, perm1);  
   
110                      if (data) {                      if (data) {
111                          await client.db.get('DELETE FROM locks WHERE id = ?', [data?.id], async (err: any) => {});                          await client.db.get('DELETE FROM locks WHERE id = ?', [data?.id], async (err: any) => {});
112                      }                      }
113                  }                  }
114              });                  else {
115                                    await msg.reply({
116              if (options.isInteraction) {                          embeds: [
117                  await msg.reply({                              new MessageEmbed()
118                      content: "Channel unlocked.",                              .setColor('#007bff')
119                      ephemeral: true                              .setDescription(`:closed_lock_with_key: This channel wasn't locked.`)
120                            ],
121                            ephemeral: true
122                        });
123    
124                        return;
125                    }
126    
127                    if (options.isInteraction) {
128                        await msg.reply({
129                            content: "Channel unlocked.",
130                            ephemeral: true
131                        });
132                    }
133                    else {
134                        await (msg as Message).react('🔓');
135                    }
136    
137                    await channel.send({
138                        embeds: [
139                            new MessageEmbed()
140                            .setColor('#007bff')
141                            .setDescription(`:closed_lock_with_key: This channel has been unlocked.`)
142                        ]
143                  });                  });
             }  
             else {  
                 await (msg as Message).react('🔓');  
             }  
   
             await channel.send({  
                 embeds: [  
                     new MessageEmbed()  
                     .setColor('#007bff')  
                     .setDescription(`:closed_lock_with_key: This channel has been unlocked.`)  
                 ]  
144              });              });
145          }          }
146          catch (e) {          catch (e) {

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26