mirror of
https://github.com/Syping/dtranslatebot.git
synced 2024-11-22 05:40:23 +01:00
take advantage of initializer lists
This commit is contained in:
parent
9202f7ce00
commit
2347974beb
2 changed files with 8 additions and 31 deletions
|
@ -100,8 +100,8 @@ void file::add_channel_target(dpp::snowflake guild_id, dpp::snowflake channel_id
|
||||||
bot::settings::channel channel;
|
bot::settings::channel channel;
|
||||||
cache_get_channel(channel_id, &channel);
|
cache_get_channel(channel_id, &channel);
|
||||||
channel.targets.push_back(target);
|
channel.targets.push_back(target);
|
||||||
guild->channel.push_back(std::move(channel));
|
|
||||||
cache_add_channel(guild_id, channel_id);
|
cache_add_channel(guild_id, channel_id);
|
||||||
|
guild->channel.push_back(std::move(channel));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,13 +109,8 @@ void file::add_channel_target(dpp::snowflake guild_id, dpp::snowflake channel_id
|
||||||
bot::settings::channel channel;
|
bot::settings::channel channel;
|
||||||
cache_get_channel(channel_id, &channel);
|
cache_get_channel(channel_id, &channel);
|
||||||
channel.targets.push_back(target);
|
channel.targets.push_back(target);
|
||||||
|
|
||||||
bot::settings::guild guild;
|
|
||||||
guild.id = guild_id;
|
|
||||||
guild.channel.push_back(std::move(channel));
|
|
||||||
cache_add_channel(guild_id, channel_id);
|
cache_add_channel(guild_id, channel_id);
|
||||||
|
m_dataCache.push_back({ guild_id, { std::move(channel) } });
|
||||||
m_dataCache.push_back(std::move(guild));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void file::delete_channel(dpp::snowflake guild_id, dpp::snowflake channel_id)
|
void file::delete_channel(dpp::snowflake guild_id, dpp::snowflake channel_id)
|
||||||
|
@ -154,10 +149,7 @@ void file::delete_channel(dpp::snowflake guild_id, dpp::snowflake channel_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bot::database::guild _guild;
|
m_channelCache.push_back({ guild_id, std::move(channels) });
|
||||||
_guild.id = guild_id;
|
|
||||||
_guild.channel = std::move(channels);
|
|
||||||
m_channelCache.push_back(std::move(_guild));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::filesystem::path channel_file = m_storagePath / "channel" / (std::to_string(channel_id) + ".json");
|
const std::filesystem::path channel_file = m_storagePath / "channel" / (std::to_string(channel_id) + ".json");
|
||||||
|
@ -204,11 +196,7 @@ void file::delete_channel_target(dpp::snowflake guild_id, dpp::snowflake channel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bot::settings::guild guild;
|
m_dataCache.push_back({ guild_id, { std::move(channel) } });
|
||||||
guild.id = guild_id;
|
|
||||||
guild.channel.push_back(std::move(channel));
|
|
||||||
|
|
||||||
m_dataCache.push_back(std::move(guild));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void file::delete_guild(dpp::snowflake guild_id)
|
void file::delete_guild(dpp::snowflake guild_id)
|
||||||
|
@ -360,8 +348,8 @@ void file::set_channel_source(dpp::snowflake guild_id, dpp::snowflake channel_id
|
||||||
bot::settings::channel channel;
|
bot::settings::channel channel;
|
||||||
cache_get_channel(channel_id, &channel);
|
cache_get_channel(channel_id, &channel);
|
||||||
channel.source = source;
|
channel.source = source;
|
||||||
guild->channel.push_back(std::move(channel));
|
|
||||||
cache_add_channel(guild_id, channel_id);
|
cache_add_channel(guild_id, channel_id);
|
||||||
|
guild->channel.push_back(std::move(channel));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -369,13 +357,8 @@ void file::set_channel_source(dpp::snowflake guild_id, dpp::snowflake channel_id
|
||||||
bot::settings::channel channel;
|
bot::settings::channel channel;
|
||||||
cache_get_channel(channel_id, &channel);
|
cache_get_channel(channel_id, &channel);
|
||||||
channel.source = source;
|
channel.source = source;
|
||||||
|
|
||||||
bot::settings::guild guild;
|
|
||||||
guild.id = guild_id;
|
|
||||||
guild.channel.push_back(std::move(channel));
|
|
||||||
cache_add_channel(guild_id, channel_id);
|
cache_add_channel(guild_id, channel_id);
|
||||||
|
m_dataCache.push_back({ guild_id, { std::move(channel) } });
|
||||||
m_dataCache.push_back(std::move(guild));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool file::sync()
|
bool file::sync()
|
||||||
|
@ -409,10 +392,7 @@ void file::cache_add_channel(dpp::snowflake guild_id, dpp::snowflake channel_id)
|
||||||
if (std::find(channels.begin(), channels.end(), channel_id) == channels.end())
|
if (std::find(channels.begin(), channels.end(), channel_id) == channels.end())
|
||||||
channels.push_back(channel_id);
|
channels.push_back(channel_id);
|
||||||
|
|
||||||
bot::database::guild guild;
|
m_channelCache.push_back({ guild_id, std::move(channels) });
|
||||||
guild.id = guild_id;
|
|
||||||
guild.channel = std::move(channels);
|
|
||||||
m_channelCache.push_back(std::move(guild));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void file::cache_get_channel(dpp::snowflake channel_id, bot::settings::channel *channel)
|
void file::cache_get_channel(dpp::snowflake channel_id, bot::settings::channel *channel)
|
||||||
|
|
|
@ -228,10 +228,7 @@ void settings::add_channel(const channel &channel, dpp::snowflake guild_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We will create the guild structure when it is not in memory
|
// We will create the guild structure when it is not in memory
|
||||||
guild guild;
|
m_guilds.push_back({ guild_id, { channel } });
|
||||||
guild.id = guild_id;
|
|
||||||
guild.channel.push_back(channel);
|
|
||||||
m_guilds.push_back(std::move(guild));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool settings::add_target(const target &target, dpp::snowflake guild_id, dpp::snowflake channel_id)
|
bool settings::add_target(const target &target, dpp::snowflake guild_id, dpp::snowflake channel_id)
|
||||||
|
|
Loading…
Reference in a new issue