啊啊啊我要瘋了。我已經問了很多關于創建頻道的問題,但我仍然無法理解,我做錯了嗎????這是我正在使用的代碼:
const Discord = require('discord.js');
const { Client, GatewayIntentBits, messageLink, InteractionResponseType, ChannelType } = require('discord.js');
const logger = require('winston');
const discord = require("discord.js");
const { EmbedBuilder, SlashCommandBuilder } = require('discord.js');
const bot = new Discord.Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildMessageReactions,
],
});
//
const fs = require("node:fs");
const guild = bot.guilds.cache.get("1037081018500399154");
const path = require("node:path");
const token = "you tought"
//text
bot.on('ready', () => { // when the bot is ready and online
console.log('bot is now online!')
bot.user.setActivity("Servers");
});
guild.channels.create({
name: "hello",
type: ChannelType.GuildText,
// your permission overwrites or other options here
});
每次我啟動我的機器人時它都會拋出這個訊息
Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'channels')
請幫助我,我要瘋了。是的,我已經閱讀了檔案。
{編輯:通常有更多代碼,但我現在剛剛洗掉了代碼}
uj5u.com熱心網友回復:
把它放在一個準備好的事件中。它應該是這樣的:
bot.on("ready" , () => {
const guild = bot.guilds.cache.get("1037081018500399154");
guild.channels.create({
name: "hello",
type: ChannelType.GuildText,
// your permission overwrites or other options here
});
});
我希望對你有所幫助。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/532334.html
標籤:javascript节点.js不和谐不和谐.js机器人
上一篇:如何在“GitbashCLI控制臺”中列印賽普拉斯基礎網址
下一篇:MVC表單資料無法系結到模型
