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

Annotation of /trunk/commands/unmute.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 49 - (hide annotations)
Mon Jul 29 17:28:21 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: text/javascript
File size: 3525 byte(s)
Release version 1.10.0

* Added -queues command to list all queued jobs
* Added -joke command to fetch random jokes
* Added support of user tags in some user-based commands
1 rakin 25 const History = require("../src/History");
2 rakin 5 const MessageEmbed = require("../src/MessageEmbed");
3 rakin 49 const { getUser } = require("../src/UserInput");
4 rakin 5
5     module.exports = {
6     async handle(msg, cm) {
7     if (typeof cm.args[0] === 'undefined') {
8     await msg.reply({
9     embeds: [
10     new MessageEmbed()
11     .setColor('#f14a60')
12     .setDescription(`This command requires at least one argument.`)
13     ]
14     });
15    
16     return;
17     }
18    
19 rakin 49 try {
20     var user = await getUser(cm.args[0], msg);
21 rakin 5
22 rakin 49 console.log(user);
23    
24     if (!user) {
25     throw new Error('Invalid User');
26 rakin 5 }
27     }
28 rakin 49 catch (e) {
29     console.log(e);
30 rakin 5
31     await msg.reply({
32     embeds: [
33     new MessageEmbed()
34     .setColor('#f14a60')
35     .setDescription(`Invalid user given.`)
36     ]
37     });
38    
39     return;
40     }
41 rakin 49
42 rakin 5 this.unmute(user, msg);
43     },
44 rakin 25 async unmute(user, msg, guild, log, t) {
45 rakin 5 if (guild === undefined) {
46     guild = msg.guild;
47     }
48    
49     try {
50     let mutedRole = await guild.roles.cache.find(role => role.id === app.config.get('mute_role'));
51 rakin 37 // let generalRole = await guild.roles.cache.find(role => role.id === app.config.get('gen_role'));
52 rakin 5
53     if (typeof mutedRole !== 'object' || mutedRole === null) {
54     await msg?.reply({
55     embeds: [
56     new MessageEmbed()
57     .setColor('#f14a60')
58     .setDescription(`No muted role is set.`)
59     ]
60     });
61    
62     return;
63     }
64    
65 rakin 37 // if (typeof generalRole !== 'object' || generalRole === null) {
66     // await msg?.reply({
67     // embeds: [
68     // new MessageEmbed()
69     // .setColor('#f14a60')
70     // .setDescription(`No general role is set.`)
71     // ]
72     // });
73 rakin 5
74 rakin 37 // return;
75     // }
76 rakin 5
77 rakin 25 if (!log)
78 rakin 37 await History.create(user.id, guild, 'unmute', msg.author.id, null, async (data2) => {});
79 rakin 25
80 rakin 37 // await user.roles.add(generalRole);
81 rakin 5 await user.roles.remove(mutedRole);
82 rakin 25
83     await app.logger.logUnmute(user, t === undefined ? msg.author : t);
84    
85 rakin 5 }
86     catch(e) {
87     console.log(e);
88    
89     await msg?.reply({
90     embeds: [
91     new MessageEmbed()
92     .setColor('#f14a60')
93     .setDescription(`:x: I don't have enough permission to remove the muted role to this user.`)
94     ]
95     });
96    
97     return;
98     }
99    
100     await app.db.get("DELETE FROM unmutes WHERE user_id = ? AND guild_id = ?", [user.id, guild.id], async (err) => {
101    
102     });
103    
104     await user.send({
105     embeds: [
106     new MessageEmbed()
107     .setAuthor({
108     iconURL: guild.iconURL(),
109     name: `\tYou have been unmuted in ${guild.name}`
110     })
111     ]
112     });
113    
114     await msg?.reply({
115     embeds: [
116     new MessageEmbed()
117     .setDescription(`The user ${user.user.tag} has been unmuted`)
118     ]
119     });
120     }
121     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26