Cannot read property 'send' of underfined

前端 未结 2 1410
夕颜
夕颜 2021-01-28 01:19
const mudaeon = require(\'./mudaetime.json\');
const cron = require(\'cron\');
const Discord = require(\'discord.js\');
const clie         


        
2条回答
  •  孤街浪徒
    2021-01-28 01:32

    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.

    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)

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

    The client that instantiated the message

    (Message#client docs)

    So, instead of writing:

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

    You could write:

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

    And it will work perfectly!

提交回复
热议问题