Giter VIP home page Giter VIP logo

mineflayer-discord-bridge's Introduction

Mineflayer-Discord-bridge ๐Ÿค–๐ŸŒ

MINEFLAYER-CHATBRIDGE

A simple mineflayer bot that logs messages and has some cool features ๐ŸŽ‰

  • This is a Node.js bot that connects to a Minecraft server and a Discord server, allowing users to control the bot and receive updates from the Minecraft server in the Discord channel. ๐Ÿ’ป๐Ÿ•น๏ธ

-- Features -- ๐Ÿ”ฅ

  • Connects to a Minecraft server and a Discord server ๐ŸŒ
  • Allows users to control the bot through commands sent in the Discord channel ๐Ÿ’ฌ
  • Sends updates about the bot's status and the players in the Minecraft server to the Discord channel or from console ๐Ÿ“ข
  • Blocks certain messages from being sent to the Minecraft server ๐Ÿ›‘
  • Automatically reconnects to the Minecraft server if the bot disconnects ๐Ÿ”„
  • Has prismarine-viewer to look at what your bot is up to, right click on the map to move bot to that point ๐Ÿ˜ฎ
  • Can be controlled from both console and discord. ๐Ÿ’ฏ
  • Note: May not work for some servers, needs stable internet connection. โš ๏ธ
  • If preference in config files is set to "false" then the bot dosent need discord token, ngrok token, channel id and userids to run the code,
  • it can be run without them in your local command prompt.

MineflayerDiscordBot

Command Prompt

Prismarine Viewer http://localhost:3000/

