Por que estou recebendo: TypeError: canal.updateOverwrite não é uma função

0

Pergunta

Eu estou seguindo um tutorial sobre discord.js, fazendo um bilhete de bot. Eu tenho verificou duas vezes e eu ainda estou recebendo o mesmo erro:

TypeError: canal.updateOverwrite não é uma função

Eu olhei por cima de todos os StackOverflow perguntas que eu poderia encontrar, mas nenhum funcionou para mim. Eu também exploraram um pouco mais fora ISSO, ainda não há ajuda. Aqui é o meu código:

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("
discord discord.js javascript node.js
2021-11-23 20:58:37
1

Melhor resposta

0

Parece que você está usando discord.js v13 e tentando alguns do código antigo. Em v13 o channel#updateOverwrite() o método é removido e, enquanto na versão anterior channel#permissionOverwrites era uma coleção de substitui, em v13 é um PermissionOverwriteManager. Isso significa, você deve usar a sua .edit() método para atualização substitui:

channel.permissionOverwrites.edit(
  message.author, 
  { SEND_MESSAGES: false, VIEW_CHANNEL: false },
)
2021-11-23 21:49:11

Em outros idiomas

Esta página está em outros idiomas

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................