我需要一个命令,允许我同步特定类别中的每个通道,我的想法是使用for循环,但我不知道如何。我该怎么做。
如果你的机器人拥有管理频道权限,这样的东西应该可以工作。只需提供一个类别通道作为category
,这将允许您同步所有子通道:
Client.on('ready', () => {
// First retrieve your category channel. Plug in an ID here or provide your own value.
const category = Client.channels.cache.get('your category ID here');
// Get the category's children as an array.
// Iterating category.children itself was causing problems for me.
const channels = Array.from( category.children.cache.values() );
for( let channel of channels ){ // for each channel of channels...
channel.lockPermissions() // sync permissions
console.log(`Synced ${channel.id}`)
}
});
参考:discord.js指南