Proxima Addon Development
If you are proficient in Javascript and willing to extend Proxima's functionality; you are in luck! Proxima comes with an extensive Addon handler, allowing you to easily interact with Proxima without having to edit the source code and breaking upstream. This guide will go over the basics of creating your own addon, but it is not a Discord.JS guide and will not substitute one. You are advised to be proficient in JavaScript, Node.JS and Discord.JS before creating an addon. But even if you are not, this may be a good starting point.
You will likely want to know your way around the basic files of Proxima. Utils.js, AddonHandler.js, and AddonTemplate.js are good places to start looking.
Helpful Resources for starters
- Learning JavaScript & Node.js
- MDN Docs | MDN Refrence
- CodeCademy (Free/Paid Online Course)
- Eloquent (Free Book)
- Discord.JS
Getting started
Before you start, you should check if you meet all developer requirements.
- A working Brain. 🧠
- Basic knowledge about JavaScript
- A good Integrated Development Environment (IDE)
- Knowledge about using internet
After you confirm that you meet all the requirements you can start developing your first addon.
Creating a new addon file
- Open
Proxima/data/addons
Folder. (If doesn't exist, Generate by Starting the bot or manually creating it)- Here all addons will be placed, any addons outside this folder won't be loaded.
- Create your file with extension
.js
. Example:AddonName.js
- This file will be your addon in which you will write your code.
- Addon is required to have
.js
as extension to work.
Addon Template
Now, in your addon file copy and paste the code provided below to mark your file as an addon
import { Addon } from "../../src/Modules/Structures/Handlers/Addons.js";
const addon = new Addon('hello-world', "0.0.0");
const addonConfig = {
config: {
Variable: "Hello"
},
};
/** @type {addonConfig} */
const { config } = addon.customConfig(addonConfig);
addon.setLog(`This addon has loaded!`);
addon.setExecute(async (manager) => {
console.log(`${config.Variable} world!`)
// Addon Code Goes here.
})
export default addon;
Elaborating Addon Template
Modules Required
Addon
: This is imported from AddonHandler to create recognize this file as a addon.
Others
- Variable
addon
intilizes the addon with addon's name & version. - Variable
addonConfig
is used to define addon's config if required. - Variable
config
,lang
andcommands
are return values ofaddon.customConfig
function which you can use in your addon. - Function
addon.setLog
is used to set what will addon log when it's fully loaded first time bot starts. - Function
addon.setExecute
is used to set what addon will actually run.
Creating custom configs
As you can see, there is variable addonConfig
in template addon.
You can use it to define custom configs for your addon.
These configs are generated under
Proxima/data/addon_configs/hello-world
Folder. Wherehello-world
is addon's name.
CustomConfig construction:
customConfigs
takes Object Input as shown in addonTemplate
[key: string]: Object | Array
Example Configs:
const addonConfig = {
config: {
String: "Hello",
Boolean: true,
Integer: 1,
Object: {
Hello: "World"
},
Array: ["Hello", "World"]
},
};
/** @type {addonConfig} */
const { config } = addon.customConfig(addonConfig);
Coding your Addon
You will write your addon code under setExecute
function.
manager
: This parameter is defined as Discord.Client (This client object can be not logged into discord via token.)- This is also an instance of our custom class
Proxima
- This is also an instance of our custom class
addon.setExecute(async (manager) => {
// Addon Code Goes here.
})
Creating Custom Commands
Proxima Command Handler is very advanced and allows you to define multiple things, such as command aliases, permissions, allowed channels and more. Using the config handler, you can create configurable values.
Use below code to create you custom command:
import { Command } from "../../src/Modules/Structures/Handlers/Commands.js";
new Command({
commandData: commands["Music"],
requiredPermissions: {
bot: [], // Any Discord Permission required for bot
user: [] // Any Discord Permission required for bot
},
commandData: {
Enabled: true,
Name: 'test',
Usage: 'test,
Type: 'general',
Cooldown: false,
Aliases: ['t'],
Permission: ['@everyone'],
Description: 'This is a test command.',
DeleteCommand: 'false',
Arguments: [] // SlashCommand Options
},
LegacyRun: (manager, message, args, prefixUsed, commandData) => {
message.reply("Test")
},
InteractionRun: (manager, interaction, commandData) => {
interaction.reply("Test")
}
})
SlashCommand Options
You can define options for your slash command. There are multiple options for it, which you can all use in /slash command.
Option Usage:
{
Type: "option-type",
Name: "option-name",
Description: "option-description",
Required: true,
Choices: [],
ChannelTypes: [],
},
Where
Type
: This is a option type. Avaliable types:Sub Command
- SubcommandSub Command Group
- Subcommand groupInteger
- Integer(number) optionBoolean
- Boolean(true
/false
) optionUser
- User optionChannel
- Channel option.Role
- Role optionMentionable
- Mentionable option
Name
: Name of your option.Description
: Description of your option.ChannelTypes
(Only forchannel
type): Array of allowed channel types. Avaliable types:Text
- Text ChannelVoice
- Voice ChannelCategory
- Channel categoryNews
- News channelNews Thread
- News thread channelPublic Thread
- Public thread channelPrivate Thread
- Private thread channelStage channel
- Stage channel
Required
: Defines if option is required or not.Choices
(Only forstring
/integer
/boolean
type): Array of available choices.
Slash Command Option Choices
In case of string
/integer
/boolean
type, you can define choices for your option.
Example option:
Choices: [
{
Name: "choice-name",
Value: "choice-value",
},
]
Where
Name
: Name of your choice.Value
: Value of your choice.
That's everything you should know about CommandHandler. You your Discord.js knowledge and code your command ;-)
Creating Event Listener
Since you know, how to create custom commands, it's time to create your first event listener.
To do it, follow the example code below:
import { EventListener } from "../../src/Modules/Structures/Handlers/Events.js";
new EventListener("EVENT-NAME", async (manager, ...parameters) => {
// Code for event here.
})
Where:
EVENT-NAME
: Name of your event. You can find avaliable events list here.parameters
: Object which defines your event parameters.
Example Event Listener:
new EventListener("messageCreate", async (manager, message) => {
console.log('New Message Recieved!')
})
Congratulations!
You have successfully completed addon writing guide. Now, grab your keyboard, a good IDE and start making your own addons!