1
0
Fork 0
mirror of https://gitlab.com/niansa/discordlistforbots.git synced 2025-03-06 20:49:22 +01:00

Fixed bot owner username invalidating on moderator edit

This commit is contained in:
niansa 2021-01-15 13:30:10 +01:00
parent 61e5c2ad6c
commit 5605f89a4d
2 changed files with 7 additions and 4 deletions

View file

@ -275,11 +275,14 @@ void views::botedit(const HttpRequestPtr& req, std::function<void (const HttpRes
[this, sessionData, refresh, bot, final] (const orm::Result &) {
if (refresh) {
auto app_id = bot.app_id;
getUser(app_id, [this, sessionData, app_id, final] (const Json::Value& botuser) {
auto owner_id = bot.owner_id;
getUser(app_id, [this, sessionData, app_id, owner_id, final] (const Json::Value& botuser) {
if (not botuser.empty()) {
db->execSqlAsync("UPDATE bots SET name = '"+dbEsc(botuser["username"].asString())+"',"
"avatar_url = '"+dbEsc(botuser["avatar_url"].asString())+"',"
"owner = '"+dbEsc(sessionData->discord_fullname())+"' "
"avatar_url = '"+dbEsc(botuser["avatar_url"].asString())+
std::string(sessionData->discord_id==owner_id?
("',owner = '"+dbEsc(sessionData->discord_fullname())+"' "):
("' "))+
"WHERE app_id = '"+std::to_string(app_id)+"'",
[final] (const orm::Result &) {
final();

View file

@ -10,7 +10,7 @@
<p class="title">Discordlist for Bots</p>
<p>Find a lot of bots that will be useful to your server</p>
<%c++ if (@@.get<bool>("authed")) {%>
<%c++ if (justMine) {%>
<%c++ if (justMine or modView) {%>
<a class="special-button" href="@all">All bots</a>
<%c++ } else {%>
<a class="special-button" href="@me">My bots</a>