Class: ZumitoFramework
Description
The main class of the framework.
Example
new ZumitoFramework({
discordClientOptions: {
intents: 3276799,
token: 'XXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
clientId: 755XXXXXXXXXX98,
},
defaultPrefix: process.env.BOTPREFIX || "z-",
mongoQueryString: mongodb://XXXXXX,
logLevel: parseInt(process.env.LOGLEVEL || "3"),
});
Constructors
constructor
• new ZumitoFramework(settings
, callback?
)
Parameters
Name | Type | Description |
---|---|---|
settings | FrameworkSettings | The settings to use for the framework. |
callback? | (framework : any ) => void | A callback to be called when the framework has finished initializing. |
Defined in
Properties
app
• Private
app: any
The ExpressJS app instance.
See
https://expressjs.com/en/4x/api.html#app
Defined in
client
• Private
client: Client
<boolean
>
The discord client instance.
See
https://discord.js.org/#/docs/main/stable/class/Client
Defined in
commands
• Private
commands: Map
<string
, Command
>
The commands loaded in the framework.
See
Defined in
database
• Private
database: any
The canario database schema instance.
See
https://www.npmjs.com/package/canario
Defined in
events
• Private
events: Map
<string
, FrameworkEvent
>
The events loaded in the framework.
See
Defined in
models
• Private
models: DatabaseModel
[]
The database models loaded in the framework.
Defined in
modules
• Private
modules: Map
<string
, Module
>
The modules loaded in the framework.
Defined in
routes
• routes: any
Defined in
settings
• Private
settings: FrameworkSettings
The settings for the framework.
Defined in
translations
• Private
translations: TranslationManager
The Translation Manager for the framework.
See
Defined in
Methods
getGuildSettings
▸ getGuildSettings(guildId
): Promise
<unknown
>
Gets the guild settings from the database. If the guild is not in the database, it is added.
Async
Example
// returns the guild settings
getGuildSettings('123456789012345678');
Example
// returns the guild settings
getGuildSettings(guild.id);
Example
// returns the guild settings
getGuildSettings(message.guild.id);
Example
// returns the guild settings
getGuildSettings(interaction.guild.id);
Example
// returns the guild settings
getGuildSettings(interaction.guildId);
Parameters
Name | Type |
---|---|
guildId | string |
Returns
Promise
<unknown
>
Defined in
initialize
▸ Private
initialize(): Promise
<void
>
Initializes the framework. Connects to the MongoDB database, starts the Discord client, and runs API server. It also loads the modules from the project's modules folder.
Async
Returns
Promise
<void
>
Defined in
initializeDatabase
▸ Private
initializeDatabase(): Promise
<void
>
Returns
Promise
<void
>
Defined in
initializeDiscordClient
▸ Private
initializeDiscordClient(): void
Initializes the Discord client using the Discord.js library. Logs in to the Discord API using the provided token and logs a message when the client is ready.
Returns
void
Defined in
memberHasPermission
▸ memberHasPermission(member
, channel
, permission
): Promise
<boolean
>
Checks if a member has a permission in a channel.
Example
// returns true if the member has the permission
memberHasPermission(member, channel, Permissions.FLAGS.MANAGE_MESSAGES);
Example
// returns true if the member has the permission
memberHasPermission(member, channel, Permissions.FLAGS.MANAGE_MESSAGES | Permissions.FLAGS.MANAGE_CHANNELS);
Example
Parameters
Name | Type |
---|---|
member | GuildMember |
channel | TextChannel |
permission | bigint |
Returns
Promise
<boolean
>
Defined in
refreshSlashCommands
▸ refreshSlashCommands(): Promise
<void
>
Returns
Promise
<void
>
Defined in
registerModule
▸ Private
registerModule(modulesFolder
, moduleName
, module?
): Promise
<void
>
Parameters
Name | Type |
---|---|
modulesFolder | any |
moduleName | any |
module? | any |
Returns
Promise
<void
>
Defined in
registerModules
▸ Private
registerModules(): Promise
<void
>
Register all modules in the 'modules' folder.
Scans the specified folder for module files and calls the registerModule
method for each file.
Also, it loads the baseModule in the framework.
Returns
Promise
<void
>
Defined in
startApiServer
▸ startApiServer(): void
Initializes and starts the API server using ExpressJS. Sets up middleware, routes, and error handling for the server.
Returns
void
Defined in
splitCommandLine
▸ Static
Private
splitCommandLine(commandLine
): any
From a command-line string, returns an array of parameters.
Static
Example
// returns ['a', 'b', 'c']
splitCommandLine('a b c');
Example
// returns ['a', 'b c']
splitCommandLine('a "b c"');
Parameters
Name | Type |
---|---|
commandLine | any |
Returns
any