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

Diff of /trunk/commands/unlockall.js

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

revision 20 by rakin, Mon Jul 29 17:28:12 2024 UTC revision 21 by rakin, Mon Jul 29 17:28:15 2024 UTC
# Line 4  const MessageEmbed = require("../src/Mes Line 4  const MessageEmbed = require("../src/Mes
4  module.exports = {  module.exports = {
5      needsOptionParse: true,      needsOptionParse: true,
6      async handle(msg, cm) {      async handle(msg, cm) {
7          let channels = cm.options.indexOf('--raid') !== -1 ? app.config.get('raid').included : app.config.get('lockall');          let channels = cm.options.indexOf('--raid') !== -1 ? app.config.get('raid').excluded : app.config.get('lockall');
8    
9          if (msg.mentions.channels.first()) {          if (msg.mentions.channels.first()) {
10              channels = msg.mentions.channels;              channels = msg.mentions.channels;
11          }          }
12          else {          else {
13              channels = await msg.guild.channels.cache.filter(c => channels.indexOf(c.id) !== -1);              channels = await msg.guild.channels.cache.filter(c => ((cm.options.indexOf('--raid') !== -1 && channels.indexOf(c.id) === -1 && channels.indexOf(c.parent?.id) === -1 && c.type === 'GUILD_TEXT') || (cm.options.indexOf('--raid') === -1 && channels.indexOf(c.id) !== -1)));
14          }          }
15    
16          await this.unlockAll(msg, cm, channels);          await this.unlockAll(msg, cm, channels);
# Line 20  module.exports = { Line 20  module.exports = {
20    
21          if (role) {          if (role) {
22              channels.forEach(async channel => {              channels.forEach(async channel => {
23                  if (cm.options.indexOf('--no-send') === -1) {                  try {
24                      channel.send({                      if (cm.options.indexOf('--no-send') === -1) {
25                          embeds: [                          channel.send({
26                              new MessageEmbed()                              embeds: [
27                              .setDescription(':closed_lock_with_key: This channel has been unlocked.')                                  new MessageEmbed()
28                          ]                                  .setDescription(':closed_lock_with_key: This channel has been unlocked.')
29                                ]
30                            });
31                        }
32                        
33                        channel.permissionOverwrites.edit(role, {
34                            SEND_MESSAGES: true,
35                      });                      });
36                  }                  }
37                                    catch(e) {
38                  channel.permissionOverwrites.edit(role, {                      console.log(e);
39                      SEND_MESSAGES: true,                  }
                 });  
40              });              });
41          }          }
42      }      }

Legend:
Removed from v.20  
changed lines
  Added in v.21

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26