Skip to content

Instantly share code, notes, and snippets.

@totoraj930
Created June 23, 2017 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save totoraj930/ce726e81999ea23dfc52a435dd1398c1 to your computer and use it in GitHub Desktop.
Save totoraj930/ce726e81999ea23dfc52a435dd1398c1 to your computer and use it in GitHub Desktop.
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