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

Annotation of /trunk/commands/bean.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5 - (hide annotations)
Mon Jul 29 17:28:11 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: text/javascript
File size: 2178 byte(s)
Added base commands
1 rakin 5 const MessageEmbed = require("../src/MessageEmbed");
2    
3     module.exports = {
4     async handle(msg, cm) {
5     if (typeof cm.args[0] === 'undefined') {
6     await msg.reply({
7     embeds: [
8     new MessageEmbed()
9     .setColor('#f14a60')
10     .setDescription(`This command requires at least one argument.`)
11     ]
12     });
13    
14     return;
15     }
16    
17     var user = await msg.mentions.members.first();
18     let reason;
19    
20     if (typeof cm.args[1] !== 'undefined') {
21     let args = [...cm.args];
22     args.shift();
23    
24     await (reason = args.join(' '));
25     }
26    
27     if (typeof user !== 'object') {
28     try {
29     user = await msg.guild.members.fetch(cm.args[0]);
30     }
31     catch(e) {
32    
33     }
34     }
35    
36     if (typeof user !== 'object') {
37     await msg.reply({
38     embeds: [
39     new MessageEmbed()
40     .setColor('#f14a60')
41     .setDescription(`Invalid user given.`)
42     ]
43     });
44    
45     return;
46     }
47    
48     this.bean(user, reason, msg);
49    
50     await msg.reply({
51     embeds: [
52     new MessageEmbed()
53     .setDescription(`The user ${user.user.tag} has been beaned`)
54     .addFields([
55     {
56     name: "Reason",
57     value: typeof reason === 'undefined' ? '*No reason provided*' : reason
58     }
59     ])
60     ]
61     });
62     },
63     async bean(user, reason, msg) {
64     await user.send({
65     embeds: [
66     new MessageEmbed()
67     .setAuthor({
68     iconURL: msg.guild.iconURL(),
69     name: `\tYou have been beaned in ${msg.guild.name}`
70     })
71     .addFields([
72     {
73     name: "Reason",
74     value: typeof reason === 'undefined' ? '*No reason provided*' : reason
75     }
76     ])
77     ]
78     });
79     }
80     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26