Skip to main content

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

NameTypeDescription
settingsFrameworkSettingsThe settings to use for the framework.
callback?(framework: any) => voidA callback to be called when the framework has finished initializing.

Defined in

ZumitoFramework.ts:117

Properties

app

Private app: any

The ExpressJS app instance.

See

https://expressjs.com/en/4x/api.html#app

Defined in

ZumitoFramework.ts:110


client

Private client: Client<boolean>

The discord client instance.

See

https://discord.js.org/#/docs/main/stable/class/Client

Defined in

ZumitoFramework.ts:56


commands

Private commands: Map<string, Command>

The commands loaded in the framework.

See

Command

Defined in

ZumitoFramework.ts:75


database

Private database: any

The canario database schema instance.

See

https://www.npmjs.com/package/canario

Defined in

ZumitoFramework.ts:103


events

Private events: Map<string, FrameworkEvent>

The events loaded in the framework.

See

FrameworkEvent

Defined in

ZumitoFramework.ts:82


models

Private models: DatabaseModel[]

The database models loaded in the framework.

Defined in

ZumitoFramework.ts:96


modules

Private modules: Map<string, Module>

The modules loaded in the framework.

Defined in

ZumitoFramework.ts:68


routes

routes: any

Defined in

ZumitoFramework.ts:90


settings

Private settings: FrameworkSettings

The settings for the framework.

Defined in

ZumitoFramework.ts:62


translations

Private translations: TranslationManager

The Translation Manager for the framework.

See

TranslationManager

Defined in

ZumitoFramework.ts:89

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

NameType
guildIdstring

Returns

Promise<unknown>

Defined in

ZumitoFramework.ts:442


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

ZumitoFramework.ts:146


initializeDatabase

Private initializeDatabase(): Promise<void>

Returns

Promise<void>

Defined in

ZumitoFramework.ts:155


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

ZumitoFramework.ts:338


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

NameType
memberGuildMember
channelTextChannel
permissionbigint

Returns

Promise<boolean>

Defined in

ZumitoFramework.ts:409


refreshSlashCommands

refreshSlashCommands(): Promise<void>

Returns

Promise<void>

Defined in

ZumitoFramework.ts:462


registerModule

Private registerModule(modulesFolder, moduleName, module?): Promise<void>

Parameters

NameType
modulesFolderany
moduleNameany
module?any

Returns

Promise<void>

Defined in

ZumitoFramework.ts:267


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

ZumitoFramework.ts:229


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

ZumitoFramework.ts:183


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

NameType
commandLineany

Returns

any

Defined in

ZumitoFramework.ts:362