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

無法讀取未定義的屬性“發(fā)送"

Cannot read property #39;send#39; of underfined(無法讀取未定義的屬性“發(fā)送)
本文介紹了無法讀取未定義的屬性“發(fā)送"的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

const mudaeon = require('./mudaetime.json');
const cron = require('cron');
const Discord = require('discord.js');
const client = new Discord.Client();

module.exports = {
 name: 'mudaetime',
 description: '...',
 execute(message, args) {
  if (mudaeon) {
   const channel = client.channels.cache.get('id');
   let scheduledMessage = new cron.CronJob(
    '* * * * *',
    () => {
     scheduledMessage.start();
    },
    message.react('?'),
    channel.send('check $tu ! <@&id')
   );
  } else !mudaeon;
  {
   cancel();
  }
 },
};

請幫助找出我的代碼中的錯誤!我想做一個機器人,每十分鐘在特定頻道發(fā)送一條消息(盡管在這種情況下,我每分鐘都放一次,這樣我就可以看看它是否有效)

Please help find the error in my code! I wanted to make a bot that sends a message in a specific channel every ten minutes (although in this case, I put it for every minute so I can see if it works)

推薦答案

問題是你正在創(chuàng)建一個新的 Discord.Client() 實例,它不共享相同的頻道、成員、角色等作為原作.您應(yīng)該將原始的作為參數(shù)傳遞給您的 execute() 函數(shù),而不是創(chuàng)建新的 Discord.Client().

The problem is that you are creating a new Discord.Client() instance, which does not share the same channels, members, roles, etc. as the original. Instead of creating a new Discord.Client(), you should pass the original one as an argument to your execute() function.

例如,您可以將 async execute(message, args){ 更改為 async execute(message, args, client){.然后,在您的命令處理程序中,將 command.execute(message, args) 更改為 command.execute(message, args, client)

For example, you could change async execute(message, args){ to async execute(message, args, client){. Then, in your command handler, change command.execute(message, args) to command.execute(message, args, client)

然而,還有一個更更簡單的方法.client實際上是message對象的一個??有效屬性,指的是:

However, there is an even easier way. client is actually a valid property of the message object, referring to:

實例化消息的客戶端

(Message#client 文檔)

所以,不要寫:

const channel = client.channels.cache.get('id');

你可以寫:

const channel = message.client.channels.cache.get('id')

它會完美運行!

這篇關(guān)于無法讀取未定義的屬性“發(fā)送"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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(如何讓我的機器人提及發(fā)出該機器人命令的人)
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ù)器時的歡迎消息)
主站蜘蛛池模板: 国产精品资源在线观看 | 日韩综合网 | 狠狠久久综合 | 最新免费黄色网址 | 亚洲一区二区欧美 | 91久久精品一区二区二区 | 日韩欧美在线观看视频网站 | 国产精品成人国产乱一区 | 成人黄色电影在线观看 | 亚洲国产精品一区二区第一页 | 完全免费av在线 | 最近日韩中文字幕 | 国产丝袜一区二区三区免费视频 | 亚洲国产成人在线观看 | 91视频国产精品 | 在线观看国产视频 | av在线免费播放 | 色99视频 | 成人黄色网址大全 | 国产精品二区三区在线观看 | 亚洲成av人影片在线观看 | 国产精品二区三区在线观看 | 国产日产精品一区二区三区四区 | 欧美不卡一区二区三区 | 91视频在线| 欧美视频一区二区三区 | 久久久久精 | 久久婷婷麻豆国产91天堂 | 久久日韩精品一区二区三区 | 成人一区在线观看 | 草久视频 | 亚洲黄色一区二区三区 | 丁香久久 | 美女爽到呻吟久久久久 | 日本一区二区影视 | 日韩精品在线观看视频 | 国产免费视频 | 精品美女久久久 | 成人夜晚看av | 亚洲精选一区 | 日韩www |