Extending

This page will cover how to extend the library to fit your needs

Overview

Until a proper plugin system can be written there is only one way to do this. And there is only one method worth changing.

This is the async FilterCommand.byPermission(commands, message) function.

This takes in the message object to get detail about the author, and the array of commands, and returns a Promise containing the filtered list of commands.

Here is the original function

byPermission: async (commands, message) =>
		// Filter all commands based on the permissions specified and the user's permissions
		commands.filter((command) => {
			let viable = false;
			if (command["permissions"].length > 0) {
				command["permissions"].forEach((permission) => {
					if (message.member.hasPermission(permission)) {
						viable = true;
					}
				});
			} else {
				viable = true;
			}
			return viable;
		})

Overwrite

You can overwrite the above function by assigning an asynchronous function taking the commands and message arguments to client.djsCommandControl.FilterCommands.byPermission where client is your discord.js Client object

Last updated