1 |
rakin |
46 |
const CommandManager = require("../src/CommandManager"); |
2 |
|
|
|
3 |
|
|
module.exports = async (command, msg_id, channel_id, guild_id) => { |
4 |
|
|
try { |
5 |
|
|
const guild = await app.client.guilds.cache.get(guild_id); |
6 |
|
|
|
7 |
|
|
if (guild) { |
8 |
|
|
const channel = await guild.channels.fetch(channel_id); |
9 |
|
|
|
10 |
|
|
if (channel) { |
11 |
|
|
const msg = await channel.messages.fetch(msg_id); |
12 |
|
|
|
13 |
|
|
if (msg) { |
14 |
|
|
const realMessage = await app.msg; |
15 |
|
|
app.msg = await msg; |
16 |
|
|
|
17 |
|
|
const cm = await new CommandManager(null, false, false); |
18 |
|
|
|
19 |
|
|
cm.snippetManager = app.commandManager.snippetManager; |
20 |
|
|
cm.commands = app.commandManager.commands; |
21 |
|
|
cm.commandNames = app.commandManager.commandNames; |
22 |
|
|
|
23 |
|
|
await cm.setMessage(msg); |
24 |
|
|
|
25 |
|
|
cm.argv = command.split(' '); |
26 |
|
|
cm.args = [...cm.argv]; |
27 |
|
|
cm.args.shift(); |
28 |
|
|
|
29 |
|
|
cm.commandName = cm.argv[0]; |
30 |
|
|
|
31 |
|
|
const valid = await cm.valid(); |
32 |
|
|
const has = await cm.has(); |
33 |
|
|
const snippet = await cm.snippet(); |
34 |
|
|
const allowed = await cm.verify(); |
35 |
|
|
|
36 |
|
|
if (valid && has && allowed) { |
37 |
|
|
await cm.exec(); |
38 |
|
|
} |
39 |
|
|
else if (valid && snippet !== undefined) { |
40 |
|
|
await message.channel.send({ |
41 |
|
|
content: snippet.content, |
42 |
|
|
files: snippet.files.map(f => { |
43 |
|
|
return { |
44 |
|
|
attachment: path.resolve(__dirname, '..', 'storage', f) |
45 |
|
|
} |
46 |
|
|
}) |
47 |
|
|
}); |
48 |
|
|
} |
49 |
|
|
else if (valid && !has) { |
50 |
|
|
await cm.notFound(); |
51 |
|
|
} |
52 |
|
|
else if (valid && has && !allowed) { |
53 |
|
|
await cm.notAllowed(); |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
app.msg = await realMessage; |
57 |
|
|
} |
58 |
|
|
} |
59 |
|
|
} |
60 |
|
|
} |
61 |
|
|
catch (e) { |
62 |
|
|
console.log(e); |
63 |
|
|
} |
64 |
|
|
}; |