-- Requirements -- ๐Ÿ“‹

  • Node.js (version 19 or 20, DO NOT USE HIGHER VERSIONS) ๐Ÿš€
  • An ngrok account and authentication token ๐Ÿ”‘ (Optional if preference is set to false, will send messages to console instead, same with discord token.
  • A Discord bot token ๐Ÿค–
  • A Minecraft server to connect to ๐Ÿข

-- Installation -- ๐Ÿ› ๏ธ

Clone the repository:

git clone https://github.com/Dr4cule/Mineflayer-Discord-bridge.git

Install the required dependencies(will take a while to download):

cd Mineflayer-Discord-bridge
npm install
  • Use the one below if you want dependencies same as mine installed
npm ci
// or use ๐Ÿ‘‡ if you want the latest dependencies versions, may cause errors, try when about two dosent work for you
npm install @ngrok/ngrok discord.js mineflayer@latest mineflayer-pathfinder prismarine-viewer minecraft-data minecraft-data mineflayer-auto-eat mineflayer-armor-manager
  • Note: If you are facing issues with installing, try installing one package at a time and npm audit fix --force

To get the discord channel id and discord user ids:

  • Go to discord settings, go to advance and enable developer mode then ๐Ÿ”ง right click on the discord channel, copy its id and paste it in the config file where it says to paste ๐Ÿ“‚ right click on discord users and copy their id and paste it in the config file where it says to paste for them to be able to use the bot and its commands. ๐Ÿ™‹โ€โ™‚๏ธ

-- Installation for Termux -- ๐Ÿค–

  • Install Termux from the Play Store or F-Droid.
  • Open Termux and run the following commands(will take a while to download):
pkg update && pkg upgrade
pkg install nodejs-lts git
git clone https://github.com/Dr4cule/Mineflayer-Discord-bridge.git
cd Mineflayer-Discord-bridge
npm install
  • Use the one below if you want dependencies same as mine installed
npm ci
// or use ๐Ÿ‘‡ if you want the latest dependencies versions, may cause errors, try when about two dosent work for you
npm install @ngrok/ngrok discord.js mineflayer@latest mineflayer-pathfinder prismarine-viewer minecraft-data mineflayer-auto-eat mineflayer-armor-manager
  • Note: If you are facing issues with installing, try installing one package at a time and npm audit fix --force

To get the discord channel id and discord user ids:

  • Go to discord settings, go to advance and enable developer mode then ๐Ÿ”ง right click on the discord channel, copy its id and paste it in the config file where it says to paste ๐Ÿ“‚ right click on discord users and copy their id and paste it in the config file where it says to paste for them to be able to use the bot and its commands. ๐Ÿ™‹โ€โ™‚๏ธ

  • Follow the rest of the steps as

-- Ngrok -- ๐ŸŒ

  • To get your ngrok token visit ngrok, click on the link after you log in if you are lost. ๐Ÿ”‘
  • Paste your ngrok token to the specified place in config.json ๐Ÿ“
  • Note: You can visit localhost:3000 to use prismarine viewer locally once your free ngrok expires or just make another alt for ngrok with temp mails for the bots view to be accessable for other authorized users in discord server.

Making a discord bot: ๐Ÿค–

  • Go to devportal and make an application, go to "Bot" and enable all the 3 "Privileged Gateway Intents" ๐Ÿ” then go to "OAuth2", put this link in the redirect box https://discordapp.com/oauth2/authorize?&client_id=Bots_client_id&scope=bot, ๐Ÿ”— get the application id from "Genearal Information" and replace Bots_client_id with the one you copied, after editing the link in redirect box as directed, select "bot" in "OAuth2 URL Generator" and select "Administrator" in "Bot permissions and then copy the link it gives you at the bottom, paste it in your website and invite the bot to your server. ๐Ÿ™Œ
  • Get your discord bot token from "Bot" at devportal to paste it in config.json, click on reset at near token if you have lost or forgotten your token and update config.json with your new bot token. ๐Ÿ”‘

Configure config.json file with your requirements: ๐Ÿ”ง

  • The bot's configuration is stored in the config.json file. Here's a breakdown of the available settings:

  • ngrokAuthToken: The authentication token for the ngrok service.

  • botUsername: The username of the bot in the Minecraft server.

  • botPswd: The password for the bot's Minecraft account.

  • serverHost: The hostname of the Minecraft server.

  • serverPort: The port number of the Minecraft server.

  • serverVersion: The version of the Minecraft server / Mineflayer bot version, make sure the version you put here is allowed by the server.

  • botAuth: The authentication method for the bot (either "offline" or "microsoft").

  • botPass: The password for the bot's Minecraft account.

  • discordToken: The authentication token for the Discord bot.

  • discordChannelId: The ID of the Discord channel where the bot will send messages.

  • allowedUserIds: The list of Discord user IDs that are allowed to send commands to the bot.

  • BlockedMessages: The list of messages that the bot will ignore.

  • Preference: If true the bot sends messages to dc and can be controlled by allowed users from there else it sends and can be controlled from console.

Once everything is done and set up run the bot using:

node index.js

-- Usage -- ๐Ÿ•น๏ธ

  • Send commands to the bot in the Discord channel specified in the config.json file.
  • The bot will execute the commands in the Minecraft server and send updates back to the Discord channel.

Available commands:

  • /antiafk: Moves the bot every 30 seconds, customize in code to your need. ๐Ÿšถโ€โ™‚๏ธ
  • /listtab: Sends a list of players currently in the Minecraft server to the Discord channel. ๐Ÿ“‹
  • /reconnect: Disconnects the bot from the Minecraft server and attempts to reconnect. ๐Ÿ”
  • /Rclickslot <slot>: Right-clicks the specified hotbar slot. ๐Ÿ–ฑ๏ธ example: /Rclickslot 4
  • /Lclickslot <slot>: Left-clicks the specified hotbar slot. ๐Ÿ–ฑ๏ธ example: /Lclickslot 12
  • /closewindow: Closes the currently open window. ๐Ÿ”’
  • /health: To check the bots health. โค๏ธ
  • /inv: Lists all the items in the inventory along with their slot number. ๐Ÿ‘€
  • /coords: Gives the coordinates of the bot. ๐ŸŒ
  • /move: To make the bot move forwards for 5 seconds. ๐Ÿƒโ€โ™‚๏ธ
  • /hunger: Gives the bots hunger index number. ๐Ÿ–
  • /tocmd: Transfers control and chats to console, only available in discord. ๐Ÿ‘‡
  • /todis: Transfers control and chats to discord, only available in console. โ˜๏ธ
  • /cmdhelp: Lists all the available commands. โœ…
  • /fpull: To snatch controls from discord from console without having to use /tocmd in discord, only available in console. ๐Ÿคฉ
  • /yell : Sends message with the username of discord message sender. (botname ยป dcmsgsender ๐Ÿ—ฃ๏ธ msg) example: /yell Hello world -output-> PizzAllDay7 ยป Dr4cule ๐Ÿ—ฃ๏ธ Hello world

To do(when repo gets 10 stars) ๐Ÿ“™ : [Basic functions already covered]

  • /nearby: Lists players nearby the bot, will be added later.
  • /killaura: Attacks specified entities, will be added later.
  • /lookat: Looks at specified player/entity, will be added later.
  • /follow: Follows specified player, will be added later.
  • Telegram support
  • Online bot Dashboard
  • Will add lots of stuff when I start getting good at coding.

slotinfo

  • You can also set a pattern of clicks the bot should initiate on login to directly join in to the sub-server of a minecraft server. ๐Ÿค–
  • Example commented out in index.js

-- Contributing -- ๐Ÿค

  • If you find any issues or have suggestions for improvements, feel free to create a new issue or submit a pull request. ๐Ÿ™Œ

License ๐Ÿ“œ

Works on my machine ๐Ÿ‘ ๐Ÿ’€ Hope it does on yours as well ๐Ÿ˜…

MIT

mineflayer-discord-bridge's People

Contributors

dr4cule avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.