summaryrefslogtreecommitdiff
path: root/npc/commands/discord.txt
blob: 2f7feb494c85ff39ae1936cdfbe505c50dfa1da0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// 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;
}