javascript - 为什么我的播放命令一直给我一个错误
问题描述
我试图为我的 discord.js 机器人制作音乐播放命令,但文件一直给我一个错误,我不明白为什么会这样。
const ytdl = require("ytdl-core");
const ytSearch = require("yt-search");
module.export = {
name: "play",
description: "Joins the vc and plays a yt vid",
execute(message, args) {
const voiceChannel = message.member.voiceChannel;
if (!voiceChannel)
return message.channel.send("You need to be in a vc to use this command");
const permissions = voiceChannel.permissionsFor(message.client.user);
if (!permissions.has("CONNECT"))
return message.channel.send("You dont have the required permissions");
if (!permissions.has("SPEAK"))
return message.channel.send("You dont have the required permissions");
if (!args.length)
return message.channel.send("You need to send the second argument");
const connection = await voiceChannel.join();
const videoFinder = async (query) => {
const videoResult = await ytSearch(query);
return videoResult.videos.length > 1 ? videoResult.videos[0] : null;
};
const video = await videoFinder(args.join(" "));
if (video) {
const stream = ytdl(video.url, { filter: "audioonly" });
connection.play(stream, { seek: 0, volume: 1 });
}
},
};
解决方案
推荐阅读
- tensorflow - 是否有 EnCTC 的 tensorflow 实现
- css - 在 Bootstrap 4 中重复创建 5 列
- c# - 如何从同一项目中的另一个 Api 控制器调用 Api 控制器
- ios - Package.swift 与 Xcode 11 项目一起使用,如何同时使用 Carthage 和 SPM?
- node.js - 在 ForEach 中遇到同步问题
- ios - 如何使用第三方应用在 Apple Watch 中的活动移动环中添加贡献
- python-2.7 - 扩展“RequestExecutionException”的“Timeout”类是否与扩展 Datastax 驱动程序中的 DriverException 的“OperationTimedOut”类相同?
- amazon-cognito - 如何在同一个 cognito 用户池中发送不同的验证邮件
- laravel - 在 Laravel 包的 RouteServiceProvder 中使用“命名空间”方法
- c++ - SFINAE `std::void_t` 类模板特化