繁体   English   中英

Discord-RichEmbed-空消息-音乐的播放命令

[英]Discord - RichEmbed - Empty Message - Play command for Music

我正在尝试将我的机器人设置为每当我运行“ = 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});

};

完成嵌入后,您忘记添加; 到两个嵌入中声明的末尾。 尝试解决该问题,然后查看是否可行。

我发现了问题。 message.channel.send({playing}); 是不正确的。 ({playing})不需要放在方括号内,只需要放在括号内即可。

因此,而不是message.channel.send({playing}); 这将是message.channel.send(playing);

暂无
暂无

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

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