This is Discord bot that transpiles Civet code into TypeScript or JavaScript.
The bot automatically responds to messages containing ```
code blocks
with languages of
```civet
: regular Civet code, converted to TypeScript and Prettified.```coffee
: CoffeeScript-compatibility mode: automatically prepend"civet coffeeCompat"
.```civet-raw
or```coffee-raw
: Don't run Prettier; give the raw output from the Civet transpiler.```civet-js
or```coffee-js
: Ask Civet to convert to JavaScript instead of TypeScript.```civet-raw-js
or```coffee-raw-js
: Ask Civet to convert to JavaScript instead of TypeScript, and don't run Prettier.
You can include multiple code blocks. If the total output size is large, it will switch from inlined code to file attachments.
You can edit your messages after initial sending, and the bot its response. If you delete a message or edit it to remove all relevant code blocks, the bot will delete its response (and will no longer consider edits to that message).
In addition, you can use the /civet
slash command to transpile Civet code,
with similar options. If you set the private
option to True, you will get a
private response, and not clutter the channel you are in.
- Create a Discord bot
- Invite the bot to your server
with permissions 277025393664 (as listed below),
via a link like
https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&permissions=277025401856&scope=bot%20applications.commands
- Read Messages/View Channels
- Send Messages
- Send Messages in Threads
- Manage Messages
- Use Slash Commands
- Add the server to desired channels
- Use Node >= 18
- Create an
.env
file like .env.example:DISCORD_TOKEN=your-long-token
pnpm install
pnpm build
to producedist/index.js
pnpm start
ornode dist/index.js
to start bot- Whenever the process is running, the bot is up
To permanently run the bot in the background, we recommend pm2:
npm install pm2@latest -g
pm2 startup
(and follow instructions)- To run the bot and automatic upgrading of Civet:
pm2 start bot.config.js
- To run just the bot:
pm2 start bot.config.js --only civet-discord
- Restart the bot (e.g., when updating the bot):
pm2 restart civet-discord