我目前正在使用 Discord 机器人进行编程discord.js,并且我正在使用它ytdl-core来播放音乐。这是我用来播放音乐的程序:
const {google} = require('googleapis');
const ytdl = require('ytdl-core');
// Initialise Google API
const youtube = google.youtube({
version: 'v3',
auth: MyAuth
});
musicQueue = [] // Queue for playing music
dispatcher = null; // Transmits voice packets from stream
module.exports = {
name: "play",
async execute(msg, args) { // msg is a Discord Message
// Play music and music queued after
async function playAndQueue(stream) {
// Join voice channel
voiceChannel = client.channels.cache.find(channel => channel.type …Run Code Online (Sandbox Code Playgroud)