본문 바로가기

디스코드봇

(5)
[JS] 디스코드 노래 봇 5 노래봇에 재생목록, 삭제, 넘기기, 반복재생 등등 기능을 만들었는데 중요한 문제가 생겼다.유튜브 정책 변경으로 기존에 사용중이던 ytdl-core 라이브러리가 사용이 불가능해졌다.다른 방법을 찾아야하는 상황이다.일단 아래는 지금까지 작업했었던 코드다.const { Client, GatewayIntentBits } = require('discord.js');const { joinVoiceChannel, createAudioPlayer, createAudioResource, AudioPlayerStatus } = require('@discordjs/voice');const ytdl = require('ytdl-core'); //수정예정const { token, youtubeApiKey } = require..
[JS] 디스코드 노래 봇 4 이제 얼추 정리는 끝났다.유튜브search api도 가져왔고, 그걸 이용하여 노래 재생까지 완료된 상태다.여기에 명령어를 정리하여 코드를 정리해보자 현재까지 작성했던 내용을 바탕으로 조금 정리해본 코드이다.const { Client, GatewayIntentBits } = require('discord.js');const { joinVoiceChannel, createAudioPlayer, createAudioResource, AudioPlayerStatus } = require('@discordjs/voice');const ytdl = require('ytdl-core');const { token, youtubeApiKey } = require('./discordConfig.js');const sodi..
[JS] 디스코드 노래 봇 3 이런저런 일이 많아 잠시 내려놓았다가 시간이 생겨 또 추가해보았다.이번엔 직접 유튜브 링크를 작성하여 재생시키는게 아닌 특정단어로 해당 유튜브를 재생시키는 방법을 추가했다.고맙게도 node js 에 youtube-search 모듈이 있다.npm install youtube-search이후 https://console.developers.google.com Google 클라우드 플랫폼로그인 Google 클라우드 플랫폼으로 이동accounts.google.com에 접속하여 프로젝트를 만들고 key를 발급받자자세한건 아래 블로그 참고https://bonniness.tistory.com/entry/%EA%B5%AC%EA%B8%80-Youtube-API-%EC%82%AC%EC%9A%A9-%EC%82%AC%EC%9..
[JS] 디스코드 노래 봇 2 저번에 특정 노래만을 재생하도록 만들어놨으니 이번엔 URL을 받으면 그 노래를 반복재생하도록 추가해보았다.else if (command.indexOf('https://www.youtube.com') != -1) { const playUrl = command; voiceChannel = message.member.voice.channel; if (!voiceChannel) { return message.reply('채널에 먼저 들가라'); } const permissions = voiceChannel.permissionsFor(message.client.user); if (!permissions.has('CONNECT') || !perm..
[JS] 디스코드 노래 봇 디스코드에서 쓸만한 노래봇을 쓰려고 하는데 특정 기능을 사용하려 하니 유료결제가 필요하다길래 직접 만들어본다.일단 node js 사용하였다. npm init 로 세팅하며 시작 필요한 모듈은 아래와 같다npm install discord.js @discordjs/voice ytdl-core libsodium-wrappers discord.js 는 discord에서 제공하는 기능을 사용하기위해ytdl-core 는 youtube에서 url로 영상을 가져와 처리하기위해 사용한다 https://discord.com/developers/applications Discord Developer Portal — API Docs for Bots and DevelopersIntegrate your service with D..

반응형