colorize your discord bot messages using ANSI !
npm install dischalk
To utilize ANSI colors and styles in your discord bot messages, follow these instructions:
const dischalk = require('dischalk');
const myColor = dischalk.red; // red style object
const myModifier = dischalk.bold; // bold style object
const styledText = dischalk.apply('Hello, world!', myColor, myModifier);
const { Client, GatewayIntentBits } = require('discord.js');
const dischalk = require('dischalk');
const client = new Client({ intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]});
client.on('messageCreate', async message => {
if (message.content === 'ping') {
message.reply(
dischalk.apply('Pong!', dischalk.pink, dischalk.bgFireflyDarkBlue, dischalk.bold, dischalk.underline)
);
}
})
client.login('token');
- apply(text, ...styles) applies one or more styles to a specified text string.
- text (string): The text to be styled.
- ...styles (array of dischalk objects): Style directives to be applied to the text.
- (string): Styled text.
const styledText = dischalk.apply('Hello, world!', dischalk.green, dischalk.bold);
normal
bold
underline
gray
red
green
yellow
blue
pink
cyan
white
bgFireflyDarkBlue
bgOrange
bgMarbleBlue
bgGreyishTurquoise
bgGray
bgIndigo
bgLightGray
bgWhite
Contributions to this project are welcome! Feel free to open issues, submit pull requests, or suggest improvements.
This library is released under the MIT License. See LICENSE file for more informations.
If you have any questions or need further assistance, please contact @hackirby:matrix.org