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