Discworldmc is a Discord bot that provides various commands to manage and monitor Minecraft servers. It allows users to start, stop, and check the status of servers directly from Discord.
The following commands are available for interacting with the bot on Discord:
/dw server list
-> returns a list of all servers and if they are currently running/dw server start <server>
-> starts a server/dw server stop <server>
-> stops a server/dw server status <server>
-> returns a detailed status of a server
To add the bot to your Discord server, click on the following link:
https://discord.com/oauth2/authorize?client_id=<app_id>&scope=bot%20applications.commands&permissions=274877908992
Make sure to replace <app_id> with the actual application ID of the bot. The bot requires the following permissions:
- send messages
- send messages in threads
The permissions number to be granted is 274877908992.
Discworldmc is designed to work specifically with Kubernetes for managing Minecraft servers. Follow the steps below to set up Discworldmc within your Kubernetes environment:
- Ensure that you have a Kubernetes cluster set up and running.
- Deploy your Minecraft servers as Kubernetes deployments within a specific namespace.
- Create a role within the namespace to grant Discworldmc the necessary permissions. Use the following YAML configuration as an example:
Example manifest file
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: minecraft
name: discworldmc-role
rules:
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get", "list"]
- apiGroups: ["apps"]
resources: ["deployments/scale"]
verbs: ["update"]
Example manifest file
apiVersion: v1
kind: ServiceAccount
metadata:
name: discworldmc-service-account
namespace: minecraft
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: discworldmc-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: discworldmc-role
subjects:
- kind: ServiceAccount
name: discworldmc-service-account
namespace: minecraft
Example manifest file
apiVersion: apps/v1
kind: Deployment
metadata:
name: discworldmc
namespace: minecraft
labels:
app: discworldmc
spec:
replicas: 1
selector:
matchLabels:
app: discworldmc
template:
metadata:
labels:
app: discworldmc
spec:
containers:
- name: discworldmc
image: rudxde/discworldmc:build.45
env:
- name: CONFIG_FILE_PATH
value: /path/to/config-file.json5
volumeMounts:
- name: config-volume
mountPath: /path/to/config-file.json5
subPath: config-file.json5
volumes:
- name: config-volume
secret:
secretName: discworldmc-config-secret
By following these steps, you can successfully integrate Discworldmc with your Kubernetes environment, allowing you to manage your Minecraft servers using Discord commands.
The logic of the permissions in the provided role configuration is based on a hierarchical structure where the presence of an asterisk (*) at any part of the permission grants access to all sub-permissions within that category.
Let's consider the example role configuration again:
{
// [...]
"roles": [
{
"roleId": "default",
"permissions": [
"dw.server.list",
"dw.server.status.*"
]
},
{
"roleId": "<role id>",
"permissions": [
"dw.server.start.*"
]
},
{
"roleId": "<role id>",
"permissions": [
"dw.server.start.server1",
"dw.server.start.server2"
]
},
{
"roleId": "<role id>",
"permissions": [
"dw.server.stop.*"
]
}
]
}
In this configuration:
-
The default role has the permission
dw.server.list
, which allows users with this role to use the/dw server list
command. Additionally, it has the permissiondw.server.status.*
. The asterisk (*
) at the end indicates that this role has access to all sub-permissions under thedw.server.status
category. For example, it grants access to commands like/dw server status <server_id>
for any server. -
The
<role id>
role (replace<role id>
with the actual Discord role ID) has the permissiondw.server.start.*
. Again, the asterisk (*
) at the end indicates that this role has access to all sub-permissions under thedw.server.start
category. It allows users with this role to use commands like/dw server start <server_id>
for any server. -
The
<role id>
role (replace<role id>
with the actual Discord role ID) now has explicit permissions for starting two specific servers:dw.server.start.server1
anddw.server.start.server2
. This means users with this role can use the/dw server start server1
and/dw server start server2
commands, but not other server start commands. -
The
<role id>
role (replace<role id>
with the actual Discord role ID) has the permissiondw.server.stop.*
. This permission grants access to all sub-permissions under thedw.server.stop
category, allowing users with this role to use commands like/dw server stop <server_id>
for any server.
In summary, when a role is assigned a permission that ends with an asterisk (*
), it implies that the role has access to all sub-permissions under that category. This wildcard-based approach simplifies the permission management by granting broader access to related commands without explicitly listing each sub-permission.
We welcome contributions to Discworldmc. If you encounter any issues or have ideas for improvements, please open an issue or submit a pull request on the GitHub repository.