簡體   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