A Discord bot to create images of code with Carbon, inspired by Carbonara.
Invite Carbon Bot to your guild here.
- User uses the
/carbon
command in Discord. - Constructs a Carbon URI using the user's stored settings.
- Uses Microsoft Playwright to visit Carbon.
- Screenshots the created image.
- Post the image to Discord.
- Use the majority of Carbon's configuration settings through Discord.
- User settings are persisted in Redis.
- Creates images of any message quickly.
- Parses code blocks to provide the correct syntax hilighting.
The following commands are currently available.
Creates an image of the message's contents using the user's stored settings, if any.
First, Carbon Bot tries to find a code block (delimited by three back ticks, ```) in the message's contents, as well as the code block's language (specified after the opening back ticks, e.g. ```java) for syntax hilighting, in which case an image is created with the code block's content. If a code block could not be found, then the message's contents are stripped of any surrounding back ticks and used.
Argument Name | Description | Required |
---|---|---|
message_id |
The message's ID or link. | Yes |
/carbon <message_id>
Displays the help menu for all commands
Argument Name | Description | Required |
---|---|---|
command |
A command to display the help menu for. | No |
Currently, the only commands with sub-menus are
set
andunset
.
/help <command>?
/help
, /help set
Displays buttons to invite Carbon Bot
/invite
Displays your settings
/mysettings
Changes a default setting. View all changable settings by using /help set
.
Argument Name | Description | Required |
---|---|---|
setting |
The setting to change. | Yes |
value |
The value to change it to. | Yes |
/set <setting> <value>
/set font-family Monoid
, /set theme Hopscotch
, /set window-style outlined
Restores a setting to default
Argument Name | Description | Required |
---|---|---|
setting |
The setting to change. | Yes |
/unset <setting>
/unset font-family
, /unset theme
, /unset window-style
Carbon Bot is written in Java 16 and has the following dependencies.
The config.properties
file requires the following three properties.
discord.bot.token=bot token
discord.invite.uri=invite url
redis.uri=redis://localhost:6379
The IntelliJ code style files, which are a fork of
the Google Java Style Guide, are stored in
the .idea/codeStyles
directory.