Coder Social home page Coder Social logo

carbonite's Introduction

Carbonite

A Discord Bot that takes code messages and converts them into beautiful images. Powered by Carbon.

Get it working

The repo is written in JavaScript. To run in you need to have node 16 installed. Follow these steps to get started:

git clone https://github.com/OSDG-IIITH/Carbonite.git
cd Carbonite
npm i
node index.js

Note that to run the bot, you need to set up a Discord bot in the Discord Developer Platform and get a bot token. Save this token in a file called .env at the root directory of the project as:

DISCORD_TOKEN=YOUR_TOKEN_HERE

In the channel, invite Carbonite. You can now invoke it using the carbonite keyword, followed by the code on a new line. For example, send the following message on the channel that Carbonite has access to:

carbonite
```
print("Hello World")
```

How does it work?

The Bot has 2 main parts:

  1. The Bot interface, powered by Discord.js v13, that handles receiving, parsing and sending messages.

  2. The "Carbonizer", powered by Puppeteer. It spawns a headless browser that modifies the Carbon webpage's contents to accomodate for the code, then screenshots the DOM element that has the prettified code image and returns a byte stream of the image data back to the bot to send to Discord.

Future Plans

  1. Add option to specify theme. Check Carbon for the list of avaiable themes.
  2. Add option to specify language. By default, it is on auto-detect, but this may lead to improper syntax highlighting.
  3. Delete the original message requesting the carbonification.
  4. Add a "Carbonite is typing..." prompt to Discord while the bot generates and sends the image.

carbonite's People

Contributors

dkapur17 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.