message.guild.me.displayColor(用于将嵌入的颜色设置为机器人最高角色的颜色)在commands文件夹中的文件中不起作用。我尝试使用:
<body>
<div id="app">
<div id="slider">
<div class="logo">MovieApp</div>
<div class="image"></div>
<div class="content">
<div class="title"><h3>- Title -</h3></div>
<div class="description">
<p>
description description description description description
description description description description description
description description description description description
description description description description description
description description description description description
description description description description description
description description description description description
description description description description description
description description description description description
description description description
</p>
</div>
<button>More</button>
</div>
</div>
<div id="navigation">
<ul class="nav">
<li data-category="top" class="nav-item active">Top</li>
<li data-category="comedy" class="nav-item">Comedy</li>
<li data-category="horror" class="nav-item">Horror</li>
<li data-category="documentary" class="nav-item">Documentary</li>
<li data-category="thriller" class="nav-item">Thriller</li>
<li data-category="musical" class="nav-item">Musical</li>
</ul>
<div class="search"></div>
</div>
<div id="movies">
<div class="slider-btns">
<i class="fa fa-angle-left"></i>
<i class="fa fa-angle-right"></i>
</div>
<div class="categories">
<div data-category="comedy" class="category">
<div class="movies">
<div data-item="1" class="movie active">
<div class="image"></div>
<div class="title">Title 1</div>
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
<div data-item="2" class="movie">
<div class="image"></div>
<div class="title">Title 2</div>
<div class="content">Content</div>
</div>
<div data-item="3" class="movie">
<div class="image"></div>
<div class="title">Title 3</div>
<div class="content">
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
</div>
<div data-item="4" class="movie">
<div class="image"></div>
<div class="title">Title 4</div>
<div class="content">
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
</div>
<div data-item="5" class="movie">
<div class="image"></div>
<div class="title">Title 5</div>
<div class="content">
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
</div>
</div>
</div>
<div data-category="horror" class="category">
<div class="movies">
<div data-item="1" class="movie">
<div class="image"></div>
<div class="title">Title 1</div>
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
<div data-item="2" class="movie">
<div class="image"></div>
<div class="title">Title 2</div>
<div class="content">Content</div>
</div>
<div data-item="3" class="movie">
<div class="image"></div>
<div class="title">Title 3</div>
<div class="content">
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
</div>
<div data-item="4" class="movie">
<div class="image"></div>
<div class="title">Title 4</div>
<div class="content">
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
</div>
<div data-item="5" class="movie">
<div class="image"></div>
<div class="title">Title 5</div>
<div class="content">
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
</div>
</div>
</div>
<div data-category="documentary" class="category">
<div class="movies">
<div data-item="1" class="movie">
<div class="image"></div>
<div class="title">Title 1</div>
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
<div data-item="2" class="movie">
<div class="image"></div>
<div class="title">Title 2</div>
<div class="content">Content</div>
</div>
<div data-item="3" class="movie">
<div class="image"></div>
<div class="title">Title 3</div>
<div class="content">
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
</div>
<div data-item="4" class="movie">
<div class="image"></div>
<div class="title">Title 4</div>
<div class="content">
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
</div>
<div data-item="5" class="movie">
<div class="image"></div>
<div class="title">Title 5</div>
<div class="content">
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
</div>
</div>
</div>
<div data-category="thriller" class="category">
<div class="movies">
<div data-item="1" class="movie">
<div class="image"></div>
<div class="title">Title 1</div>
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
<div data-item="2" class="movie">
<div class="image"></div>
<div class="title">Title 2</div>
<div class="content">Content</div>
</div>
<div data-item="3" class="movie">
<div class="image"></div>
<div class="title">Title 3</div>
<div class="content">
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
</div>
<div data-item="4" class="movie">
<div class="image"></div>
<div class="title">Title 4</div>
<div class="content">
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
</div>
<div data-item="5" class="movie">
<div class="image"></div>
<div class="title">Title 5</div>
<div class="content">
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
</div>
</div>
</div>
<div data-category="musical" class="category">
<div class="movies">
<div data-item="1" class="movie">
<div class="image"></div>
<div class="title">Title 1</div>
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
<div data-item="2" class="movie">
<div class="image"></div>
<div class="title">Title 2</div>
<div class="content">Content</div>
</div>
<div data-item="3" class="movie">
<div class="image"></div>
<div class="title">Title 3</div>
<div class="content">
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
</div>
<div data-item="4" class="movie">
<div class="image"></div>
<div class="title">Title 4</div>
<div class="content">
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
</div>
<div data-item="5" class="movie">
<div class="image"></div>
<div class="title">Title 5</div>
<div class="content">
<div class="content">
<p>Content</p>
<button>More</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
但这似乎不起作用,但是message.guild.me.displayColor仅在index(main)文件中有效。也许这是我包含文件的方式?如果是这样,您可以查看我如何包含这些文件
let color = message.guild.me.displayColor
如果有人帮助我,我将不胜感激
答案 0 :(得分:0)
虽然您阅读文件的方式对我来说有点不合理,但我认为这不是问题所在。 注意:如果未执行命令,请尝试用此命令替换它。您可以使用简单的console.log("works")
轻松检查命令是否正常工作。
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
};
现在是您的实际问题。您设置颜色的方法不起作用,因为displayColor
会以10为底色返回颜色。要在嵌入中使用高级角色颜色,您需要使用displayHexColor
,因为嵌入不能使用10以底色。 / p>
let color = message.guild.me.displayHexColor;