¿Cómo se envía un mensaje a un canal específico en discord.js?

user8385393:

Leer Editar en el fondo, CAMBIOS toda la cuestión.

Sí, sé que la gente ha preguntado esto antes. Sin embargo, no puedo encontrar una solución que funciona y no ha quedado en desuso. Aquí están las partes de mi código que se requiere para operar la función específica que estoy tratando de replicar;

const Discord = require('discord.js');
const bot = new Discord.Client();
const client = bot

const token = 'NunyaBuisness';
const channel = '525723958239852735' // Not a real channel ID
const PREFIX = '.';

bot.on('message', msg=>{
    let args = msg.content.substring(PREFIX.length).split(" ");
    switch(args[0]){
        case 'process':
            if(args[1] === 'test'){
                var testGuild = new Discord.Guild(bot, 'serverID');
                var testTextChannel = new Discord.TextChannel(testGuild, channel);
                testTextChannel.send("Test");
            }
        break;
    }
})

Motor de búsqueda regresa lo siguiente en el mensaje

prueba .Proceso

B:\bot\node_modules\discord.js\src\structures\Guild.js:152
    this.large = Boolean('large' in data ? data.large : this.large);
                                 ^

TypeError: Cannot use 'in' operator to search for 'large' in serverID
    at Guild._patch (B:\bot\node_modules\discord.js\src\structures\Guild.js:152:34)
    at new Guild (B:\bot\node_modules\discord.js\src\structures\Guild.js:92:12)
    at Client.<anonymous> (B:\bot\index.js:101:33)
    at Client.emit (events.js:311:20)
    at MessageCreateAction.handle (B:\bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (B:\bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (B:\bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
    at WebSocketShard.onPacket (B:\bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:435:22)
    at WebSocketShard.onMessage (B:\bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
    at WebSocket.onMessage (B:\bot\node_modules\ws\lib\event-target.js:120:16)

¡Gracias por tu ayuda! Realmente lo aprecio. He estado tratando de resolver esto por mi mismo día utilizando la documentación, pero constantemente fallar.

EDITAR

Creo que el problema es que el método CLIENT.channels.get ( 'id'), literalmente no existe. Esto es extraño como el infierno y estoy mirando a través de la GitHub para ver si falta algo. En este momento, no veo absolutamente nada falta. Esto es super raro. Gracias por su ayuda hasta ahora.

Cipher:

Para el cambio de la discordia v12:

msg.guild.channels.get(myChannel) a msg.guild.channels.cache.get(myChannel)

let myChannel = '123213123'

    bot.on('message', msg=>{
        let args = msg.content.substring(PREFIX.length).split(" ");
        switch(args[0]){
            case 'process':
                if(args[1] === 'test'){
                    let targetChannel = msg.guild.channels.get(myChannel)
                    if (targetChannel) targetChannel.send('sssss')
                }
            break;
        }
    })

Supongo que te gusta

Origin http://43.154.161.224:23101/article/api/json?id=303702&siteId=1
Recomendado
Clasificación