第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

discord.js | 無法讀取未定義的屬性“集”

discord.js | 無法讀取未定義的屬性“集”

慕運(yùn)維8079593 2023-03-10 16:41:08
我在 discord.js v12 中創(chuàng)建我的命令處理程序,但我一直收到此錯(cuò)誤,即:無法讀取未定義的屬性“集”這是我的代碼,這段代碼在一個(gè)名為handlersconst { readdirSync, readdir } = require('fs');const ascii = require('ascii-table');let table = new ascii('commands');table.setHeading('Commands', 'Status');module.exports = (client) => { readdirSync('./commands/').forEach((dir) => {  const commands = readdirSync(`./commands/${dir}/`).filter((file) =>   file.endsWith('.js')  );  for (let file of commands) {   let pull = require(`../commands/${dir}/${file}`);   if (pull.name) {    client.commands.set(pull.name, pull);    table.addRow(file, '?');   } else {    table.addRow(     file,     `? -> Missing a help.name, or help.name in not a string.`    );    continue;   }   if (pull.aliases && Array.isArray(pull.aliases))    pull.aliases.forEach((alias) => client.aliases.set(aliases, pull.name));  } }); console.log(table.toString());};在我的切入點(diǎn),即main.js,我制作了一個(gè)新系列。
查看完整描述

1 回答

?
倚天杖

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊

這里的問題是你在一個(gè)單獨(dú)的文件中工作,所以你無法訪問另一個(gè)文件中定義的變量

為了解決這個(gè)問題,在你的 main.js 文件中你需要使用一個(gè)module.exports.client = client并且在 handler.js 文件中你可以做const client = require("../main.js").client

您還必須確保在定義時(shí)client.commands為其提供正確的對(duì)象類型。一定是client.commands = new Discord.Collection()


查看完整回答
反對(duì) 回復(fù) 2023-03-10
  • 1 回答
  • 0 關(guān)注
  • 81 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)