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

Annotation of /trunk/commands/kick.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (hide annotations)
Mon Jul 29 17:28:16 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: text/javascript
File size: 2587 byte(s)
More improvements
1 rakin 25 const History = require("../src/History");
2 rakin 5 const MessageEmbed = require("../src/MessageEmbed");
3    
4     module.exports = {
5     async handle(msg, cm) {
6     if (typeof cm.args[0] === 'undefined') {
7     await msg.reply({
8     embeds: [
9     new MessageEmbed()
10     .setColor('#f14a60')
11     .setDescription(`This command requires at least one argument.`)
12     ]
13     });
14    
15     return;
16     }
17    
18     var user = await msg.mentions.members.first();
19     let reason = {};
20    
21     if (typeof cm.args[1] !== 'undefined') {
22     let args = [...cm.args];
23     args.shift();
24    
25     await (reason.reason = args.join(' '));
26     }
27    
28     if (typeof user !== 'object') {
29     try {
30     user = await msg.guild.members.fetch(cm.args[0]);
31     }
32     catch(e) {
33    
34     }
35     }
36    
37     if (typeof user !== 'object') {
38     await msg.reply({
39     embeds: [
40     new MessageEmbed()
41     .setColor('#f14a60')
42     .setDescription(`Invalid user given.`)
43     ]
44     });
45    
46     return;
47     }
48    
49     try {
50     if (typeof user.kickable === 'boolean' && user.kickable === false) {
51     await msg.reply({
52     embeds: [
53     new MessageEmbed()
54     .setColor('#f14a60')
55     .setDescription(`This user isn't kickable.`)
56     ]
57     });
58    
59     return;
60     }
61    
62 rakin 25
63     await History.create(user.id, msg.guild, 'kick', msg.author.id, async (data2) => {
64     await user.kick(reason);
65     });
66 rakin 5 }
67     catch(e) {
68     console.log(e);
69    
70     await msg.reply({
71     embeds: [
72     new MessageEmbed()
73     .setColor('#f14a60')
74     .setDescription(`I don't have enough permission to kick this user.`)
75     ]
76     });
77    
78     return;
79     }
80    
81     await msg.reply({
82     embeds: [
83     new MessageEmbed()
84     .setDescription(`The user ${user.user.tag} has been kicked`)
85     .addFields([
86     {
87     name: "Reason",
88     value: typeof reason.reason === 'undefined' ? '*No reason provided*' : reason.reason
89     }
90     ])
91     ]
92     });
93     }
94     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26