summaryrefslogblamecommitdiff
path: root/npc/commands/discord.txt
blob: 2f7feb494c85ff39ae1936cdfbe505c50dfa1da0 (plain) (tree)





















                                                                                           
                                                                                                                   
















                                                                                      
                                                  
                       


                                                                                                                          
                                                                                                     

                      
                                                                                         











                                                     
// TMW-2 Script.
// Author:
//    Jesusalva
//    LawnCable
// Notes:
//    Controls `discord` table with @discord command.
//    Only useful for TMW2-Discord integration.

-	script	@discord	32767,{
    end;

OnCall:
    // Anti-Flood System
    if (@discord) {
        mesc l("You already ran this command today. Please try again at a later time."), 1;
        close;
    }

    if (!validatepin())
        close;

    @discord=1;
	.@nb = query_sql("select `discord_name` from `discord` WHERE `account_id`='"+getcharid(3)+"'", .@discord$);


    do
    {
        mesn "Lawn Cable";
        mesq l("Current linked Discord account: @@", .@discord$);
        next;
        select
            l("Change Linked Discord Account"),
            l("Disconnect"),
            l("Quit");

        switch (@menu) {
            case 1:
                mesc l("Please insert your Discord ID, on the following format: "), 1;
                mesc l("Usename#0000"), 2;
                input .@discord$;
                .@discord$=escape_sql(.@discord$);
                mes "";
                query_sql("UPDATE `discord` SET `discord_name` = '"+.@discord$+"' WHERE `account_id`='"+getcharid(3)+"'");
                query_sql("UPDATE `discord` SET `verified` = '0' WHERE `account_id`='"+getcharid(3)+"'");
                query_sql("UPDATE `discord` SET `discord_id` = '' WHERE `account_id`='"+getcharid(3)+"'");
                mesc l("You must send ##B/verify##b to Discord bot for the linking be complete."), 1;
                break;
            case 2:
                query_sql("DELETE FROM `discord` WHERE `account_id`='"+getcharid(3)+"'");
                .@discord$="";
                break;
        }

    } while (@menu != 3);
    close;

OnInit:
    bindatcmd "discord", "@discord::OnCall", 0, 0, 1;
    end;
}