繁体   English   中英

Discord.js 向特定频道发送消息

[英]Discord.js Send a message to a specific channel

我想发出一个轮询命令,但我无法让它向特定频道发送消息这是我的代码:

const { tprefix, pollchannel } = require('../config.json');
const Discord = require('discord.js');
const client = new Discord.Client();

module.exports = {
 name: 'poll',
 description: 'can make polls',
 cooldown: 5,
 usage: '[ask] [emoji1] [emoji 2]',
 aliases: ['createpoll'],
 async execute(message) {
  const channel = message.client.channels.fetch(pollchannel);
  message.channel.send('you have 60 seconds.');

  // await new Promise((resolve) => setTimeout(resolve, 60000));
  channel.client.send(`${tprefix} message`);
  message.channel.send('finished');
 },
};

它应该发送一条带有“你有 60 秒。”的消息,然后等待 60 秒,然后在轮询通道和当前通道上发送一条消息。 通道id是正确的,写在config.json

利用:

const channel = message.client.channels.cache.get(pollchannel)
channel.send('hello')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM