Discord - RichEmbed - 空消息 - 音乐播放命令
Discord - RichEmbed - Empty Message - Play command for Music
我正在尝试将我的机器人设置为每当我 运行“=播放”时它都会 post 嵌入说明正在播放的内容。但每次我尝试 运行 时,视频加载正常,但嵌入本身不会。有没有人有关于如何让它工作的任何提示?
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);
。
我正在尝试将我的机器人设置为每当我 运行“=播放”时它都会 post 嵌入说明正在播放的内容。但每次我尝试 运行 时,视频加载正常,但嵌入本身不会。有没有人有关于如何让它工作的任何提示?
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);
。