Fixed that music bots now not appear anymore...

This commit is contained in:
WolverinDEV 2020-03-20 01:05:39 +01:00
parent e5f7b3bd32
commit c74804ccf5

View File

@ -81,19 +81,22 @@ std::shared_ptr<server::MusicClient> 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<seconds>(system_clock::now().time_since_epoch()).count();
musicBot->properties()[property::CLIENT_CREATED] = duration_cast<seconds>(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;