本文介紹了如何為嵌入 Discord.js 制作隨機顏色的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
好的,所以在我的機器人中,我希望嵌入顯示為紅色和綠色(這兩者之間是隨機的),所以我想創(chuàng)建一些可以使這成為可能的東西類似:
const randomcolors = ['#008000', '#E50000']const randomizer = Math.floor((Math.random() * foreigncolors.length));
那我有
const embed= new Discord.MessageEmbed().setColor(foreigncolors[colorss])
但它只會發(fā)送綠色,我需要幫助
解決方案
沒有必要自己寫復(fù)雜的東西.相反,您可以使用:
Embed.setColor('RANDOM')
這是 discord.js
庫的內(nèi)置功能.?/p>
okay, so in my bot, i want the embeds to appear in red and green (random between those two) so i want to create something that will make this possible something like:
const randomcolors = ['#008000', '#E50000']
const randomizer = Math.floor((Math.random() * foreigncolors.length));
then i have
const embed= new Discord.MessageEmbed()
.setColor(foreigncolors[colorss])
but it will only send green color, I need help
解決方案
There is no need to write something complex all by yourself. Instead, you can use:
Embed.setColor('RANDOM')
This is an inbuilt feature of the discord.js
library.
這篇關(guān)于如何為嵌入 Discord.js 制作隨機顏色的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!