我试图将我的机器人设置为每当我运行“ = 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});
};
答案 0 :(得分:0)
完成嵌入后,您忘记在两个嵌入的语句末尾添加;
。尝试解决该问题,看看是否可行。
答案 1 :(得分:0)
我发现了问题所在。 message.channel.send({playing});
不正确。 ({playing})
不需要放在方括号内,只需要放在括号内即可。
因此不是message.channel.send({playing});
,而是message.channel.send(playing);
。