Tutorial by: Adam


OVERVIEW

This tutorial will teach you how to create a command (/link), which will give the user a code, then the user proceeds to run a command in discord (!link), which will allow them to link their Minecraft account to their discord account.

This allows you to create custom things such as checking stats from discord, easy moderation, and allows you to create easy verification rewards.

VIXIO

This tutorial relies on you already having a Discord Bot, using Vixio set up. View this tutorial on how to set this up.

Once you have this set up, you can continue.

CREATING THE IN-GAME COMMAND

This command (/link) will give the player a unique code that they can use to link their account. We will simply be using randomly generated numbers.

command link:
    trigger:
        set {_code} to a random integer between 11111 and 99999
        set {code::%{_code}%} to player
        send "Your unique is %{_code}%. Run the command !link %{_code}% on our discord to link your account. This code will be deleted in 1 minute."
        wait 1 minute
        delete {code::%{_code}%}

Let's break this code block down. We have created a custom command, /link, which sets a local variable to a random 5 digit code. This then sets a variable, that we will later use on the discord command, that holds the player's username. It then sends the unique code to the player, and gives them instructions on how link their account. The code will be deleted in 60 seconds, regardless of whether the code is used or not.

CREATING THE DISCORD COMMAND

This discord command (!link) will allow the player to enter their unique code (gathered from the command above), which will allow them to link their Minecraft account to their discord account.

discord command link [<text>]:
    prefixes: !
    trigger:
        if arg-1 is not set:
            reply with "Syntax: !link (code)"
            stop
        if {code::%arg-1%} is not set:
            reply with "Invalid code"
            stop
        set {discord::%discord id of event-member%::username} to {code::%arg-1%}
        reply with "You have linked with the Minecraft account %{code::%arg-1%}%."
        delete {code::%arg-1%}

Let's break this code block down. We have created another custom discord command, !link, which accepts one argument. If no code is entered, it will return with the valid syntax. If the code entered is invalid, it will return invalid code. If the code is correct, it will link the account with the user's Minecraft account (Screenshot shown below).

There are a few things you can do at this stage. As the user's Minecraft IGN is still stored, you can reward the player. Furthermore, you can change the user's nickname to match their Minecraft IGN, or even give the user a Linked role.


Did you find Adam's tutorial helpful?


You must be logged in to comment

  • March 26, 2021, 6:31 a.m. - Jordan  

    I have questions, as you said "As the user's Minecraft IGN is still stored, you can reward the player. Furthermore, you can change the user's nickname to match their Minecraft IGN, or even give the user a Linked role.". I was wondering how I would go about doing each of these? What would it look like within the skript? Also, how do I make it where once this player has linked their account, the command /link would tell them "You have already linked your account!", or something along those lines?

    |     
  • March 29, 2021, 5:58 a.m. - siryolothe2  

    where do i insert the discord part?

    |