diff --git a/server/src/music/MusicBotManager.cpp b/server/src/music/MusicBotManager.cpp index 48acb47..9dc4bf1 100644 --- a/server/src/music/MusicBotManager.cpp +++ b/server/src/music/MusicBotManager.cpp @@ -81,19 +81,22 @@ std::shared_ptr MusicBotManager::createBot(ClientDbId owner musicBot->manager = this; musicBot->server = handle; DatabaseHelper::assignDatabaseId(handle->getSql(), handle->getServerId(), musicBot); - { + if(config::music::enabled) { lock_guard lock(this->music_bots_lock); this->music_bots.push_back(musicBot); } (LOG_SQL_CMD)(sql::command(handle->getSql(), "INSERT INTO `musicbots` (`serverId`, `botId`, `uniqueId`, `owner`) VALUES (:sid, :botId, :uid, :owner)", variable{":sid", handle->getServerId()}, variable{":botId", musicBot->getClientDatabaseId()}, variable{":uid", musicBot->getUid()}, variable{":owner", owner}).execute()); musicBot->properties()[property::CLIENT_OWNER] = owner; - handle->groups->enableCache(musicBot->getClientDatabaseId()); musicBot->setDisplayName("Im a music bot!"); musicBot->properties()[property::CLIENT_LASTCONNECTED] = duration_cast(system_clock::now().time_since_epoch()).count(); musicBot->properties()[property::CLIENT_CREATED] = duration_cast(system_clock::now().time_since_epoch()).count(); musicBot->properties()[property::CLIENT_VERSION] = "TeaMusic"; musicBot->properties()[property::CLIENT_PLATFORM] = "internal"; + + + if(!config::music::enabled) return nullptr; + handle->groups->enableCache(musicBot->getClientDatabaseId()); handle->registerClient(musicBot); { @@ -283,7 +286,7 @@ void MusicBotManager::disconnectBots() { void MusicBotManager::load_playlists() { if(!config::music::enabled) return; - + lock_guard playlist_lock(this->playlists_lock); auto sql_result = sql::command(this->ref_server()->getSql(), "SELECT `playlist_id` FROM `playlists` WHERE `serverId` = :server_id", variable{":server_id", this->ref_server()->getServerId()}).query([&](int length, string* values, string* names){ if(length != 1) return;