【发布时间】:2022-01-02 08:23:51
【问题描述】:
我在 discord.js 上关注 tutorial,制作票务机器人。我已经仔细检查过,我仍然收到同样的错误:
TypeError:channel.updateOverwrite 不是函数
我查看了我能找到的所有 StackOverflow 问题,但没有一个对我有用。我也在 SO 之外进行了更深入的探索,仍然没有帮助。这是我的代码:
module.exports = {
name: 'ticket',
description: 'Open a ticket!',
async execute(client, message, args, cmd, Discord) {
// creates tickets
let channel = await message.guild.channels.create(
`ticket: ${message.author.tag}`,
{ type: 'text' }
);
await channel.setParent('912495738947260446');
// updates channel perms
channel.updateOverwrite(message.guild.id, {
SEND_MESSAGE: false,
VIEW_CHANNEL: false
});
channel.updateOverwrite(message.author, {
SEND_MESSAGE: true,
VIEW_CHANNEL: true
});
const reactionMessage = await channel.send('Thanks for opening a ticket! A staff member will be with you shortly. While you are here, please tell us why you opened this ticket.');
try {
await reactionMessage.react("????");
await reactionMessage.react("????️");
} catch(err) {
channel.send('Error sending emojis! Please tell a developer to check the console!');
throw err;
}
const collector = reactionMessage.createReactionCollector((reaction, user) => message.guild.members.cache.find((member) => member.id === user.id).hasPermission('ADMINISTRATOR'), {dispose: true});
collector.on('collect', (reaction, user) => {
switch (reaction.emoji.name) {
case "????":
channel.updateOverwrite(message.author, { SEND_MESSAGE: false, VIEW_CHANNEL: false});
channel.setname(`???? ${channel.name}`)
break;
case "????️":
channel.send('Deleting Channel in 10 seconds!');
setTimeout(() => channel.delete(), 10000);
break;
}
});
}
}
【问题讨论】:
-
尝试 channel.overwritePermissions 代替:stackoverflow.com/questions/62704976/…
标签: javascript node.js discord discord.js