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

Annotation of /trunk/commands/unlock.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (hide annotations)
Mon Jul 29 17:28:12 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: text/javascript
File size: 1783 byte(s)
Added lock and unlock commands and improved command parsing
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     let role = cm.options.indexOf('--everyone') === -1 ? msg.guild.roles.cache.find(r => r.id === app.config.get('gen_role')) : msg.guild.roles.everyone;
14    
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     channel.send({
27     embeds: [
28     new MessageEmbed()
29     .setDescription('This channel has been unlocked.')
30     ]
31     });
32     }
33    
34     channel.permissionOverwrites.edit(role, {
35     SEND_MESSAGES: true,
36     });
37     }
38     else {
39     console.log('invalid channel');
40     }
41     }
42    
43     // await msg.reply({
44     // embeds: [
45     // new MessageEmbed()
46     // .setDescription(`The user ${user.user.tag} has been beaned`)
47     // .addFields([
48     // {
49     // name: "Reason",
50     // value: typeof reason === 'undefined' ? '*No reason provided*' : reason
51     // }
52     // ])
53     // ]
54     // });
55     }
56     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26