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

Annotation of /trunk/commands/unlock.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 39 - (hide annotations)
Mon Jul 29 17:28:19 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: text/javascript
File size: 4795 byte(s)
Updated anti-raid systems
1 rakin 7 const { Permissions } = require("discord.js");
2     const MessageEmbed = require("../src/MessageEmbed");
3    
4     module.exports = {
5     needsOptionParse: true,
6     async handle(msg, cm) {
7     let channel;
8    
9     if (typeof cm.normalArgs[0] === 'undefined') {
10     channel = msg.channel;
11     }
12    
13 rakin 39 let role = msg.guild.roles.everyone;
14 rakin 7
15     if (role) {
16     if (!channel) {
17     channel = msg.mentions?.channels?.first();
18    
19     if (!channel) {
20     channel = msg.guild.channels.cache.find(c => c.id === cm.normalArgs[0]);
21     }
22     }
23    
24     if (channel) {
25     if (cm.options.indexOf('--no-send') === -1) {
26 rakin 39 try {
27     if (cm.options.indexOf('--no-send') === -1) {
28     await channel.send({
29     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 rakin 7 }
98    
99     channel.permissionOverwrites.edit(role, {
100     SEND_MESSAGES: true,
101     });
102     }
103     else {
104     console.log('invalid channel');
105     }
106     }
107    
108     // await msg.reply({
109     // embeds: [
110     // new MessageEmbed()
111     // .setDescription(`The user ${user.user.tag} has been beaned`)
112     // .addFields([
113     // {
114     // name: "Reason",
115     // value: typeof reason === 'undefined' ? '*No reason provided*' : reason
116     // }
117     // ])
118     // ]
119     // });
120     }
121     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26