If you are a Minecraft server owner and are looking for ways to enhance your player’s experience, you might want to consider creating a custom Discord bot. Discord is a popular communication platform used by gamers and offers several unique features that are missing in other social media platforms. With a custom bot, you can automate tasks and offer several commands that can help players on your server. In this blog post, we will explore one such bot, ‘Sharon’, that has been developed for a Minecraft Bedrock server.
Sharon is a custom Discord bot that has been developed to automate several tasks on the Minecraft Bedrock server. The bot has several commands that allow players to get information about the server, whitelist players, and get their playtime. One of the unique features of Sharon is the “!on” command, which is a custom player-tracking system that interacts with the server’s console. This feature is rare for unaltered, vanilla Bedrock servers directly from Mojang and can only be achieved by a scripted interaction with the server’s console. This feature adds value to the Minecraft Bedrock server and makes Sharon a helpful tool for players.
Apart from the “!on” command, Sharon has several other commands that can be used by players on the server. These commands range from simple ones like “!hi” to more advanced ones like “!whitelist” and “!playtime.” The bot can retrieve data from the server’s console or a MySQL database, making it a versatile tool for server owners. Since Sharon is a custom bot, it can be updated whenever the owner pleases without following any particular release patterns. This flexibility allows for experimentation and evolution of the bot based on user interaction.
Developing a custom Discord bot like Sharon requires knowledge of programming languages like JavaScript, Node.js/Python, Bash, Expect, and various other command-line and development tools. Discord’s API is well-written and easy to learn, making it a viable option for those who are new to bot development. With the Node-powered Discord.js library, developers can create and deploy their bots in a matter of minutes.
Code sample
Discord’s API as well written and easy to learn. Below there is an example of simple command’s code.
module.exports =
name: 'ping'
description: 'Ping!'
cooldown: .3
execute: (client, config, message, args) ->
message.channel.send 'Pong.'
.catch (error) -> client.helpers.error_message_send error, {command: @.name}; return
return
Below there is an excerpt from my sought-after !whitelist command. Whitelisting in vanilla Bedrock can only be performed via command-line and can be a pain in the neck for server owners.
# [...]
send = 'whitelist add "' + gtag + '"'
expect = '"Player already in whitelist*" "Failed*" "No targets*"' # the array of expected strings sending as space separated quoted strings
else if subcommand == 'remove'
send = 'whitelist remove "' + gtag + '"'
expect = '"Player removed from whitelist*" "Player not in whitelist*"'
message.channel.send client.helpers.random([ 'okay, lemme see', 'oof, back to work', 'communicating with MC server', 'talking to Minecraft Gods', 'sure, why not']) + " ...⏳"
.catch (error) -> client.helpers.error_message_send error, err_msg_send_args; return
client.libs.exec config.abspath + '/mc-connect/mc-connect.exp.sh \'' + send + '\' \'' + expect + '\'', (error, stdout, stderr) ->
if error
console.log 'error: ' + error.message
message.channel.send "Wasn't able to do the whitelist thingy this time.\rYou can always try again #{message.author} ..."
.catch (error) -> client.helpers.error_message_send error, err_msg_send_args; return
return
if stderr
console.log 'stderr: ' + stderr
message.channel.send "Wasn't able to do the whitelist thingy this time.\rYou can always try again #{message.author} ..."
.catch (error) -> client.helpers.error_message_send error, err_msg_send_args; return
return
# handle responses from the expect script
# ---- add
if stdout.includes('Player added to whitelist’)
# [...]
The corresponding except code follows
#!/usr/bin/expect --
log_user 0
# log_file /var/sharon_log.log
set timeout 5
spawn ssh “*********"
expect "*$ "
# set the prompt to a known value
#send "PS1='>'\r"
#expect -re {>$}
send "docker attach --detach-keys=Q emer\r"
expect "DEBU*"
log_user 1
send "[lindex $argv 0]\r"
foreach arg [lindex $argv 1] {
expect "$arg"
}
log_user 0
send "Q"
# expect ">$"
expect "*$ "
send "exit\r"
expect eof
exit
In conclusion, creating a custom Discord bot like Sharon can significantly enhance the experience of players on a Minecraft Bedrock server. The bot can automate tasks, offer several commands, and retrieve data from the server’s console or a MySQL database. Additionally, developing a custom bot is a fun way to learn programming languages and command-line tools. If you are a Minecraft server owner, you should consider creating a custom Discord bot like Sharon to improve your player’s experience.
If you play Emerland I’m giving you a diamond block for finding this post lol :D
Why “Sharon”
The name “Sharon” was inspired by two separate sources. The first being a TV sketch by Rowan Atkinson, and the second, a questionable prank emergency call.
Add a comment