/[sudobot]/trunk/commands/unlock.js
ViewVC logotype

Diff of /trunk/commands/unlock.js

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

revision 11 by rakin, Mon Jul 29 17:28:13 2024 UTC revision 39 by rakin, Mon Jul 29 17:28:19 2024 UTC
# Line 10  module.exports = { Line 10  module.exports = {
10              channel = msg.channel;              channel = msg.channel;
11          }          }
12    
13          let role = cm.options.indexOf('--everyone') === -1 ? msg.guild.roles.cache.find(r => r.id === app.config.get('gen_role')) : msg.guild.roles.everyone;          let role = msg.guild.roles.everyone;
14    
15          if (role) {          if (role) {
16              if (!channel) {              if (!channel) {
# Line 23  module.exports = { Line 23  module.exports = {
23    
24              if (channel) {              if (channel) {
25                  if (cm.options.indexOf('--no-send') === -1) {                  if (cm.options.indexOf('--no-send') === -1) {
26                      channel.send({                      try {
27                          embeds: [                          if (cm.options.indexOf('--no-send') === -1) {
28                              new MessageEmbed()                              await channel.send({
29                              .setDescription(':closed_lock_with_key: This channel has been unlocked.')                                  embeds: [
30                          ]                                      new MessageEmbed()
31                      });                                      .setDescription(':closed_lock_with_key: This channel has been unlocked.')
32                                    ]
33                                });
34                            }
35        
36                            app.db.get('SELECT * FROM locks WHERE channel_id = ?', [channel.id], async (err, data) => {
37                                if (data || cm.options.indexOf('--force') !== -1) {
38                                    let perm1;
39                                    let perm;
40                                    const data1 = data?.perms?.split(',');
41        
42                                    if (data1) {
43                                        if (data1[0] === 'DENY') {
44                                            await (perm = false);
45                                        }
46                                        else if (data1[0] === 'NULL') {
47                                            await (perm = null);
48                                        }
49                                        else if (data1[0] === 'ALLOW') {
50                                            await (perm = true);
51                                        }
52            
53                                        if (data1[1] === 'DENY') {
54                                            await (perm1 = false);
55                                        }
56                                        else if (data1[1] === 'NULL') {
57                                            await (perm1 = null);
58                                        }
59                                        else if (data1[1] === 'ALLOW') {
60                                            await (perm1 = true);
61                                        }
62                                    }
63                                    
64                                    if (cm.options.indexOf('--force') !== -1) {
65                                        await (perm1 = true);
66                                        await (perm = true);
67                                    }
68        
69                                    await console.log(channel.name);
70        
71                                    try {
72                                        await channel.permissionOverwrites.edit(role, {
73                                            SEND_MESSAGES: perm,
74                                        });
75        
76                                        const gen = await msg.guild.roles.fetch(app.config.props[msg.guild.id].gen_role);
77        
78                                        await channel.permissionOverwrites.edit(gen, {
79                                            SEND_MESSAGES: perm1,
80                                        });
81                                    }
82                                    catch (e) {
83                                        console.log(e);
84                                    }
85        
86                                    await console.log(perm, perm1);
87        
88                                    if (data) {
89                                        await app.db.get('DELETE FROM locks WHERE id = ?', [data?.id], async (err) => {});
90                                    }
91                                }
92                            });
93                        }
94                        catch(e) {
95                            console.log(e);
96                        }
97                  }                  }
98                                    
99                  channel.permissionOverwrites.edit(role, {                  channel.permissionOverwrites.edit(role, {

Legend:
Removed from v.11  
changed lines
  Added in v.39

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26