summaryrefslogtreecommitdiff
path: root/npc/commands
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2022-05-08 23:36:06 -0300
committerJesusaves <cpntb1@ymail.com>2022-05-08 23:36:06 -0300
commit8d1ae4685fd560c0de3fea9268787acf536d001b (patch)
tree73863a5afb1289bf036d2ae70d2e5ef1b17308c2 /npc/commands
parent5d08e13ca37feae95a3beddf8dc29041323ee115 (diff)
downloadserverdata-8d1ae4685fd560c0de3fea9268787acf536d001b.tar.gz
serverdata-8d1ae4685fd560c0de3fea9268787acf536d001b.tar.bz2
serverdata-8d1ae4685fd560c0de3fea9268787acf536d001b.tar.xz
serverdata-8d1ae4685fd560c0de3fea9268787acf536d001b.zip
Modernize @discord so you can use it once per day
Diffstat (limited to 'npc/commands')
-rw-r--r--npc/commands/discord.txt24
1 files changed, 18 insertions, 6 deletions
diff --git a/npc/commands/discord.txt b/npc/commands/discord.txt
index e411de419..963acb4b3 100644
--- a/npc/commands/discord.txt
+++ b/npc/commands/discord.txt
@@ -23,7 +23,7 @@ OnCall:
}
// Bot cannot (or should not) alter staff data
- if (is_staff()) {
+ if (is_staff() && !is_admin()) {
dispbottom l("Staff is not allowed to use this command.");
end;
}
@@ -90,17 +90,29 @@ OnCall:
// Run SQL query (will halt execution on dupe)
if (.@link) {
- query_sql(sprintf("UPDATE `discord` SET `discord_name` = '%s', `verified` = '0', `discord_id` = '' WHERE `account_id`='%d'",
+ if ($@HAS_API) {
+ apiasync("SQL", sprintf("UPDATE `discord` SET `discord_name` = '?1', `verified` = '0', `discord_id` = '' WHERE `account_id`='%d'", getcharid(3)));
+ apiasync("SAD1", .@discord$);
+ apiasync("SQLRUN", "");
+ } else {
+ query_sql(sprintf("UPDATE `discord` SET `discord_name` = '%s', `verified` = '0', `discord_id` = '' WHERE `account_id`='%d'",
escape_sql(.@discord$), getcharid(3)));
+ }
} else {
- query_sql(sprintf("INSERT INTO `discord` (`discord_name`, `verified`, `discord_id`, `account_id`) VALUES ('%s', '0', '', '%d')",
+ if ($@HAS_API) {
+ apiasync("SQL", sprintf("INSERT INTO `discord` (`discord_name`, `verified`, `discord_id`, `account_id`) VALUES ('?1', '0', '', '%d')", getcharid(3)));
+ apiasync("SAD1", .@discord$);
+ apiasync("SQLRUN", "");
+ } else {
+ query_sql(sprintf("INSERT INTO `discord` (`discord_name`, `verified`, `discord_id`, `account_id`) VALUES ('%s', '0', '', '%d')",
escape_sql(.@discord$), getcharid(3)));
+ }
}
// Encode JSON data
.@p$=json_encode("name", strcharinfo(0),
"accId", getcharid(3),
- "disc", .@discord$);
+ "disc", escape_sql(.@discord$));
// Send to API and update cache
api_send(API_DISCORD, .@p$);
@@ -108,9 +120,9 @@ OnCall:
consoleinfo("%s linked discord account \"%s\".", strcharinfo(0), .@discord$);
// Prevent changing for the next 3 days
- DISCTRL=gettimeparam(GETTIME_DAYOFMONTH)+2;
+ DISCTRL=gettimeparam(GETTIME_DAYOFMONTH)+1;
mesc l("Linking requested."), 1;
- mesc l("This setting can only be changed every %d days.", 2), 1;
+ mesc l("This setting can only be changed every %d days.", 1), 1;
break;
/////////////////////////////////////////////////////////////////////
case 2: