This page looks best with JavaScript enabled

Hex Parser in Data Cube Discord Bot

 ·   ·  ☕ 1 min read

    There are a number of ways to represent color in text. One of the more common versions is to use hex codes to represent the value.

    The standard format for a hex value is “#RRGGBB” where R, G and B represent the red, green and blue channels of the color in base 16. This gives us a range from 0-255 for each color channel.

    We’re going to implement a way to parse these colors from scratch. There are other, more efficient ways to do this but it’ll give us a good opportunity to dive a bit deeper into the concept. The final goal here is to add support for our Discord Data Cube bot to consume hex colors. This means you can send custom colors to Data Cube easily.

    Our implementation of our hex parser here is a more manual approach than is necessary. You can accomplish the same effect using a number of simpler implementations including the UInt32.TryParse(). Simpler, more production ready implementations can be found here:

    Come play with the Data Cube bot in the World of Zero Discord channel:

    Sam Wronski
    Sam Wronski
    Maker of things, currently helping build cloud things @ Google. World of Zero is a personal project disconnected from my professional work. Lets make something awesome together!