1 |
|
const History = require("../src/History"); |
2 |
const MessageEmbed = require("../src/MessageEmbed"); |
const MessageEmbed = require("../src/MessageEmbed"); |
3 |
|
const { getUser } = require("../src/UserInput"); |
4 |
|
|
5 |
module.exports = { |
module.exports = { |
6 |
async handle(msg, cm) { |
async handle(msg, cm) { |
16 |
return; |
return; |
17 |
} |
} |
18 |
|
|
19 |
var user = await msg.mentions.members.first(); |
try { |
20 |
let reason; |
var user = await getUser(cm.args[0], msg); |
|
|
|
|
if (typeof cm.args[1] !== 'undefined') { |
|
|
let args = [...cm.args]; |
|
|
args.shift(); |
|
|
|
|
|
await (reason = args.join(' ')); |
|
|
} |
|
21 |
|
|
22 |
if (typeof user !== 'object') { |
console.log(user); |
|
try { |
|
|
user = await msg.guild.members.fetch(cm.args[0]); |
|
|
} |
|
|
catch(e) { |
|
23 |
|
|
24 |
|
if (!user) { |
25 |
|
throw new Error('Invalid User'); |
26 |
} |
} |
27 |
} |
} |
28 |
|
catch (e) { |
29 |
|
console.log(e); |
30 |
|
|
|
if (typeof user !== 'object') { |
|
31 |
await msg.reply({ |
await msg.reply({ |
32 |
embeds: [ |
embeds: [ |
33 |
new MessageEmbed() |
new MessageEmbed() |
39 |
return; |
return; |
40 |
} |
} |
41 |
|
|
42 |
|
let reason; |
43 |
|
|
44 |
|
if (typeof cm.args[1] !== 'undefined') { |
45 |
|
let args = [...cm.args]; |
46 |
|
args.shift(); |
47 |
|
|
48 |
|
await (reason = args.join(' ')); |
49 |
|
} |
50 |
|
|
51 |
this.bean(user, reason, msg); |
this.bean(user, reason, msg); |
52 |
|
|
53 |
await msg.reply({ |
await msg.reply({ |
64 |
}); |
}); |
65 |
}, |
}, |
66 |
async bean(user, reason, msg) { |
async bean(user, reason, msg) { |
67 |
await user.send({ |
await History.create(user.id, msg.guild, 'bean', msg.author.id, typeof reason === 'undefined' ? null : reason, async (data2) => { |
68 |
embeds: [ |
await user.send({ |
69 |
new MessageEmbed() |
embeds: [ |
70 |
.setAuthor({ |
new MessageEmbed() |
71 |
iconURL: msg.guild.iconURL(), |
.setAuthor({ |
72 |
name: `\tYou have been beaned in ${msg.guild.name}` |
iconURL: msg.guild.iconURL(), |
73 |
}) |
name: `\tYou have been beaned in ${msg.guild.name}` |
74 |
.addFields([ |
}) |
75 |
{ |
.addFields([ |
76 |
name: "Reason", |
{ |
77 |
value: typeof reason === 'undefined' ? '*No reason provided*' : reason |
name: "Reason", |
78 |
} |
value: typeof reason === 'undefined' ? '*No reason provided*' : reason |
79 |
]) |
} |
80 |
] |
]) |
81 |
|
] |
82 |
|
}); |
83 |
|
|
84 |
|
await app.logger.logBeaned(user, typeof reason === 'undefined' ? '*No reason provided*' : reason, msg.author); |
85 |
}); |
}); |
86 |
} |
} |
87 |
}; |
}; |