Carbon

TextDisplay

A component for displaying text content in messages.

The TextDisplay component is the primary way to show text content in your messages. It's a simple but essential component that can be used standalone or within other components like Section or Container.

Component Structure

A TextDisplay is defined by its text content. It's the most basic component type and serves as the foundation for displaying information in your messages.

Creating a TextDisplay

To create a text display, you simply instantiate the TextDisplay class with your desired text:

src/components/text.ts
import { TextDisplay } from "@buape/carbon";
 
const text = new TextDisplay("Hello, world!");

Usage Example

Here's how you might use TextDisplay in a command:

src/commands/text-example.ts
import { Command, type CommandInteraction } from "@buape/carbon";
import { TextDisplay, Section } from "@buape/carbon";
 
class TextExample extends Command {
	name = "text"
	description = "Example of using TextDisplay components"
 
	async run(interaction: CommandInteraction) {
		const section = new Section(
			[
				new TextDisplay("This is the first line of text."),
				new TextDisplay("This is the second line of text.")
			]
		)
 
		await interaction.reply({
			components: [section]
		})
	}
}
Edit on GitHub

Last updated on

On this page