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

Annotation of /trunk/commands/warnings.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: 2288 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 5 const MessageEmbed = require("../src/MessageEmbed");
2 rakin 49 const { getUser } = require("../src/UserInput");
3 rakin 5
4     module.exports = {
5     async handle(msg, cm) {
6     var test = false;
7    
8     if (typeof cm.args[0] === 'undefined') {
9     var args1 = ['SELECT * FROM warnings WHERE guild_id = ?', [msg.guild.id]];
10     var a = {
11     name: `All warnings`
12     };
13     }
14     else {
15 rakin 49 try {
16     var user = await getUser(cm.args[0], msg);
17 rakin 5
18 rakin 49 console.log(user);
19    
20     if (!user) {
21     throw new Error('Invalid User');
22 rakin 5 }
23     }
24 rakin 49 catch (e) {
25     console.log(e);
26 rakin 5
27     await msg.reply({
28     embeds: [
29     new MessageEmbed()
30     .setColor('#f14a60')
31     .setDescription(`Invalid user given.`)
32     ]
33     });
34    
35     return;
36     }
37    
38     var args1 = ['SELECT id, user_id, guild_id, reason FROM warnings WHERE user_id = ? AND guild_id = ?', [user.id, msg.guild.id]];
39     var a = {
40     iconURL: user.displayAvatarURL(),
41     name: `All warnings for ${user.user.tag} in ${msg.guild.name}`
42     };
43    
44     test = true;
45     }
46    
47     await app.db.all(...args1, async (err, data) => {
48     if (err) {
49     console.log(err);
50     }
51    
52     let i = 0;
53    
54     let warnings = await data.map(value => {
55     i++;
56     return {
57     name: "Warning " + i + " (ID: " + value.id + (!test ? ", To: " + value.user_id : "") + ")",
58     value: value.reason === '\c\b\c' ? "No reason provided" : value.reason
59     };
60     });
61    
62     if (test) {
63     warnings.push(
64     {
65     name: "Strike",
66     value: i + ' time(s)'
67     }
68     );
69     }
70    
71     await msg.reply({
72     embeds: [
73     new MessageEmbed()
74     .setAuthor(a)
75     .addFields(warnings)
76     ]
77     });
78     });
79     }
80     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26