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

Annotation of /trunk/commands/addsnippet.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5 - (hide annotations)
Mon Jul 29 17:28:11 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: text/javascript
File size: 1120 byte(s)
Added base commands
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    
21     let status = cm.snippetManager.create(cm.args[0], content);
22    
23     if (status) {
24     await msg.reply({
25     embeds: [
26     new MessageEmbed()
27     .setDescription('New snippet added successfully!')
28     ]
29     });
30     }
31     else {
32     await msg.reply({
33     embeds: [
34     new MessageEmbed()
35     .setColor('#f14a60')
36     .setDescription('A snippet already exists with that name.')
37     ]
38     });
39     }
40     }
41     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26