Giter Club home page Giter Club logo

shulker's Introduction

shulker

Connects Discord and Minecraft Servers by sending messages back and forth without any mods or plugins.

In Action

discord-mc

Features

  • Sends message to and from Vanilla Minecraft servers with no plugins or mods
  • Can send messages regarding
    • Advancements
    • Players joining and leaving
    • Player deaths
  • Webhooks for sending messages
  • Allows members with specific roles to send commands to Minecraft through Discord
  • Can be run on a remote machine or locally on the same machine (see IS_LOCAL_FILE in the options below)

Installation

Ensure you have Node v16.6+ installed. You can check the version you have installed with node -v in your terminal or command prompt.

Create a Discord bot here: https://discordapp.com/developers/applications/me

  • Important: Ensure that the Bot has the Server Members Intent and the Message Content Intent (available on the "Bot" tab in your Application settings)

Then, add the bot to your Discord server using the following link, replace the Client ID with that of your bot.

https://discordapp.com/oauth2/authorize?client_id=<CLIENT ID>&scope=bot

In your Minecraft server.properties, make sure you have the following and restart the server:

enable-rcon=true
rcon.password=<your password>
rcon.port=<1-65535>

Clone this repository onto a server, copy config.example.json to config.json. And edit the following config fields:

Set DISCORD_TOKEN to the Discord Bot token that you created.

Set MINECRAFT_SERVER_RCON_IP, MINECRAFT_SERVER_RCON_PORT, and MINECRAFT_SERVER_RCON_PASSWORD to the ip, rcon port, and rcon password respectively for your server. (127.0.0.1 can be used if Shulker is running on the same server as your Minecraft server)

If you are running Shulker on the same server as your Minecraft server, set IS_LOCAL_FILE to true and update LOCAL_FILE_PATH to the full path to your Minecraft server's latest log file. (ex: minecraft_server/logs/latest.log)

If you want to have Shulker running on a remote server, see Remote below.

With developer mode (Settings > Appearance > Developer Mode) enabled, right click the channel you wish to have Shulker send messages to and click "Copy ID". Set DISCORD_CHANNEL_ID to this value.

Create a webhook in the channel (Right click on channel > Edit Channel > Integrations > Create Webhook or New Webhook), copy it, and set WEBHOOK_URL to this value.

Finally, start Shulker.

npm install
npm run build
npm run start

Configuration

Details on the config.json file.

