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 Aoi.MySQL package
const client = new AoiClient({
token: 'YOUR_TOKEN',
prefix: 'YOUR_PREFIX',
intents: ['Guilds', 'GuildMessages', 'GuildMembers', 'MessageContent'],
events: ['onMessage', 'onInteractionCreate'],
database: { ... }, // Your Aoi.DB options
disableAoiDB: true | false // Set to true if using only Aoi.MySQL
});
// Initialize the MySQL Database
new Database(client, {
url: 'mysql://YOUR_DATABASE_URL', // Replace with your MySQL server URI
tables: ['main'], // Specify your database tables
keepAoiDB: true | false, // Set to true to use both aoi.db and MySQL
debug: true | false // Set to true for debug information during development
});
// Client variables setup
client.variables({
key: 'value' // Define client variables here
});
// Continue with the rest of your bot's setup...
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({
// ... Your client options
database: { ... }, // Your Aoi.DB options
disableAoiDB: false // Must be false to use both databases
});
// Initialize the MySQL Database
new Database(client, {
// ... Your MySQL database options
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
$mysqlAdvanceCooldown
$mysqlChannelCooldown
$mysqlCloseTicket
$mysqlCooldown
$mysqlCreateTemporaryVar
$mysqlDatabasePing
$mysqlDeleteVar
$mysqlGetChannelVar
$mysqlGetCooldownTime
$mysqlGetGlobalUserVar
$mysqlGetGuildVar
$mysqlGetLeaderboardInfo
$mysqlGetMessageVar
$mysqlGetTimeout
$mysqlGetUserVar
$mysqlGetVar
$mysqlGlobalCooldown
$mysqlGlobalUserLeaderBoard
$mysqlGuildCooldown
$mysqlGuildLeaderBoard
$mysqlIsTicket
$mysqlIsVariableExist
$mysqlNewTicket
$mysqlRawLeaderboard
$mysqlResetGlobalUserVar
$mysqlResetGuildVar
$mysqlResetUserVar
$mysqlSetChannelVar
$mysqlSetGlobalUserVar
$mysqlSetGuildVar
$mysqlSetMessageVar
$mysqlSetUserVar
$mysqlSetVar
$mysqlStopTimeout
$mysqlTimeoutList
$mysqlUserLeaderBoard
If you're considering transferring your aoi.db database to MySQL, 🚫 Migration Is Not Currently Possible!