From 5492ad8860e9a9e6989f241f095f3e6f25fe5769 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sat, 15 May 2021 22:28:55 -0300 Subject: Fix bugs --- npc/commands/discord.txt | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/npc/commands/discord.txt b/npc/commands/discord.txt index 0f4f7e8c7..21e675a45 100644 --- a/npc/commands/discord.txt +++ b/npc/commands/discord.txt @@ -44,9 +44,9 @@ OnCall: // Search on cache .@key$=str(getcharid(3)); - .@m$ = htget(.discmem$, .@key$, "Not found"); + .@discord$ = htget(.discmem, .@key$, "Not found"); - if (.@m$ == "Not found") { + if (.@discord$ == "Not found") { // Only do SQL query if not in cache .@nb = query_sql("select `discord_name` from `discord` WHERE `account_id`='"+getcharid(3)+"' limit 1", .@discord$); // Override default behavior @@ -55,14 +55,7 @@ OnCall: .@link=false; } // Add to Cache - htput(.discmem$, str(getcharid(3)), .@discord$); - } - - - // Doublecheck it worked properly - if (.@discord$ == "") { - .@discord$="Not Linked"; - .@link=false; + htput(.discmem, str(getcharid(3)), .@discord$); } do @@ -86,7 +79,7 @@ OnCall: if (.@discord$ == "") close; mes ""; - // Run SQL query + // 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'", escape_sql(.@discord$), getcharid(3))); @@ -102,7 +95,7 @@ OnCall: // Send to API and update cache api_send(API_DISCORD, .@p$); - htput(.discmem$, str(getcharid(3)), .@discord$); + htput(.discmem, str(getcharid(3)), .@discord$); // Prevent changing for the next 3 days DISCTRL=gettimeparam(GETTIME_DAYOFMONTH)+3; @@ -116,7 +109,7 @@ OnCall: // Prevent setting a new linking right away DISCTRL=gettimeparam(GETTIME_DAYOFMONTH)+1; // Update Cache - htput(.discmem$, str(getcharid(3)), ""); + htput(.discmem, str(getcharid(3)), ""); // TODO: Remove Adventurer role? logmes(sprintf("User %d \"%s\" unlinked Discord account!", getcharid(3), strcharinfo(0))); break; @@ -127,7 +120,7 @@ OnCall: OnInit: bindatcmd "discord", "@discord::OnCall", 0, 0, 1; - .discmem$ = htnew; + .discmem = htnew; end; } -- cgit v1.2.3-60-g2f50