{
    "DEBUG": false, /* Dev debugging */
    
    "USE_WEBHOOKS": true, /* If you want to use webhooks rather than the Discord bot sending the messages (recommended) */
    "WEBHOOK_URL": "DISCORD_WEBHOOK_URL_HERE", /* Be sure to create a webhook in the channel settings and place it here! */

    "IGNORE_WEBHOOKS": true, /* Ignore any messages that are sent by webhooks. If disabled, then all webhooks but those sent from the configured webhook will be handled as well */

    "DISCORD_TOKEN": "<12345>", /* Discord bot token. [Click here](https://discordapp.com/developers/applications/me) to create you application and add a bot to it. */
    "DISCORD_CHANNEL_ID": "<channel>", /* Discord channel ID for for the discord bot. Enable developer mode in your Discord client, then right click channel and select "Copy ID". */
    "DISCORD_MESSAGE_TEMPLATE": "`%username%`:%message%", /* Message template to display in Discord */

    "MINECRAFT_SERVER_RCON_IP": "127.0.0.1", /* Minecraft server IP (make sure you have enabled rcon) */
    "MINECRAFT_SERVER_RCON_PORT": <1-65535>, /* Minecraft server rcon port */
    "MINECRAFT_SERVER_RCON_PASSWORD": "<your password>", /* Minecraft server rcon password */
    "MINECRAFT_TELLRAW_TEMPLATE": "[{\"color\": \"white\", \"text\": \"<%username%> %message%\"}]", /* Tellraw template to display in Minecraft */
    "MINECRAFT_TELLRAW_DOESNT_EXIST": false, /* Minecraft doesn't have the tellraw command (<1.7.2), use say instead. !this may be dangerous! */
    "MINECRAFT_TELLRAW_DOESNT_EXIST_SAY_TEMPLATE": "<%username%> %message%", /* used when MINECRAFT_TELLRAW_DOESNT_EXIST is set to true. say template to display on minecraft, same as MINECRAFT_TELLRAW_TEMPLATE. */

    "IS_LOCAL_FILE": true, /* tail the local file specified at `LOCAL_FILE_PATH` */
    "LOCAL_FILE_PATH": "/usr/home/minecraft_server/logs/latest.log", /* the path to the local file if `IS_LOCAL_FILE` is set */
    "FS_WATCH_FILE": false, /* use node's watchFile rather than watch. see FAQ for more details */

    "PORT": 8000, /* Port you want to run the webserver for the hook on */
    "SHOW_INIT_MESSAGE": true, /* Sends the message on boot if not a local file of what command to run */ 

    "ALLOW_USER_MENTIONS": false, /* should replace @mentions with the mention in discord (format: @username#discriminator) */
    "ALLOW_HERE_EVERYONE_MENTIONS": false, /* replaces @everyone and @here with "@ everyone" and "@ here" respectively */
    "ALLOW_SLASH_COMMANDS": false, /* whether to allow users to run slash commands from discord */
    "SLASH_COMMAND_ROLES_IDS": [], /* if the above is enabled, the IDs of the roles which can run slash commands. With developer mode enabled, right click each role and "Copy ID". */.
    
    "WEBHOOK": "/minecraft/hook", /* Web hook, where to send the log to */
    "REGEX_SERVER_PREFIX": "\\[Server thread/INFO\\]:", /* What the lines of the log should start with */
    "REGEX_MATCH_CHAT_MC": "^<([^>]*)> (.*)", /* What to match for chat (best to leave as default) */
    "REGEX_DEATH_MESSAGE": "^[\w_]+ (died|...)", /* What to match for death messages (best leave this default too) */
    "REGEX_IGNORED_CHAT": "packets too frequently", /* What to ignore, you can put any regex for swear words for example and it will  be ignored */

    "SERVER_NAME": "Shulker", /* The username used when displaying any server information in chat, e.g., Server - Shulker : Server message here*/
    "SERVER_IMAGE": "", /* Image for the server when sending such messages (if enabled below). Only for WebHooks. */
    "HEAD_IMAGE_URL": "https://mc-heads.net/avatar/%uuid%/256", /* Url to get the heads for the webhook, %uuid% is replaced with the uuid of the player */
    "UUID_API_URL": "https://api.mojang.com/users/profiles/minecraft/%username%", /* Url to fetch the uuids from. %username% is replaced with the username of the player. expects uuid at top level key `id` (like the mojang api) */
    "DEFAULT_PLAYER_HEAD": "c06f89064c8a49119c29ea1dbd1aab82", /* UUID of player with the default head to use (currently is MHF_Steve) */

    "SHOW_SERVER_STATUS": false, /* Shows when the server turns on and off e.g., Server - Shulker : Server is online */
    "SHOW_PLAYER_CONN_STAT": false, /* Shows player connection status in chat, e.g., Server - Shulker : TheMachine joined the game */
    "SHOW_PLAYER_ADVANCEMENT": false, /* Shows when players earn advancements in chat, e.g., Server - Shulker : TheMachine has made the advacement [MEME - Machine] */
    "SHOW_PLAYER_DEATH": false, /* Shows when players die in chat, e.g., Server - Shulker : TheMachine was blown up by creeper */
    "SHOW_PLAYER_ME": false /* Shows when players use the /me command, e.g. **destruc7i0n** says hello */
}

FAQ

  • How do I make this work on a modded server?

    • Try replacing REGEX_SERVER_PREFIX with "\\[Server thread/INFO\\] \\[.*\\]:"
  • Why can't I send commands even if I have the option enabled?

    • Make sure that you have a role on the server which is put in the array SLASH_COMMAND_ROLES_IDS.
      • e.g. "SLASH_COMMAND_ROLES_IDS": ["<role id>"]
  • I am using a local file and no messages are being sent!

    • Enable DEBUG in the config to check for any errors.
    • If you are on Windows, try enabling FS_WATCH_FILE.

Remote Setup

