This is a Discord bot that allows users to automatically create and manage voice channels. It is written in Rust using the Serenity library. It is currently in development.
The bot is currently not hosted anywhere, so you will have to host it yourself. To do so, you will need to have Rust and Postgres installed. You will also need to create a Discord bot and invite it to your server. You can find instructions on how to do that here. Read the installation guide here for more details.
The purpose of this bot is to allow users to create, manage and delete voice channels automatically as user demand ebbs and flows. This is useful for servers that have a large number of users that are not always active at the same time. It is also useful for servers that have a large number of users that are active at the same time, but are not always active in the same channels.
The bot automatically creates and deletes channels using the concept of parent and child channels. A parent channel is a channel that will spawn a new child anytime someone joins the parent channel and move the user to the child channel. A child channel is a channel that will be deleted when it is empty. Parent channels creates child channels using a template in order to set the names of the children.
Parent channels use templates to set the names of their child channels. Templates are strings of text that contain special directives in curly braces that are replaced with values when the child channel is created. Curly braces may be escaped by using two curly braces in a row. The following directives are available:
{#}
: The number of the child channel. This is incremented for each child channel created, and decremented as children are deleted. It is guaranteed that two living children will never have the same number.{%}
: The total number of sibling channels currently living (count also includes self).
Gaming channel number: {#}
Gaming channel number: {#}/{%}
Curly braces: {{}}
All commands are invoked by sending a message in your server prefixed with a prefix followed by a command name and a whitespace delimited set of arguments. The prefix is either the DEFAULT_PREFIX
or your servers configured prefix. DEFAULT_PREFIX
will always work in addition to whatever server specific prefixes have been configured.The following commands are available:
Creates a new voice channel with the given name. The channel will be created in the root category of your server. Requires two arguments, the name of the channel and the template to use when creating child channels.
Changes the template used by the given channel. Requires two arguments, the ID of the channel and the new template. Does NOT require the channel to be a parent channel to work.
vc/alter_channel
, vc/alter_parent
Changes the capacity of child channels created by the given parent channel. Requires two arguments, the ID of the channel and the new capacity.
vc/change_cap
, vc/set_cap
, vc/set_capacity
Resets the capacity of child channels created by the given parent channel to be unlimited. Requires one argument, the ID of the channel.
vc/reset_cap
Lists all the template channels in you guild. Ordered by parent.
vc/list_template
, vc/list_templates
, vc/list_template_channel
, vc/list
, vc/list_channels
, vc/list_channel
Changes the prefix used to invoke the bot in your server. Requires one argument, the new prefix.
vc/set_prefix
Resets the prefix used to invoke the bot in your server to the default prefix.
The bot is configured using environment variables.
DISCORD_TOKEN
: The token of your Discord bot.DISCORD_CLIENT_ID
: The client ID of your Discord bot.DATABASE_URL
: The URL of your PostgreSQL database.DATABASE_USER
: The username used in your PostgreSQL database.DATABASE_PASSWORD
: The password of your PostgreSQL database. This variable is optional if you do not have a password set.DATABASE_ROLE
: The role used in of your PostgreSQL database.
RUST_LOG
: The log level of the bot. See details here. Defaults tovoice_channel_manager=debug,info
.DISCORD_PREFIX
: The prefix used to invoke the bot. Defaults tovc/
.
- Clone the repository.
- Create a .env file in the root of the repository and fill it with the required environment variables. See the Configuration section for more details. A .env file is not required if you set the environment variables in some other way.
- Create and migrate the database by running
sqlx database setup
in the root of the repository. - Run the bot by running
cargo run
orcargo run --release
in the root of the repository. You can also use the included dockerfile to run the bot in a docker container. Please note that the database must be run separately if you use the dockerfile.