Skip to content

TypeError when using realms in createBot #3587

Open
@abic

Description

@abic
  • [ X] The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 4.26.0 (though I've hit the same issue for about 3 months)
  • server: Minecraft Realms
  • node: v22.12.0

Detailed description of a problem

Using a simple example code, attempting to connect to a local server with username and password does not result in any TypeErrors. Changing the example code to using realms with a pickRealms function results in a TypeError when loading the game.js plugin.

(node:39305) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
/path/to/project/node_modules/mineflayer/lib/plugins/game.js:87
  bot._client.registerChannel(brandChannel, ['string', []])
              ^

TypeError: bot._client.registerChannel is not a function
    at inject (/path/to/project/node_modules/mineflayer/lib/plugins/game.js:87:15)
    at /path/to/project/node_modules/mineflayer/lib/plugin_loader.js:41:7
    at Array.forEach (<anonymous>)
    at injectPlugins (/path/to/project/node_modules/mineflayer/lib/plugin_loader.js:40:16)
    at EventEmitter.onInjectAllowed (/path/to/project/node_modules/mineflayer/lib/plugin_loader.js:12:5)
    at Object.onceWrapper (node:events:638:28)
    at EventEmitter.emit (node:events:524:28)
    at Timeout._onTimeout (/path/to/project/node_modules/mineflayer/lib/loader.js:128:26)
    at listOnTimeout (node:internal/timers:594:17)
    at process.processTimers (node:internal/timers:529:7)

What did you try yet?

I tried a simple npm install mineflayer with the echo example code in README.md.
I then changed the createBot to use the realms option with pickRealms.

Your current code

const mineflayer = require('mineflayer')

const bot = mineflayer.createBot({
  username: 'EMAIL HIDDEN,
  auth: 'microsoft',
  realms: {
    pickRealm: (realms) => realms[0]
  }
})

bot.on('chat', (username, message) => {
  if (username === bot.username) return
  bot.chat(message)
})

// Log errors and kick reasons:
bot.on('kicked', console.log)
bot.on('error', console.log)

Expected behavior

A request to open a browser to authenticate to Microsoft for the Microsoft authentication for Realms.

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stage1just created by someone new to the project, we don't know yet if it deserves an implementation / a fpossible bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions