-
-
Save totoraj930/ce726e81999ea23dfc52a435dd1398c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Discord = require("discord.js"); | |
const client = new Discord.Client(); | |
client.login("メモしておいたToken"); | |
client.on("ready", () => { | |
console.log("BOTの準備ができました。"); | |
}); | |
// メッセージ受信イベント | |
client.on("message", message => { | |
var sender = message.member,// 送信者 | |
ch = sender.voiceChannel;// 送信者の接続しているボイスチャンネル | |
// メッセージの内容が「!paly」で | |
// 送信者がボイスチャンネルに接続しているなら | |
if (message.content === "!play" && ch) { | |
// ボイスチャンネルに接続 | |
ch.join().then(connection => { | |
// 接続できたらファイルのパスを指定して再生 | |
connection.playFile("./sound.mp3"); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment