【发布时间】:2018-07-03 09:33:36
【问题描述】:
我正在尝试将我的机器人设置为每当我运行“=play”时它会发布一个嵌入说明正在播放的内容。但每次我尝试运行它时,视频加载正常,但嵌入本身不会。有没有人有任何关于如何让它工作的提示?
const Discord = require("discord.js");
const ytdl = require('ytdl-core');
exports.run = async (client, message, args, ops) => {
const embed = new Discord.RichEmbed()
.setAuthor('Please enter a voice channel','https://i.imgur.com/Tu6PraB.png')
.setDescription('You must be in a voice channel to play music!')
.setColor('#de2e43')
if (!message.member.voiceChannel) return message.channel.send({embed});
if (message.guild.me.voiceChannel) return message.channel.send('Sorry, the bot is already connected to the channel.');
if (!args[0]) return message.channel.send('Sorry, please input a url following the command.');
let validate = await ytdl.validateURL(args[0]);
if (!validate) return message.channel.send('Sorry, please input a **valid** url following the command.')
let info = await ytdl.getInfo(args[0]);
let connection = await message.member.voiceChannel.join();
let dispatcher = await connection.playStream(ytdl(args[0], { filter: 'audioonly'}));
var playing = new Discord.RichEmbed()
.setAuthor('Now playing')
.setDescription(`${info.title}`)
.setColor('#2ecc71')
message.channel.send({playing});
};
【问题讨论】:
-
(node:31960) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message是我得到的错误。
标签: node.js discord.js