Perform the following command on the server hosting the Minecraft server (in a screen/tmux session or background process, make sure to replace your YOUR_URL with whatever URL you're using (localhost:8000 if running on the same server and default config) and PATH_TO_MINECRAFT_SERVER_INSTALL with the path to the Minecraft server installation, such as /usr/home/minecraft_server/):

tail -F /PATH_TO_MINECRAFT_SERVER_INSTALL/logs/latest.log | grep --line-buffered ": <" | while read x ; do echo -ne $x | curl -X POST -d @- http://YOUR_URL/minecraft/hook ; done

(The above command will also be given to you if you are not using a local file when you first start up Shulker)

Upgrade Instructions

From version 2 to version 3:

  • The main change is that you need to split your REGEX_MATCH_CHAT_MC to both REGEX_MATCH_CHAT_MC and REGEX_SERVER_PREFIX. See the configuration above for details.

Upcoming

None

Suggestions

If you have any suggestions or feature requests, feel free to add an issue and I will take a look.

Thanks

License

ISC. See LICENSE.

shulker's People

Contributors

arcensoth avatar blandin avatar destruc7i0n avatar elveskevtar avatar feikojoosten avatar mageluingil avatar moliver91 avatar secretonline avatar surepy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

shulker's Issues

Error inside of bot log. (MC chat to discord doesn't work)

It's similar to this issue: #15.

This is the error:
TypeError: Cannot read property '1' of null at /home/lando/shulker/index.js:70:45 at Layer.handle [as handle_request] (/home/lando/shulker/node_modules/express/lib/router/layer.js:95:5) at next (/home/lando/shulker/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/home/lando/shulker/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/home/lando/shulker/node_modules/express/lib/router/layer.js:95:5) at /home/lando/shulker/node_modules/express/lib/router/index.js:281:22 at Function.process_params (/home/lando/shulker/node_modules/express/lib/router/index.js:335:12) at next (/home/lando/shulker/node_modules/express/lib/router/index.js:275:10) at IncomingMessage.<anonymous> (/home/lando/shulker/index.js:58:5) at IncomingMessage.emit (events.js:197:13)

Extended functionality

Hope you don't mind me creating feature requests here, but I have a few ideas for additional messages that could be transmitted to Discord:

  • Players Leaving & Joining
  • Death Messages
  • Achievement/Advancment Messages
  • /me messages

Discord mentions in MC don't successfully mention in Discord

As a user, I am unable to mention a Discord user in the MC chat. We attempted @User#1234, @User, @Nickname, @Nickname#1234 and none seem to work.

It seems that the regex for mentions returns the entire line including the message logging.

PR incoming.

discord wont recieve messages but will send.

even when tailing latest.log (listening on 6969), discord can send but cant recieve messages from the server (1.14.1)

the error it gives when sending a message on the minecraft server is:

<title>Error</title>
Cannot POST /

any help would be appreciated...

EDIT: i use discord canary instead of normal one dont know if that makes a difference tho

ERR_BUFFER_OUT_OF_BOUNDS

Getting error unable to authenticate with Rcon, definitely attempting to connect as can see all the connections starting and ending in the log however it's not authenticating and is giving the error message in title.

This is stopping all messages from Discord not to post to the server.

Password is correct.

messages from within discord crash shulker

Messages sent from discord app crash the shulker server with:

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 127.0.0.1:65535
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14)
error Command failed with exit code 1.

Interestingly, chat from my minecraft server comes through to discord perfectly; has anyone else experienced this issue? Being that there is quite a lot of configuration between shulker and the discord bot I'm not sure that I haven't configured something incorrectly, but I'm unable to find any logs to break the issue down any further.

Shulker running with yarn, and here's my config.json:

    "PORT": 8000,
    "USE_WEBHOOKS": true,
    "WEBHOOK_URL": "https://discordapp.com/###
    "DISCORD_TOKEN": "NTI4Nzkx#######",
    "DISCORD_CHANNEL_ID": "5287######",
    "DISCORD_MESSAGE_TEMPLATE": "`%username%`: %message%",
    "MINECRAFT_SERVER_RCON_IP": "127.0.0.1",
    "MINECRAFT_SERVER_RCON_PORT": 65535,
    "MINECRAFT_SERVER_RCON_PASSWORD": "#######",
    "MINECRAFT_TELLRAW_TEMPLATE": "[{\"color\": \"white\", \"text\": \"<%username%> %mess$
    "WEBHOOK": "/minecraft/hook",
    "REGEX_MATCH_CHAT_MC": "\\[Server thread/INFO\\]: <([^>]*)> (.*)",
    "REGEX_IGNORED_CHAT": "packets too frequently",
    "RCON_RECONNECT_DELAY": 10,
    "DEBUG": true


Discord messages not in minecraft anymore

At first, everything with the bot worked (both messages from discord to minecraft and from minecraft to discord). But all of a sudden the messages from discord to minecraft stopped working. (At first it displayed an error message (didn't save the name... Every time a message in discord was send, it'd say something in the terminal about Discord and the Webhook.) Now it doesn't show an error anymore, but still doesn't work...
The only things I can imagine that caused this problem are me messing with the latest.log file while the webhook was running and me ones redoing the port forwarding. Any idea what the problem is and how to fix it?

More detail in the wiki

Would it be possible to have more detail added to the wiki? I'm trying to install Shulker Bot, and have managed to get it working one way (Discord -> MC), but not the reverse.

With reference to the tail command, the wiki says make sure to replace your URL and your log directory location, but what exactly is the URL? Where should it point to? Should this be a discordapp URL, or something on localhost?

Apologies if I'm missing something obvious, but I've been trying all sorts for the past few days and haven't been able to work out how it is supposed to be configured.

Connection Refused

The tails command always returns with a curl: (7) Failed to connect to localhost port 8000: Connection refused

The tails command (directory is correct on my setup):
tail -F /DIRECTORY/logs/latest.log | grep --line-buffered ": <" | while read x ; do echo -ne $x | curl -X POST -d @- http://localhost:8000/minecraft/hook ; done

I'm not sure as to what the problem is with the localhost, the port is right, and I have the webhook and rcon on, he tmux screen with the yarn build && yarn run say Authenticated with 127.0.0.1:25575 so I'm very unsure as to what could fix this.

"Cannot read property 'id' of undefined"

yarn run v1.22.10
$ node build/index.js
[INFO] Using configuration file: ../config.json
[INFO] Using Discord WebHooks to send messages
C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\discord.js\src\client\ClientDataManager.js:81
        guild.channels.set(channel.id, channel);
                                   ^

TypeError: Cannot read property 'id' of undefined
    at ClientDataManager.newChannel (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\discord.js\src\client\ClientDataManager.js:81:36)
    at Guild.setup (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\discord.js\src\structures\Guild.js:206:68)
    at GuildCreateHandler.handle (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\discord.js\src\client\websocket\packets\handlers\GuildCreate.js:12:15)
    at WebSocketPacketManager.handle (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:105:65)
    at WebSocketConnection.onPacket (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
    at WebSocket.onMessage (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\ws\lib\event-target.js:120:16)
    at WebSocket.emit (events.js:314:20)
    at Receiver.receiverOnMessage (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\ws\lib\websocket.js:789:20)
    at Receiver.emit (events.js:314:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Trying to understand how to set this up.

In trying to set this up, I don't understand what is meant when trying to place a url/minecraft/hook in the setup process. Could you possibly give me a real world example?

Request failed with status code 400

I get this Error if i chat something in MC
root@tns-01:/home/chatbot# cd /home/chatbot/ && yarn start
yarn run v1.13.0
$ node index.js
[INFO] Using configuration file: ./config.json
[INFO] Bot listening on *:8000
[INFO] Recieved [14:23:13] [Server thread/INFO]: <[Admin] mar_robHD> ad
[DEBUG] Username: [Admin] mar_robHD
[DEBUG] Text: ad
(node:4740) UnhandledPromiseRejectionWarning: Error: Request failed with status code 400
at createError (/home/chatbot/node_modules/axios/lib/core/createError.js:16:15)
at settle (/home/chatbot/node_modules/axios/lib/core/settle.js:18:12)
at IncomingMessage.handleStreamEnd (/home/chatbot/node_modules/axios/lib/adapters/http.js:201:11)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:4740) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:4740) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Minecraft chat not passed into Discord

Hi,
I've been having an issue with this, where the app receives the in-game chat fine (as shown by the console log), but then never sends that message to Discord. The reverse (Discord to Minecraft) works perfectly.
The most I've been able to get out of it is this stacktrace:

TypeError: Cannot read property 'sendMessage' of null                                                                 
    at /home/minecraft/discordrelay/index.js:42:48
    at Layer.handle [as handle_request] (/home/minecraft/discordrelay/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/minecraft/discordrelay/node_modules/express/lib/router/route.js:131:13)
    at Route.dispatch (/home/minecraft/discordrelay/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/minecraft/discordrelay/node_modules/express/lib/router/layer.js:95:5)
    at /home/minecraft/discordrelay/node_modules/express/lib/router/index.js:277:22
    at Function.process_params (/home/minecraft/discordrelay/node_modules/express/lib/router/index.js:330:12)
    at next (/home/minecraft/discordrelay/node_modules/express/lib/router/index.js:271:10)
    at IncomingMessage.<anonymous> (/home/minecraft/discordrelay/index.js:24:9)
    at emitNone (events.js:67:13)

Syntax error

Hi I am trying to run shulker, but it gets an syntaxerror. The error is:

/root/minecraft/shulker/node_modules/discord.js/src/util/Util.js:8 class Util { ^^^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:374:25) at Object.Module._extensions..js (module.js:417:10) at Module.load (module.js:344:32) at Function.Module._load (module.js:301:12) at Module.require (module.js:354:17) at require (internal/module.js:12:17) at Object.<anonymous> (/root/minecraft/shulker/node_modules/discord.js/src/index.js:1:76) at Module._compile (module.js:410:26) at Object.Module._extensions..js (module.js:417:10)

Running it on Ubuntu 16.04.2 LTS, my node version is v4.2.6 and npm 3.5.2
Do you know what wen't wrong?

2 Shulker instances in the same channel can's see each other

image

I've got 2 instances of Shulker each running on different servers and I was hoping this would bridge their chats in addition to showing them on Discord, but it just makes it into a situation where you only hear one side of a telephone conversation. Is there a way to fix this?

Errer: read ECONNRESET

I was trying to get this working, and I got through a couple of problems that I was experiencing, but now I am stuck with:
`[INFO] Using configuration file: ./config.json
[INFO] Using configuration for local file at "D:/Server/logs/latest.log"
[INFO] Authenticated with 127.0.0.1:255##
(node:13728) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[DEBUG] Recieved response:
[DEBUG] Recieved response:
events.js:174
throw er; // Unhandled 'error' event
^

Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:111:27)
Emitted 'error' event at:
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`

Any ideas on what to do? This only happens why I type a message in the discord channel. For minecraft nothing even gets recognized so that is another issue too. Using 1.14

Help with Regex

Hi! Help me pls.
Earlier all working:
latest.log:
[21:39:48] [Async Chat Thread - #65/INFO]: <nickname> msg
Regex: "REGEX_MATCH_CHAT_MC": "\\[Async Chat Thread - #\\d*\/INFO\\]: <([^>]*)> (.*)"

But, i change chat cfg:
latest.log:
[21:36:20] [Async Chat Thread - #64/INFO]: nickname: msg
And now msg mc to dc not send. This regex not correct. Help me with regex pls for new chat cfg

Tail ftp mount

Hello,
Since I have minecraft hosted on a minecraft dedicated host (verygames) I can't use the tail -F /PATH_TO_MINECRAFT_SERVER_INSTALL/logs/latest.log | grep --line-buffered ": <" | while read x ; do echo -ne $x | curl -X POST -d @- http://YOUR_URL/minecraft/hook ; done command on minecraft machine. I've mounted the ftp directory to a linux server that I own and tried to use the log file as a local file but it was not "reading" it and displaying on discord. I found this on the internet. Seems that when a remote directory is mounted there is a diferent filesystem provided by FUSE. https://unix.stackexchange.com/questions/347554/doing-a-tail-f-on-a-text-file-over-sshfs-not-working-why
This is the error that shows on trying to run the bot with local file reading from the mounted directory:
image
Is there any way to adapt the index.js to read this?
Thanks! ๐Ÿ‘

Cannot POST /minecraft/hook

After completing all of the steps and running the app, I get the following message every time I type in Minecraft:

Cannot POST /minecraft/hook

Bug?

`if (message.channel.id === shulker.channels.get(c.DISCORD_CHANNEL_ID).id) {
                                                                         ^

TypeError: Cannot read property 'id' of undefined
    at Client.<anonymous> (/app/index.js:54:74)
    at emitOne (events.js:116:13)
    at Client.emit (events.js:211:7)
    at MessageCreateHandler.handle (/app/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (/app/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:103:65)
    at WebSocketConnection.onPacket (/app/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (/app/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
    at WebSocket.onMessage (/app/node_modules/ws/lib/event-target.js:120:16)
    at emitOne (events.js:116:13)
    at WebSocket.emit (events.js:211:7)`

An error occurred when I tried running the app on Heroku

NPM Crash

Not sure if this is shulker or discord.js but I've set up an implemented the package and am having the following crash intermittently.

http://pastebin.com/LAawtem2

Any tips appreciated - in the meantime setting up a script to run on a cronjob and kick it back alive every 30 minutes.

Can send messages via Discord, but not via Minecraft

My config :

{
    "PORT": 8000,

    "USE_WEBHOOKS": true,
    "WEBHOOK_URL": "",
    "DISCORD_TOKEN": "",
    "DISCORD_CHANNEL_ID": "670317920886325268",
    "DISCORD_MESSAGE_TEMPLATE": "`%username%`:  %message%",
	"PATH_TO_MINECRAFT_SERVER_INSTALL ": "C:\\Users\\GameServer\\Desktop\\MCServer\\",

    "MINECRAFT_SERVER_RCON_IP": "localhost",
    "MINECRAFT_SERVER_RCON_PORT": 25575,
    "MINECRAFT_SERVER_RCON_PASSWORD": "",
    "MINECRAFT_TELLRAW_TEMPLATE": "[{\"color\": \"white\", \"text\": \"<@%username%> %message%\"}]",

    "IS_LOCAL_FILE": false,
    "LOCAL_FILE_PATH": "C:\\Users\\GameServer\\Desktop\\MCServer\\logs\\latest.log",

    "ALLOW_USER_MENTIONS": true,

    "WEBHOOK": "/minecraft/hook",
    "REGEX_MATCH_CHAT_MC": "\\[Server thread/INFO\\]: <([^>]*)> (.*)",
    "REGEX_IGNORED_CHAT": "packets too frequently",
    "RCON_RECONNECT_DELAY": 10,
    "DEBUG": true
}

What is wrong?

npm-debug.log

0 info it worked if it ends with ok 1 verbose cli [ '/home/jannes/.nvm/versions/node/v4.4.7/bin/node', 1 verbose cli '/home/jannes/.nvm/versions/node/v4.4.7/bin/npm', 1 verbose cli 'start' ] 2 info using [email protected] 3 info using [email protected] 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info prestart [email protected] 6 info start [email protected] 7 verbose unsafe-perm in lifecycle true 8 info [email protected] Failed to exec start script 9 verbose stack Error: [email protected] start: node index.js9 verbose stack Exit status 1 9 verbose stack at EventEmitter.<anonymous> (/home/jannes/.nvm/versions/node/v4.4.7/lib/node_modules/npm/lib/utils/lifecycle.js:217:16) 9 verbose stack at emitTwo (events.js:87:13) 9 verbose stack at EventEmitter.emit (events.js:172:7) 9 verbose stack at ChildProcess.<anonymous> (/home/jannes/.nvm/versions/node/v4.4.7/lib/node_modules/npm/lib/utils/spawn.js:24:14) 9 verbose stack at emitTwo (events.js:87:13) 9 verbose stack at ChildProcess.emit (events.js:172:7) 9 verbose stack at maybeClose (internal/child_process.js:827:16) 9 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5) 10 verbose pkgid [email protected] 11 verbose cwd /home/jannes/shulker-master 12 error Linux 3.16.0-4-amd64 13 error argv "/home/jannes/.nvm/versions/node/v4.4.7/bin/node" "/home/jannes/.nvm/versions/node/v4.4.7/bin/npm" "start" 14 error node v4.4.7 15 error npm v2.15.8 16 error code ELIFECYCLE 17 error [email protected] start:node index.js 17 error Exit status 1 18 error Failed at the [email protected] start script 'node index.js'. 18 error This is most likely a problem with the shulker package, 18 error not with npm itself. 18 error Tell the author that this fails on your system: 18 error node index.js 18 error You can get information on how to open an issue for this project with: 18 error npm bugs shulker 18 error Or if that isn't available, you can get their info via: 18 error 18 error npm owner ls shulker 18 error There is likely additional logging output above. 19 verbose exit [ 1, true ]

Messages from Discord to MC Always Show Username

As an administrator, we require our users to change their Discord nickname to their Minecraft name so that people are familiar with one another whether in Discord or in Minecraft.

Administrators should have the ability to choose to use the user's nickname rather than the username in message.

PR incoming.

Error nodejs With Utils

Hello I running My code and it gives me this error
`/root/KannaArmyV2/node_modules/discord.js/src/util/Util.js:8
class Util {
^^^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
`
I have a node version 11.0.0

Thanks.

Death message false positives

The current keyword method of detecting death messages allows for false positives, such as this one:

villager-death

A more robust solution would use an actual regex to detect expected death messages at the beginning of the log line. I have a solution that's been running on my server for two weeks now with no apparent issues. (Pull request incoming)

Tellraw escape

First of all, I didn't test these. But I wondered where " is escaped from discord to minecraft messages. I didn't find a place, so you can escape the tellraw json and add styles with clickable links & commands.
Also it should be possible to send ยง from discord to minecraft.
From minecraft to discord @here & @everyone should be escaped. Normally the bots shouldn't have perms to mention everyone, but I saw servers giving the Bots roll Admin permissions.
I'm sorry if these are already handled somewhere and I oversaw it.

Intermittent Crashes

I am getting the following error:

events.js:180

    throw err; // Unhandled 'error' event
    ^

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ([object Object])
    at Client.emit (events.js:178:17)
    at WebSocketConnection.onError (/home/bowilla/mc/main/shulker/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:374:17)
    at WebSocket.onError (/home/bowilla/mc/main/shulker/node_modules/ws/lib/event-target.js:128:16)
    at WebSocket.emit (events.js:189:13)
    at _receiver.cleanup (/home/bowilla/mc/main/shulker/node_modules/ws/lib/websocket.js:211:14)
    at Receiver.cleanup (/home/bowilla/mc/main/shulker/node_modules/ws/lib/receiver.js:557:13)
    at WebSocket.finalize (/home/bowilla/mc/main/shulker/node_modules/ws/lib/websocket.js:206:20)
    at TLSSocket.emit (events.js:189:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Shulker has worked very well, but then this error comes intermittently.
It works for about a day or so and then crashes with this error and requires a restart to continue.
I thought about running it with nodemon(auto-restarter) instead of yarn, but I would prefer to fix the issue if possible.

I noticed in this line that the error is rooted in the discord.js websocket connection, but I couldn't tell if this was a bug in discord.js error handling or in shulkers error handling.
at WebSocketConnection.onError (/home/bowilla/mc/main/shulker/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:374:17)

I just want to know if it is possible or not to be fixed in shulker.
I don't know since I have seen deep-rooted errors, that don't relate back to my script but is in fact my error.

I see with issue #9 that there is something related to what you are doing inside Discord.
I quickly tested all of that and can confirm it is not the cause.
As of now I cannot reproduce when or why it happens, but it does happen about once everyday.

As a quick side note, there is a deprecated use of Buffer used in shulker which will causes crashes in the future:
(node:13869) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

TypeError when webhook called with chat text

I've got the Discord --> Minecraft functionality working. But shulker errors when it parses the latest.log


> [email protected] start /opt/shulker
> node index.js

[INFO] Bot listening on *:25501
[INFO] Recieved [17:12:16 INFO]: <Baphomet> Test from MC
TypeError: Cannot read property '1' of null
    at /opt/shulker/index.js:38:61
    at Layer.handle [as handle_request] (/opt/shulker/node_modules/express/lib/router/layer.js:95:5)
    at next (/opt/shulker/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/opt/shulker/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/opt/shulker/node_modules/express/lib/router/layer.js:95:5)
    at /opt/shulker/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/opt/shulker/node_modules/express/lib/router/index.js:335:12)
    at next (/opt/shulker/node_modules/express/lib/router/index.js:275:10)
    at IncomingMessage.<anonymous> (/opt/shulker/index.js:24:9)
    at emitNone (events.js:106:13)

The following was me feeding it a log line but I receive the same error when the while loop parses the latest.log as well

 $ echo "[17:12:16 INFO]: <Baphomet> Test from MC" |  curl -X POST -d @- http://localhost:25501/minecraft/hook
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>TypeError: Cannot read property &#39;1&#39; of null<br> &nbsp; &nbsp;at /opt/shulker/index.js:38:61<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/opt/shulker/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at next (/opt/shulker/node_modules/express/lib/router/route.js:137:13)<br> &nbsp; &nbsp;at Route.dispatch (/opt/shulker/node_modules/express/lib/router/route.js:112:3)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/opt/shulker/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at /opt/shulker/node_modules/express/lib/router/index.js:281:22<br> &nbsp; &nbsp;at Function.process_params (/opt/shulker/node_modules/express/lib/router/index.js:335:12)<br> &nbsp; &nbsp;at next (/opt/shulker/node_modules/express/lib/router/index.js:275:10)<br> &nbsp; &nbsp;at IncomingMessage.&lt;anonymous&gt; (/opt/shulker/index.js:24:9)<br> &nbsp; &nbsp;at emitNone (events.js:106:13)</pre>
</body>
</html>
cat config.json
{
    "PORT": 25501,
    "DISCORD_TOKEN": "REDACTED",
    "DISCORD_CHANNEL_ID": "480132340551516160",
    "MINECRAFT_SERVER_RCON_IP": "localhost",
    "MINECRAFT_SERVER_RCON_PORT": 25575,
    "MINECRAFT_SERVER_RCON_PASSWORD": "REDACTED",
    "WEBHOOK": "/minecraft/hook",
    "REGEX_MATCH_CHAT_MC": "\\[Server thread/INFO\\]: <([^>]*)> (.*)",
    "REGEX_IGNORED_CHAT": "packets too frequently",
    "RCON_RECONNECT_DELAY": 10,
    "DEBUG": true
}
$ npm version
{ shulker: '1.0.0',
  npm: '6.4.0',
  ares: '1.10.1-DEV',
  cldr: '32.0',
  http_parser: '2.8.0',
  icu: '60.1',
  modules: '57',
  napi: '3',
  nghttp2: '1.32.0',
  node: '8.11.3',
  openssl: '1.0.2o',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.19.1',
  v8: '6.2.414.54',
  zlib: '1.2.11' }

What have I done wrong?

301 Moved Permanently Error

The bot sents the Discord chat to Minecraft but not the chat from Minecraft to Discord.

If I try this:

tail -F /var/lib/pufferd/servers/8d5caf9a-ccc2-4568-ac7f-34a104008199/logs/latest.log | grep --line-buffered ": <" | while read x ; do echo -ne $x | curl -X POST -d @- http://172.0.0.1/minecraft/hook/ ; done

I get this Error:

</html>
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.14.0 (Ubuntu)</center>
</body>
</html>

Discord Webhook

Could you please use this JSON for the message on Discord using a webhook and content type application/json? Just replace Notch with the username and Example message with the message.

{
"content": "Example message",
"username": "Notch",
"avatar_url": "https://minotar.net/helm/Notch/300.png"
}

If you use the JSON it would show up as

Error on sending message from discord to mc

debug log show this error when message is sent from discord to mc:

`yarn run v1.22.5
$ tsc
Done in 1.62s.
yarn run v1.22.5
$ node build/index.js
[INFO] Using configuration file: ../config.json
[INFO] Using the Discord bot to send messages
[INFO] Using configuration for local log file at "/opt/valhesia/logs/latest.log"
[INFO] Authenticated with 127.0.0.1:25575
[DEBUG] Received response:
/opt/tools/shulker/build/Discord.js:199
nickname: message.member.nickname ? emoji_strip_1.default(message.member.nickname) : emoji_strip_1.default(message.author.username),
^

TypeError: Cannot read property 'nickname' of null
at Discord.makeMinecraftTellraw (/opt/tools/shulker/build/Discord.js:199:38)
at Discord. (/opt/tools/shulker/build/Discord.js:169:65)
at step (/opt/tools/shulker/build/Discord.js:33:23)
at Object.next (/opt/tools/shulker/build/Discord.js:14:53)
at fulfilled (/opt/tools/shulker/build/Discord.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:93:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`

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.