aoijs.mysql makes it effortless to connect your aoi.js Discord bot to a MySQL database. Leveraging the power of mysql2, you get fast and reliable database operations, perfectly suited for any aoi.js bot project.
npm install aoijs.mysql
const { AoiClient } = require('aoi.js');
const { Database } = require('aoijs.mysql'); // Import the aoijs.mysql package
const client = new AoiClient({ ... });
new Database(client, {
url: 'mysql://your_database_url...', // Replace with your MySQL server URI
tables: ['main'], // Specify your database tables # default is main
keepAoiDB: false, // Set to true to use both aoi.db and MySQL # default is false
debug: false // Set to true for debug information during development # default is false
});
see here for more client options
If you have an existing aoi.db database, you can continue to use it alongside aoijs.mysql. Just ensure that your setup is correctly configured:
const client = new AoiClient({
. . .
database: { ... }, // Your Aoi.DB options
disableAoiDB: false // Must be false to use both databases
});
new Database(client, {
. . .
keepAoiDB: true // This should be set to true
});
These 36 custom functions works like a normal existing functions ( only the name and inside the functions are different )
And these functions can only work if you set keepAoiDB
to true
Cooldown functions
$mysqlAdvanceCooldown
$mysqlChannelCooldown
$mysqlCooldown
$mysqlGetCooldownTime
$mysqlGlobalCooldown
$mysqlGuildCooldown
Leaderboard functions
$mysqlGetLeaderboardInfo
$mysqlGlobalUserLeaderBoard
$mysqlGuildLeaderBoard
$mysqlRawLeaderboard
$mysqlResetGlobalUserVar
$mysqlUserLeaderBoard
Variable functions
$mysqlCreateTemporaryVar
$mysqlDeleteVar
$mysqlGetChannelVar
$mysqlGetGlobalUserVar
$mysqlGetGuildVar
$mysqlGetMessageVar
$mysqlGetUserVar
$mysqlGetVar
$mysqlIsVariableExist
$mysqlResetGuildVar
$mysqlResetUserVar
$mysqlSetChannelVar
$mysqlSetGlobalUserVar
$mysqlSetGuildVar
$mysqlSetMessageVar
$mysqlSetUserVar
$mysqlSetVar
Other functions
$mysqlCloseTicket
$mysqlDatabasePing
$mysqlGetTimeout
$mysqlIsTicket
$mysqlNewTicket
$mysqlStopTimeout
$mysqlTimeoutList
If you have an existing aoi.db database, you can back it up or transfer its data to aoijs.mysql. Ensure that your setup is properly configured:
new Database(client, {
. . .
backup: {
enable: true, // Enable database transfer
directory: './database', // Directory where your aoi.db data is located
}
});