Tutorial by: KiritoMC_


Hello! Today, I will be teaching you how to use Skript in order to make a Discord bot that runs our your Minecraft server! So, before we start, we are going to need a couple things to make this work. First, get latest versions of Skript and Vixio. Next, go to Discord Developers Page, login to your account and click "Create an application"
.

Skript 2.2-dev37c: https://github.com/SkriptLang/Skript/releases/tag/dev37c
Vixio: https://github.com/iBlitzkriegi/Vixio/releases (Vixio 1.1.5 is not the latest version! 2.0 is out.)

Now, give your bot a name and picture by clicking "Bot" and boom your done but keep the Developers page open.

Now, drag Skript and Vixio to your plugins folder and boot up your server with your Start.bat. After this is done, shut your server down, and you will see why we do this in a bit. Next, go to your Skript folder inside of the plugin folder, and you will see a folder called "scripts". Go into that folder. Now, here is some good future info if you haven't already done this. Go to the top of your folder, click "View", and check off "File Name Extensions". Doing this will allow you to use Skript's special file format that it uses to read your code. Now, left click, create a new text document, and delete all of it, including the ".txt" and rename it whatever you want but with ".sk" at the end. And that's all for this step! Up next is the code.

Now, open up the file you just created and we are gonna write your code:

on skript load: 
    login to "Bot Token Here" with the name "Your Bot's Name"

Now, go back to the Discord Developers site, the bot section and go to "Token" and click "Copy". WARNING: NEVER, EVER, give anyone your bot's token! Also, still don't close the developer site! It's still needed!

Now, paste your token where I put "Bot Token Here". Now, go back to the developers page, go to "OAuth2" , click the bot box, and copy the link at the bottom and follow the other steps to inviting the bot! Now, start up your server and you should see your bot come online!


And finally, the good stuff: Connecting Discord to Minecraft
In order to send Minecraft chat to a Discord channel we need to use the on chat: event.
So here is the code:

on chat:
    send "%player%: %message%" to channel with id "channel id here"

Now to get a channel id, go to Discord, User Settings, Appearance, and toggle developer settings. Left click on whatever channel you want to use, and click copy id and paste the id where i put "channel id here" .

For sending Discord chat to Minecraft, we have to use the on guild message received seen by event-bot: Pretty much what event-bot is, is the current logged in bot, so that's easy! So here's what the code should look like:

on guild message received seen by bot:
    broadcast "%name of event-user%: %event-message%"

And that's all! You should now have a working Minecraft -> Discord -> Minecraft chat way! If you need anymore support, there is an Official Vixio discord or just dm me, Zero Two#0618! Thanks for reading! If you want another example, go check out BlueEyescat's GitHub example https://github.com/Blueyescat/Discord-Bot-Skript.


Did you find KiritoMC_'s tutorial helpful?


You must be logged in to comment

  • May 23, 2019, 12:04 p.m. - NeoKR  

    This code here, is not correct and can't be understood by skript:
    send "%player%: %message%" to channel with id "channel id here"

    |     
    Oct. 24, 2020, 5:43 p.m. - TobyMinceraft  

    Sure this is late, but some people might still have this question. Correct syntax (if using Minecraft-to-Discord chat):
    send "%player%: %message%" to channel with id "channel id here" with "YOUR BOT NAME"

    |     
  • Aug. 27, 2019, 9:06 a.m. - toriset  

    the correct code is send "%player%: %message%" to channel with id "ID" with "BOTNAMEusedFORlogIN"

    |     
  • April 26, 2020, 10:30 p.m. - Onelots  

    hmmm good tutorial. I liked It but you maybe should deepen the subject, and start to teach the possibilities that you can do with Vixio, wich are almost unlimited with using the addons.
    :) but It was pretty good.

    |     
  • July 28, 2020, 11:54 p.m. - Mxko  

    on guild message received seen by bot:
    broadcast "%name of event-user%: %event-message%"

    has an error for me the error is

    can't understand this event 'on guild message received seen by bot' line (7: on guild message received seen by bot:')

    pls pls pls help i really want this to work

    1 |     
    Oct. 24, 2020, 6:07 p.m. - TobyMinceraft  

    broadcast "%discord name of event-user%: %event-message%"
    If you want to format it to be colored on the Minecraft server:
    set {_message} to event-message
    broadcast "%discord name of event-user%: %colored {_message}%"

    |     
  • Oct. 24, 2020, 6:04 p.m. - TobyMinceraft  

    UPDATE
    Just recently, Discord updated the way bots on their network behave and have come up with the "Privileged Gateway Intents" method. So now, Discord is requiring that bots enable the PRESENCE INTENT and SERVER MEMBERS INTENT in order to continue working as intended. In turn, the Vixio plugin has also been updated to reflect this, adding new things to further enhance these intents and work better than before. Click Here for the updated login code, or go to https://pastebin.com/raw/b6Hz0Fu9 in your browser.

    Also, if you want to send a message to a channel (Minecraft-to-Discord, that is) the code is:

    send "%player%: %message%" to channel with id "channel id here" with "Your Bot Name"

    |