我不知道为什么permissionOverwrites不适合我。这里没有错误。任何人的权限都不会更改。我认为问题出在这里:{allow: 'VIEW_CHANNEL', id: userId,}。我想问题出在身份上。我希望有人能发现我哪里搞错了。
module.exports = (client, Discord, chalk, message, args) => {
const channelId = '799339037306912808'
const getEmoji = (emojiName) =>
client.emojis.cache.find((emoji) => emoji.name === emojiName)
const emojis = {
golden_ticket: 'rules',
}
const handleReaction = (reaction, user, add) => {
if (user.id === '799652033509457940') {
return
}
const emoji = reaction._emoji.name
const { guild } = reaction.message
const userName = user.username
const userId = guild.members.cache.find((member) => member.id === user.id)
const categoryId = '802172599836213258';
if (add) {
reaction.users.remove(userId)
reaction.message.guild.channels
.create(`${userName}`, {
type: 'text',
permissionOverwrites: [
{
allow: 'VIEW_CHANNEL',
id: userId,
}
],
})
.then((channel) => {
channel.setParent(categoryId)
channel => ticketChannelId = channel.id;
message.ticketChannelId.send('cs');
})
} else {
return;
}
}
client.on('messageReactionAdd', (reaction, user) => {
if (reaction.message.channel.id === channelId) {
handleReaction(reaction, user, true)
}
})
}发布于 2021-01-27 19:17:14
在这里,最好指定覆盖的类型。另外,"allow“应该是一个数组。
permissionOverwrites: [
{
allow: [ 'VIEW_CHANNEL' ],
id: userId,
type: 'member'
}
],它应该可以解决您的问题。请注意,默认情况下,每个人都可以读取您的频道,请使用:
permissionOverwrites: [
{
deny: ['VIEW_CHANNEL'],
id: reaction.message.guild.id,
type: 'role'
},
{
allow: ['VIEW_CHANNEL'],
id: userId,
type: 'member'
}
],因此,除了管理员和用户之外,所有人都看不到频道
https://stackoverflow.com/questions/65916920
复制相似问题