【发布时间】:2021-12-29 03:45:42
【问题描述】:
我正在尝试通过 DiscordJS 发送消息
谁能帮帮我
我试过这个代码
const channel = client.channels.cache.get('example discord guild');
channel.send('content');
但它不起作用
index.js
// Credetials
const { token } = require('./json/token.json');
const { guild } = require('./json/guild.json');
const { client } = require('./json/client.json')
// Init
const { Client, Intents } = require('discord.js');
const bot = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_>
bot.login(guild);
console.log("Logged In As DeltaBOT");
const channel = client.channels.cache.get(guild);
channel.send('content');
错误
const channel = client.channels.cache.get(guild);
^
TypeError: Cannot read properties of undefined (reading 'cache')
at Object.<anonymous> (/storage/emulated/0/Download/node/index.js:15:33)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
【问题讨论】:
-
你的
client.json文件的内容是什么? -
他们的不和谐服务器通常很有帮助discord.gg/djs
标签: node.js discord.js