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

Annotation of /trunk/commands/addsnippet.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 27 - (hide annotations)
Mon Jul 29 17:28:16 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: text/javascript
File size: 1381 byte(s)
Added -send command and added support of attachments in snippets
1 rakin 5 const MessageEmbed = require("../src/MessageEmbed");
2    
3     module.exports = {
4     async handle(msg, cm) {
5     if (cm.args[1] === undefined) {
6     await msg.reply({
7     embeds: [
8     new MessageEmbed()
9     .setColor('#f14a60')
10     .setDescription('This command requires at least 2 arguments.')
11     ]
12     });
13    
14     return;
15     }
16    
17     let args = [...cm.args];
18     args.shift();
19     let content = args.join(' ');
20 rakin 27
21     let files = msg.attachments.map(a => {
22     return {
23     name: a.name,
24     attachment: a.attachment,
25     proxyURL: a.proxyURL,
26     }
27     });
28    
29     console.log(files);
30 rakin 5
31 rakin 27 let status = await cm.snippetManager.create(msg.guild.id, cm.args[0], content, files);
32 rakin 5
33     if (status) {
34     await msg.reply({
35     embeds: [
36     new MessageEmbed()
37     .setDescription('New snippet added successfully!')
38     ]
39     });
40     }
41     else {
42     await msg.reply({
43     embeds: [
44     new MessageEmbed()
45     .setColor('#f14a60')
46     .setDescription('A snippet already exists with that name.')
47     ]
48     });
49     }
50     }
51     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26