-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Add]: Database for
language-config
command
- Loading branch information
1 parent
606ea9e
commit 07cb989
Showing
12 changed files
with
137 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,7 @@ | |
"xstddef": "cpp", | ||
"xtr1common": "cpp", | ||
"xtree": "cpp", | ||
"xutility": "cpp" | ||
"xutility": "cpp", | ||
"*.rh": "cpp" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (C) 2023 harshfeudal | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see https://www.gnu.org/licenses/. | ||
*/ | ||
|
||
#include "../cmd_lists.h" | ||
|
||
void config_language(dpp::cluster& client, const dpp::slashcommand_t& event) | ||
{ | ||
const auto selectLanguage = std::get<std::string>(event.get_parameter("language")); | ||
HarshieDatabase& database = HarshieDatabase::getInstance(); | ||
|
||
auto recordUser = fmt::format("'{}'", event.command.usr.id); | ||
auto searchUser = database.findRecord("language_config", "id=" + recordUser); | ||
|
||
std::string setLanguage = "en-us"; | ||
|
||
if (selectLanguage == "english") | ||
{ | ||
if (searchUser) | ||
database.deleteData("language_config", "id=" + searchUser); | ||
} | ||
else if (selectLanguage == "japanese") | ||
{ | ||
if (searchUser) | ||
database.deleteData("language_config", "id=" + searchUser); | ||
|
||
setLanguage = "ja-jp"; | ||
database.insertData("language_config", searchUser + ", '" + setLanguage + "'"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "db_create.h" | ||
|
||
void HarshieCreateDatabase::languageData() | ||
{ | ||
try | ||
{ | ||
database.createTable("language_config", "id TEXT, language TEXT"); | ||
fmt::print("[{}] language_config table created!\n", dpp::utility::current_date_time()); | ||
} | ||
catch(...) | ||
{ | ||
fmt::print("[{}] Failed to create language_config table\n", dpp::utility::current_date_time()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <dpp/dpp.h> | ||
#include <spdlog/spdlog.h> | ||
|
||
#include "database.h" | ||
|
||
class HarshieCreateDatabase | ||
{ | ||
public: | ||
void languageData(); | ||
|
||
private: | ||
HarshieDatabase& database = HarshieDatabase::getInstance(); | ||
}; |