From 812fca8174758dc57aca8d325a8416dc142ab0af Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Sun, 14 Mar 2021 20:30:09 -0600 Subject: [PATCH] Command: add guildOnly flag --- src/lib/command.js | 1 + src/lib/commandDispatcher.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/lib/command.js b/src/lib/command.js index 54e000f..10805f2 100644 --- a/src/lib/command.js +++ b/src/lib/command.js @@ -4,6 +4,7 @@ class Command { this.aliases = []; this.helpText = "No description provided."; this.category = "unsorted"; + this.guildOnly = false; } addAlias(alias) { diff --git a/src/lib/commandDispatcher.js b/src/lib/commandDispatcher.js index f645658..a7ab4d8 100644 --- a/src/lib/commandDispatcher.js +++ b/src/lib/commandDispatcher.js @@ -37,6 +37,10 @@ async function runCommand(msg, cmd, line, args) { return "No\n\nSent from my iPhone."; } + if (cmdObj.guildOnly && !msg.channel.guild) { + return "This command can only be used in guilds."; + } + try { const ret = cmdObj.callback(msg, line, ...args); if (ret instanceof Promise) {