我希望我的机器人每10秒钟编辑一次角色的颜色。这是我的代码:
client.on("ready", () => {
const Guild = client.guilds.cache.get("729208348884467735");
if (!Guild) return console.error("Couldn't find the guild.");
const Role = Guild.roles.cache.find(role => role.name == "Admin");
if (!Role) return console.error("Couldn't find the role.");
var colors = ['#8585ff','#fff681','#a073fd','#fd73b9'];
var random = Math.floor(Math.random() * colors.length);
Role.edit ({
color: colors[random]
})
}, 5000);
client.on("ready", () => {
const Guild = client.guilds.cache.get("729208348884467735");
var c = ['#8585ff','#fff681','#a073fd','#fd73b9', '#2c2f33', '#99aab5']
const Role = Guild.roles.cache.find(role => role.name == "Admin");
var outputc = c[Math.floor(Math.random()*c.length)];
setInterval(() => {
Role.edit({
color: outputc
})
}, 10000);
console.log('Sucessfully Changed')
});
我希望我的机器人按时间间隔更改它。因此我添加了setInterval。但是,它仅在启动时更改,然后颜色不变。你能帮我吗?预先感谢。