added the option to disable message command (prefix)

This commit is contained in:
mmacierzanka committed 2021-08-10 02:44:08 +02:00
1 parent 0a9cdb7bde
commit 9e78438d0a
4 files changed
+14 -6

No files matched your search

+3 -2
View File
@@ -12,10 +12,10 @@ import { CommandMessageStructure, PhraseOccurrenceData } from "./types.js";
export class CommandManager {
list: Command[];
prefix: string;
prefix?: string;
argumentSeparator: string;
constructor(prefix: string, argumentSeparator?: string) {
constructor(prefix?: string, argumentSeparator?: string) {
this.list = [];
this.prefix = prefix;
this.argumentSeparator = argumentSeparator || ",";
@@ -85,6 +85,7 @@ export class CommandManager {
* @returns *CommandMessagesStructure* | *null*
*/
fetchFromMessage(message: Message): CommandMessageStructure | null {
if (!this.prefix) return null;
if (!message.author.bot && message.content.startsWith(this.prefix)) {
const content = message.content.replace(this.prefix, "");
const name = content.split(" ")[0];