{"size": 1162, "ext": "js", "max_stars_repo_path": "src/config/sqlite.js", "max_stars_repo_name": "web-temps/NappyTube-Bot", "max_stars_repo_stars_event_min_datetime": "2020-10-22T17:52:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-22T17:52:55.000Z", "max_issues_repo_path": "src/config/sqlite.js", "max_issues_repo_name": "web-temps/NappyTube-Bot", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/config/sqlite.js", "max_forks_repo_name": "web-temps/NappyTube-Bot", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 33.2, "max_line_length": 152, "alphanum_fraction": 0.660929432}
const
    SQLite = require('better-sqlite3'),
    ytMusicDB = new SQLite('./SQLDATA/ytMusic.sqlite')

// [Init]
// Required in the config/login.js file,
// Called in the on('ready') event.
async function init(client) {
    await init_yt_music(client)
}




// YT_MUSIC DB
async function init_yt_music(client) {
    const table =
        ytMusicDB.prepare(
            "SELECT count(*) FROM sqlite_master WHERE type='table' AND name='guild_CurrentlyPlaying';"
        ).get();
    if (!table['count(*)']) {
        ytMusicDB.prepare(
            "CREATE TABLE guild_CurrentlyPlaying (id TEXT PRIMARY KEY, guild TEXT, playing TEXT);"
        ).run();
        ytMusicDB.prepare(
            "CREATE UNIQUE INDEX idx_playing_id ON guild_CurrentlyPlaying (id);"
        ).run();
        ytMusicDB.pragma("synchronous = 1")
        ytMusicDB.pragma("journal_mode = wal")
    }
    client.getCurrentlyPlaying = ytMusicDB.prepare("SELECT * FROM guild_CurrentlyPlaying WHERE guild = ?;")
    client.setCurrentlyPlaying = ytMusicDB.prepare("INSERT OR REPLACE INTO guild_CurrentlyPlaying (id, guild, playing) VALUES (@id, @guild, @playing);")
}

module.exports.init = init;