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

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

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

問(wèn)題描述

我最近遇到了一個(gè)問(wèn)題.

I've recently run into a problem.

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

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)行它時(shí),它都會(huì)指出客戶端未定義.它總是給我消息無(wú)法讀取指向 test.js 中的偵聽(tīng)器的未定義的屬性'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)上閱讀了許多不同的資源,但似乎沒(méi)有一個(gè)可以幫助我解決問(wèn)題.任何幫助,將不勝感激.謝謝

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陳述是錯(cuò)誤的.改成

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 客戶端對(duì)象在導(dǎo)出后未定義的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(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)入來(lái)加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來(lái)自特定服務(wù)器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復(fù)“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務(wù)器時(shí)的歡迎消息)
主站蜘蛛池模板: 999热在线视频 | 一本一道久久a久久精品综合蜜臀 | 中文字幕一区二区三 | 日韩精品一区二区三区四区视频 | 91麻豆产精品久久久久久夏晴子 | 成人精品国产一区二区4080 | 亚洲精品一区二区二区 | 亚洲精品欧美 | 成人做爰69片免费观看 | 精品久久久久久国产 | 日韩在线免费播放 | 欧美精品一区二区三区四区 在线 | 一级高清视频 | 国产精品久久久久久婷婷天堂 | 国产精品毛片久久久久久久 | 成人av电影天堂 | 国产美女一区二区 | 二区不卡| 色久电影 | 久久久999成人 | 午夜激情免费 | 国产精品美女久久久av超清 | 久久亚洲高清 | 欧美精品一区二区免费视频 | 精品国产91乱码一区二区三区 | 国产精品免费一区二区三区 | 亚洲国产成人精品女人 | 三级黄视频在线观看 | 中文字幕免费观看 | 天天操天天怕 | 蜜桃官网 | 久久激情网 | 欧美日韩视频在线第一区 | 日韩一三区 | 国产成人免费视频 | 欧美视频偷拍 | 日韩在线观看网站 | 免费在线观看一区二区三区 | 久久综合久久自在自线精品自 | 99免费在线视频 | 91精品国产91久久久久久丝袜 |