Packages

Mineflayer bindings for gleam

Current section

Files

Jump to
mineflayer src mineflayer bot.gleam
Raw

src/mineflayer/bot.gleam

import gleam/option.{type Option}
pub type BotAuthType {
Offline
Mojang
Microsoft
}
pub type BotOptions {
BotOptions(
auth: BotAuthType,
username: String,
password: Option(String),
host: String,
port: Int,
version: String
)
}
pub type Bot
pub type BotNewError {
DeprecatedAuth(BotAuthType)
UnsupportedProtocolVersion(String)
UnknownError(String)
}
pub type ConnectError {
EACCES
EPERM
EADDRINUSE
EADDRNOTAVAIL
EAFNOSUPPORT
EAGAIN
EALREADY
EBADF
ECONNREFUSED
EFAULT
EINPROGRESS
EINTR
EISCONN
ENETUNREACH
ENOTSOCK
EPROTOTYPE
ETIMEDOUT
UnknownConnectErr
}
pub type DNSError {
NoData /// `dns.NODATA`: DNS server returned an answer with no data.
Formerr /// `dns.FORMERR`: DNS server claims query was misformatted.
ServerFail /// `dns.SERVFAIL`: DNS server returned general failure.
NotFound /// `dns.NOTFOUND`: Domain name not found.
NotImplemented /// `dns.NOTIMP`: DNS server does not implement the requested operation.
Refused /// `dns.REFUSED`: DNS server refused query.
BadQuery /// `dns.BADQUERY`: Misformatted DNS query.
BadName /// `dns.BADNAME`: Misformatted host name.
BadFamily /// `dns.BADFAMILY`: Unsupported address family.
BadResponse /// `dns.BADRESP`: Misformatted DNS reply.
ConnectionRefused /// `dns.CONNREFUSED`: Could not contact DNS servers.
Timeout /// `dns.TIMEOUT`: Timeout while contacting DNS servers.
EOF /// `dns.EOF`: End of file.
File /// `dns.FILE`: Error reading file.
NoMem /// `dns.NOMEM`: Out of memory.
Destruction /// `dns.DESTRUCTION`: Channel is being destroyed.
BadString /// `dns.BADSTR`: Misformatted string.
BadFlags /// `dns.BADFLAGS`: Illegal flags specified.
NoName /// `dns.NONAME`: Given host name is not numeric.
BadHints /// `dns.BADHINTS`: Illegal hints flags specified.
NotInitialized /// `dns.NOTINITIALIZED`: c-ares library initialization not yet performed.
LoadIPHLPAPI /// `dns.LOADIPHLPAPI`: Error loading iphlpapi.dll.
AddrGetNetworkParams /// `dns.ADDRGETNETWORKPARAMS`: Could not find GetNetworkParams function.
Cancelled /// `dns.CANCELLED`: DNS query cancelled.
TryAgainLater /// `EAI_AGAIN`: The name server returned a temporary failure indication. Try again later.
UnknownDNSError
}
pub type BotRuntimeError {
DNSError(DNSError)
ConnectError(ConnectError)
}
@external(javascript, "../mineflayer_bot_ffi.mjs", "create_bot")
pub fn new(bot_options: BotOptions) -> Result(Bot, BotNewError)
@external(javascript, "../mineflayer_bot_ffi.mjs", "end_bot")
pub fn end(bot: Bot, reason: Option(String)) -> Nil
@external(javascript, "../mineflayer_bot_ffi.mjs", "send_chat")
pub fn send_chat(bot: Bot, message: String) -> Bot