]> git.lizzy.rs Git - furrybot-discord.git/blob - basic.js
0ef4f4607d209c4ecd443ce36fdce8a0356241df
[furrybot-discord.git] / basic.js
1 module.exports = {
2         help: {
3                 params: "[<command>]",
4                 help: "Display help for a commands or show list of available commands",
5                 func: (msg, [cmd], {commands}) => {
6                         if (cmd) {
7                                 let def = commands[cmd]
8
9                                 if (def)
10                                         msg.reply(`!${cmd}${def.params ? " " + def.params : ""}: ${def.help || "No description given"}`)
11                                 else
12                                         msg.reply(`Invalid command: ${cmd}`)
13                         } else {
14                                 msg.reply("Available commands:\n\t" + Object.keys(commands).join("\n\t"))
15                         }
16                 },
17         },
18         accept: {
19                 help: "Accept a request",
20                 func: (msg, _, {requests}) => {
21                         const id =      msg.author.id
22                         const req = requests[id]
23
24                         if (req) {
25                                 delete requests[id]
26                                 req.func(msg, req.origin)
27                         } else {
28                                 msg.reply("Nothing to accept")
29                         }
30                 }
31         },
32         deny: {
33                 help: "Deny a request",
34                 func: (msg, _, {requests}) => {
35                         const id = msg.author.id
36                         const req = requests[id]
37
38                         if (req) {
39                                 delete requests[id]
40                                 msg.reply(`Denied request from <@!${req.origin}>`)
41                         } else {
42                                 msg.reply("Nothing to deny")
43                         }
44                 }
45         }
46 }