Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript TypeError[无效的类型]:提供的参数既不是用户也不是角色Discord.js_Javascript_Permissions_Discord.js - Fatal编程技术网

Javascript TypeError[无效的类型]:提供的参数既不是用户也不是角色Discord.js

Javascript TypeError[无效的类型]:提供的参数既不是用户也不是角色Discord.js,javascript,permissions,discord.js,Javascript,Permissions,Discord.js,当我第一次编写这些函数时,我没有意识到.overwritePermissions()会删除设置的权限。注意到错误后回到我的代码,我尝试更新joinPrivateChannel()以使用.updateOverwrite(),这样就不会删除创建频道的用户的频道权限 作为参考,第一个函数createPrivateChannel()每次都能完美地工作,而第二个函数给出了错误TypeError[无效类型]:提供的参数既不是用户也不是角色。。我尝试硬编码用户ID、成员变量、角色ID和角色变量(每种方式都不同

当我第一次编写这些函数时,我没有意识到
.overwritePermissions()
会删除设置的权限。注意到错误后回到我的代码,我尝试更新
joinPrivateChannel()
以使用
.updateOverwrite()
,这样就不会删除创建频道的用户的频道权限

作为参考,第一个函数
createPrivateChannel()
每次都能完美地工作,而第二个函数给出了错误
TypeError[无效类型]:提供的参数既不是用户也不是角色。
。我尝试硬编码用户ID、成员变量、角色ID和角色变量(每种方式都不同),但都不起作用。我很乐意提供/澄清任何要求的信息,感谢您抽出时间

async function createPrivateChannel(serverId, channelName, message) {
  const guild = await client.guilds.fetch(serverId);
  const everyoneRole = guild.roles.everyone;
  const staffRole = guild.roles.Owner;
  const channel = await guild.channels.create(channelName, 'lobby')
  await channel.setParent(lobby_category);
  await channel.overwritePermissions([
    {type: 'member', id: message.author.id, allow: [Permissions.FLAGS.VIEW_CHANNEL]},
    {type: 'role', id: everyoneRole.id, deny: [Permissions.FLAGS.VIEW_CHANNEL]},
  ]);
  channel.send('+start');
  return;
}

async function joinPrivateChannel(serverId, channel, message){
    const guild = await client.guilds.fetch(serverId);
    await channel.updateOverwrite([
        {type: 'member', id: message.author.id, allow: [Permissions.FLAGS.VIEW_CHANNEL]},
    ]);
};

基于djs文档的
updateOverwrite
没有任何数组语法。可能您只是误解了参数

updateOverwrite
具有以下参数:(userOrRole、options、reason)

就你而言

wait channel.updateOverwrite(message.author.id,
{VIEW_CHANNEL:true},
);