summaryrefslogtreecommitdiff
path: root/npc/commands/discord.txt
diff options
context:
space:
mode:
Diffstat (limited to 'npc/commands/discord.txt')
-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: