#Need help for my Discord Linking

1 messages · Page 1 of 1 (latest)

simple grotto
#

How to fix this skript cause have 3 errors, what do I need to change on this errors?

zealous flameBOT
#

Lias0_0 suggests that you read this embed @simple grotto

Formatting Code In Discord
Why?

Code blocks make it easier for helpers to identify potential errors -- help them help you!

The Format

```vb
on chat:
broadcast "This is how you format code!"
```

How It Looks
on chat:
    broadcast "This is how you format code!"
Extra Info

On US keyboards, the grave character (`) is located above the tab key on the top left of the keyboard

simple grotto
#

This is my skript:

# FUNCTION: Generate a linking code
# ==========================================
function generateCode(p: player) :: string:
    set {_code} to random integer between 11111 and 99999
    return "%{_code}%"



# ==========================================
# ON PLAYER JOIN — Require Discord Link
# ==========================================
on join:
    set {_uuid} to uuid of player

    if {linked::%{_uuid}%} is not set:
        set {_code} to generateCode(player)
        set {link::code::%{_uuid}%} to {_code}

        kick player due to "<##ff5555>%player%<##ff5555>, you are not linked to Discord!\n\n<##ffffff>Your linking code: <##55ff55>%{_code}%\n<##ffffff>Use /link %{_code}% in our Discord server to play."
        stop



# ==========================================
# DISCORD COMMAND: /link <code>
# (Discord → Minecraft)
# ==========================================
discord command link:
    prefixes: /
    trigger:
        set {_args::*} to arguments
        if size of {_args::*} is not 1:
            reply with "Usage: /link <code>"
            stop

        set {_code} to {_args::1}

        loop all players:
            set {_uuid} to uuid of loop-player
            
            if {link::code::%{_uuid}%} is {_code}:
                set {linked::%{_uuid}%} to true

                delete {link::code::%{_uuid}%}

                reply with "Your Discord is now linked to Minecraft!"
                send "<##55ff55>Your Discord link has been verified!" to loop-player

                stop

        reply with "Invalid linking code."
        stop


#


# ==========================================
# AUTOMATIC UNLINK WHEN USER LEAVES DISCORD
# ==========================================
on member leave:
    set {_userid} to event-member's id

    loop all players:
        set {_uuid} to uuid of loop-player

        if {linked::%{_uuid}%} is {_userid}:
            delete {linked::%{_uuid}%}
            send "<##ff5555>Your Discord unlink request was detected.\nYou left the server." to loop-player
            kick loop-player due to "<##ff5555>You left the Discord server.\nYou must re-link to continue playing."
            stop```
#

Done!

shut crescent
#

Okay. What is executor user supposed to do?

simple grotto
shut crescent
#

Well yeah, because you have multiple errors.

simple grotto
#

So how will it work?

shut crescent
#

After you fix the errors.

simple grotto
#

Can you help me to work this discord linking?

shut crescent
#

Sure. If you answer my question..

simple grotto
#

Ow, I didn't actually create this script, it was my idea but ai created this script, so I don't know what it is.

zealous flameBOT
#

It is recommended that you don't use AI agents for multiple reasons @simple grotto:


2) Blindly trusting code from any source is a bad idea, especially on production servers. Even if the code that was generated appears to work, you have no clue what vulnerabilities it introduces or fails to protect against.

3) Using AI to write your code takes away from your learning and doesn't challenge you to develop problem solving skills.```
While AI can be used as a tool, it is necessary to understand what it is doing and check any code it creates. Since this is a learning community, we want to support your personal growth. As a result, we don't allow generated content in our help channels ([Rule 8](<#welcome-to-skunity message>))
shut crescent
#

#welcome-to-skunity message
Rule 8

simple grotto
#

Ow sorry for that...

#

So is there possible to help me to fix some errors in this script? It's okay if not...

shut crescent
simple grotto
#

Can you give me some guides so I can start my own code