CSS 不和谐的颜色文本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41730308/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 12:21:43  来源:igfitidea点击:

Color text in discord

cssnode.jsdiscord

提问by nonerth

My goal is to partly color a text. I know I can use .sendCode("css","this is my message");which we'll make my text yellow but I don't want my whole text to be yellow.

我的目标是部分着色文本。我知道我可以使用.sendCode("css","this is my message");它使我的文本变黄,但我不希望我的整个文本变黄。

Perhaps I could create another .css file and then call it from my JavaScript file but as I am inexperienced with JavaScript I would like some help with it. I think that's the fastest way to do it.

也许我可以创建另一个 .css 文件,然后从我的 JavaScript 文件中调用它,但由于我对 JavaScript 缺乏经验,因此我需要一些帮助。我认为这是最快的方法。

回答by Fabricio20

Discord doesn't allow colored text.Though, currently, you have two options to "mimic" colored text.

Discord 不允许使用彩色文本。不过,目前,您有两个选项可以“模仿”彩色文本。

Option #1 (Markdown code-blocks)

选项#1(Markdown 代码块)

Discord supports Markdownand uses highlight.jsto highlight code-blocks. Some programming languages have specific color outputs from highlight.js and can be used to mimic colored output.

Discord 支持Markdown并使用highlight.js来突出显示代码块。某些编程语言具有来自 highlight.js 的特定颜色输出,可用于模拟彩色输出。

To use code-blocks, send a normal message in this format (Which follows Markdown's standard format).

要使用代码块,请以这种格式发送普通消息(遵循 Markdown 的标准格式)。

```language
message
```

Languages that currently reproduce nice colors: prolog (red/orange), css (yellow).

当前重现漂亮颜色的语言:prolog(红色/橙色)、css(黄色)。

Option #2 (Embeds)

选项#2(嵌入)

Discord now supports Embeds and Webhooks, which can be used to display colored blocks, they also support markdown. For documentation on how to use Embeds, please read your lib's documentation.

Discord 现在支持 Embeds 和 Webhooks,可用于显示彩色块,它们也支持 Markdown。有关如何使用 Embeds 的文档,请阅读您的 lib 文档。

(Embed Cheat-sheet)
Embed Cheat-sheet

(嵌入备忘单)
嵌入备忘单