Discord.js:TypeError:client.channels.get 不是函数 [英] Discord.js : TypeError: client.channels.get is not a function

查看:14
本文介绍了Discord.js:TypeError:client.channels.get 不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我尝试了很多东西,但这段代码不起作用,抱歉没有包含这么多细节,但我真的不知道这段代码有什么问题

Hey I've tried many thing but this code doesn't works, sorry for not including so much details but I really don't know what's wrong with this code

const express = require("express");
const app = express();
const Discord = require("discord.js");
const client = new Discord.Client()
const db = require('quick.db');
client.on('ready', () => {
console.log(client.user.tag);
});
console.log(client.channels.get(`688901992826929210`))

控制台:

TypeError: client.channels.get is not a function at Object.<anonymous> (/app/server.js:9:29)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:826:10)
    at internal/main/run_main_module.js:17:11

我正在使用 glitch.com 免费托管,谢谢.

I'm using glitch.com free hosting, thanks.

推荐答案

您似乎没有使用 client.login('INSERT TOKEN HERE') 登录到您的客户端,所以 client.channels可能未定义,因此 .get() 不是函数.

You don't appear to have logged into your client using client.login('INSERT TOKEN HERE') so client.channels is likely undefined and therefore .get() is not a function.

此外,如果您碰巧使用的是新的 Discord.js v12,现在将是 client.channels.cache.get(),但您仍然必须使用您的机器人令牌登录.

Also if you happen to be using the new Discord.js v12 this will now be client.channels.cache.get() but you still have to log in using your bot token.

这篇关于Discord.js:TypeError:client.channels.get 不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