This PR's main focus is merging "events" and "commands" into a single concept: extensions.
Extensions are based on the discord.py's command extension in that they are files with an exported setup(client) function. They can be loaded and unloaded at will, and are based on files with an exported setup() function.
All commands have been made into extensions.
Some events have been moved to index.ts
Another idea borrowed from discord.py's practices is making the Discord Client instance the "center of truth". As a primer, this PR extends Discord.js's Client to hold loaded extensions and registered commands, as well as adding manage both. This allows us to use the Client as a registry of things related to it, as opposed to how before, for example, command files were read from the commands/ folder on each use, using a function defined in utils.js.
Yet another concept taken is the idea of a Context object, which holds fields related to the command execution context (e.g message, command executed, argument specified, etc.). This Context object is passed on to the execute() function of each command when it is executed.
This helps keep execute() arguments clean, while also allowing for extensibility without much hassle.
This PR also:
Moves database logic to its own file.
Makes TypeScript target ES2020 so we can make use of the latest EcmaScript features.
Renames config.json.example to config.example.json to aid IDEs on highlighting the file.
This PR's main focus is merging "events" and "commands" into a single concept: extensions. Extensions are based on the discord.py's command extension in that they are files with an exported
setup(client)
function. They can be loaded and unloaded at will, and are based on files with an exported setup() function.Another idea borrowed from discord.py's practices is making the Discord Client instance the "center of truth". As a primer, this PR extends Discord.js's Client to hold loaded extensions and registered commands, as well as adding manage both. This allows us to use the Client as a registry of things related to it, as opposed to how before, for example, command files were read from the commands/ folder on each use, using a function defined in utils.js.
Yet another concept taken is the idea of a Context object, which holds fields related to the command execution context (e.g message, command executed, argument specified, etc.). This Context object is passed on to the
execute()
function of each command when it is executed. This helps keepexecute()
arguments clean, while also allowing for extensibility without much hassle.This PR also: