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

Contents of /trunk/commands/bean.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (show annotations)
Mon Jul 29 17:28:16 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: text/javascript
File size: 2508 byte(s)
More improvements
1 const History = require("../src/History");
2 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 = 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 this.bean(user, reason, msg);
50
51 await msg.reply({
52 embeds: [
53 new MessageEmbed()
54 .setDescription(`The user ${user.user.tag} has been beaned`)
55 .addFields([
56 {
57 name: "Reason",
58 value: typeof reason === 'undefined' ? '*No reason provided*' : reason
59 }
60 ])
61 ]
62 });
63 },
64 async bean(user, reason, msg) {
65 await History.create(user.id, msg.guild, 'bean', msg.author.id, async (data2) => {
66 await user.send({
67 embeds: [
68 new MessageEmbed()
69 .setAuthor({
70 iconURL: msg.guild.iconURL(),
71 name: `\tYou have been beaned in ${msg.guild.name}`
72 })
73 .addFields([
74 {
75 name: "Reason",
76 value: typeof reason === 'undefined' ? '*No reason provided*' : reason
77 }
78 ])
79 ]
80 });
81
82 await app.logger.logBeaned(user, typeof reason === 'undefined' ? '*No reason provided*' : reason, msg.author);
83 });
84 }
85 };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26