Showing
3 changed files
with
32 additions
and
2 deletions
| 1 | const {prefix, token} = require('./config.json'); | 1 | const {prefix, token} = require('./config.json'); |
| 2 | const Discord = require("discord.js") // npm install discord.js 필요 | 2 | const Discord = require("discord.js") // npm install discord.js 필요 |
| 3 | const client = new Discord.Client() | 3 | const client = new Discord.Client() |
| 4 | -var fs = require('fs'); | 4 | +const fs = require('fs'); // 파일 입출력 모듈 |
| 5 | const internal = require("stream"); | 5 | const internal = require("stream"); |
| 6 | var now = new Date(); // 현재날짜 및 시간 객체 | 6 | var now = new Date(); // 현재날짜 및 시간 객체 |
| 7 | -var moment = require('moment') // npm install --save moment 필요 | 7 | +const moment = require('moment') // npm install --save moment 필요 (디데이 출력 모듈) |
| 8 | 8 | ||
| 9 | +//npm install discord.js @discord/opus 필요 | ||
| 10 | +//npm install --save ffmpeg-binaries 필요 | ||
| 9 | 11 | ||
| 10 | 12 | ||
| 11 | 13 | ||
| ... | @@ -189,6 +191,34 @@ client.on("message", msg => { | ... | @@ -189,6 +191,34 @@ client.on("message", msg => { |
| 189 | 191 | ||
| 190 | 192 | ||
| 191 | 193 | ||
| 194 | + // 백색소음 틀기 | ||
| 195 | + if (command === "재생") { | ||
| 196 | + if (msg.member.voice.channel) { | ||
| 197 | + msg.member.voice.channel.join() | ||
| 198 | + .then(connection => { | ||
| 199 | + msg.reply("재생한다!"); | ||
| 200 | + const dispatcher = connection.play("music/square.mp3"); | ||
| 201 | + dispatcher.on("end", end => {}); | ||
| 202 | + }) | ||
| 203 | + .catch(console.log); | ||
| 204 | + } else { | ||
| 205 | + msg.reply("널 따라갈건데 너가 보이스채널에 없어."); | ||
| 206 | + } | ||
| 207 | + } | ||
| 208 | + if (command === "보이스나가") { | ||
| 209 | + | ||
| 210 | + if (msg.member.voice.channel) { | ||
| 211 | + msg.member.voice.channel.leave(); | ||
| 212 | + msg.reply('bye!'); | ||
| 213 | + } else { | ||
| 214 | + msg.reply('이미 나왔는데..'); | ||
| 215 | + } | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + | ||
| 219 | + | ||
| 220 | + | ||
| 221 | + | ||
| 192 | 222 | ||
| 193 | }) | 223 | }) |
| 194 | 224 | ... | ... |
music/comfortable.mp3
0 → 100644
This file is too large to display.
music/square.mp3
0 → 100644
No preview for this file type
-
Please register or login to post a comment