久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Discord 客戶端對象在導(dǎo)出后未定義

Discord client object is undefined after being exported(Discord 客戶端對象在導(dǎo)出后未定義)
本文介紹了Discord 客戶端對象在導(dǎo)出后未定義的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我最近遇到了一個問題.

I've recently run into a problem.

在過去的幾周里,我一直在研究我制作的一些不和諧機(jī)器人,但在導(dǎo)出客戶端對象時遇到了麻煩.我一直在嘗試將它導(dǎo)出到其他文件,這樣我就可以使用同一個對象將事件偵聽器掛接到其他文件中.以下是我嘗試做的事情.

For the past several weeks I have been working on some discord bots I have made and am having trouble with exporting the client object. I've been trying to export it to other files so I can hook event listeners in other files using the same object. Below's what I attempted doing.

main.js

const client = new Discord.Client(); //Defining the client
exports.squidly = client; //Attempting to export the client

test.js

const client = require('../squidly').squidly;

client.on('ready', () => {
     console.log("Test");
});

在閱讀了有關(guān)導(dǎo)出模塊的內(nèi)容后,我認(rèn)為這就是我所要做的,但每次我嘗試運(yùn)行它時,它都會指出客戶端未定義.它總是給我消息無法讀取指向 test.js 中的偵聽器的未定義的屬性'on'

After reading things about exporting modules I thought this was all I had to do but every time I try running this it states that client is undefined. It always gives me the message "cannot read property 'on' of undefined' pointing towards the listener in test.js

我在網(wǎng)上閱讀了許多不同的資源,但似乎沒有一個可以幫助我解決問題.任何幫助,將不勝感激.謝謝

I've read many different sources online and none of them seemed to help me solve the issue. Any help would be appreciated. Thanks

推薦答案

如果您創(chuàng)建和導(dǎo)出客戶端的文件名為 main.js,則您的 require陳述是錯誤的.改成

If the file in which you create and export the client is called main.js, your require statement is wrong. Change it to

const client = require('../main').squidly; //The require needs to point to the path and file name in which you export your client

這篇關(guān)于Discord 客戶端對象在導(dǎo)出后未定義的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機(jī)器人提及發(fā)出該機(jī)器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復(fù)必須使用導(dǎo)入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務(wù)器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復(fù)“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務(wù)器時的歡迎消息)
主站蜘蛛池模板: 97超碰人人草 | 人人玩人人添人人澡欧美 | 天天夜夜操 | 亚洲成人一区 | 午夜欧美一区二区三区在线播放 | 亚洲精品久久久久中文字幕二区 | 亚洲一区精品视频 | 欧美一区二区三区在线观看 | 日韩综合网 | www.日韩 | 亚洲欧美日韩精品久久亚洲区 | 四虎国产 | 亚洲电影一级片 | 91影视| 91看片免费版 | 中文字幕日韩欧美一区二区三区 | 免费视频一区 | 欧美精品在线播放 | 亚洲欧美高清 | 久久亚洲一区二区 | 国产一级影片 | 91av免费看| 久久综合伊人 | 国产一区二区三区视频 | 精品久久久久久 | 国产精品久久久久久久久久久久久 | 一区二区高清 | 日韩中文字幕免费在线观看 | 懂色中文一区二区三区在线视频 | 超级乱淫av片免费播放 | 精品欧美一区二区精品久久 | 精品国产亚洲一区二区三区大结局 | 亚洲欧美在线观看 | 热99| 成人久久久 | 精品久久影院 | av在线成人| 日韩视频一区在线观看 | 亚洲免费在线 | 欧美日韩1区2区3区 欧美久久一区 | 国产99免费视频 |