https://github.com/tyowk/aoijs.mysql
Implementation of MySQL in Aoi.js
https://github.com/tyowk/aoijs.mysql
aoijs database discord discordjs mysql2
Last synced: 3 months ago
JSON representation
Implementation of MySQL in Aoi.js
- Host: GitHub
- URL: https://github.com/tyowk/aoijs.mysql
- Owner: tyowk
- License: mit
- Created: 2024-07-04T07:29:19.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-02-22T08:47:16.000Z (4 months ago)
- Last Synced: 2025-03-30T15:11:14.304Z (3 months ago)
- Topics: aoijs, database, discord, discordjs, mysql2
- Language: JavaScript
- Homepage: https://npmjs.org/aoijs.mysql
- Size: 388 KB
- Stars: 2
- Watchers: 0
- Forks: 31
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# aoijs.mysql
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.
---
## Installation
```bash
npm install aoijs.mysql
```---
## Setup
```javascript
const { AoiClient } = require('aoi.js');
const { Database } = require('aoijs.mysql'); // Import the aoijs.mysql packageconst 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](https://sidorares.github.io/node-mysql2/docs/examples/connections/create-pool#createpoolconfig) for more client options---
## Keep aoi.db
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:
```javascript
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
});
```---
## FunctionsThese 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**
```bash
$mysqlAdvanceCooldown
$mysqlChannelCooldown
$mysqlCooldown
$mysqlGetCooldownTime
$mysqlGlobalCooldown
$mysqlGuildCooldown
```**Leaderboard functions**
```bash
$mysqlGetLeaderboardInfo
$mysqlGlobalUserLeaderBoard
$mysqlGuildLeaderBoard
$mysqlRawLeaderboard
$mysqlUserLeaderBoard
```**Variable functions**
```bash
$mysqlCreateTemporaryVar
$mysqlDeleteVar
$mysqlGetChannelVar
$mysqlGetGlobalUserVar
$mysqlGetGuildVar
$mysqlGetMessageVar
$mysqlGetUserVar
$mysqlGetVar
$mysqlIsVariableExist
$mysqlResetGlobalUserVar
$mysqlResetGuildVar
$mysqlResetUserVar
$mysqlSetChannelVar
$mysqlSetGlobalUserVar
$mysqlSetGuildVar
$mysqlSetMessageVar
$mysqlSetUserVar
$mysqlSetVar
```**Other functions**
```bash
$mysqlCloseTicket
$mysqlDatabasePing
$mysqlGetTimeout
$mysqlIsTicket
$mysqlNewTicket
$mysqlStopTimeout
$mysqlTimeoutList
```---
## Migrating
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:
```javascript
new Database(client, {
. . .
backup: {
enable: true, // Enable database transfer
directory: './database', // Directory where your aoi.db data is located
}
});
```
---