Skip to content

Commit

Permalink
Add support for command aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
synzen committed Jun 23, 2018
1 parent 2a1538d commit 51089e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"streamActivityURL": "",
"controllerIds": [""],
"menuColor": 5285609,
"deleteMenus": false
"deleteMenus": false,
"commandAliases": {}
},
"database": {
"uri": "mongodb://localhost/rss",
Expand Down
9 changes: 9 additions & 0 deletions util/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,20 @@ const list = {
userPerm: 'MANAGE_CHANNELS'
}
}
// Check for aliases
if (typeof config.bot.commandAliases === 'object') {
const aliases = config.bot.commandAliases
for (var alias in aliases) {
const cmd = aliases[alias]
if (cmd && list[cmd] && !list[alias]) list[alias] = { ...list[cmd], aliasFor: cmd }
}
}

exports.list = list
exports.has = name => list.hasOwnProperty(name)
exports.run = async (bot, message, name) => {
const cmdInfo = list[name]
if (cmdInfo.aliasFor) name = cmdInfo.aliasFor
if (!cmdInfo) return log.command.warning(`Could not run command "${name}" because command data does not exist`)
const botPerm = cmdInfo.botPerm
const userPerm = cmdInfo.userPerm
Expand Down

0 comments on commit 51089e8

Please sign in to comment.