반응형

디스코드봇 8

[JS] 디스코드 노래 봇 8

최근 유튜브 노래를 가져오는 부분에서 문제가 있었다.노래를 가져오려고하면 403 에러가 나기 시작했는데 아마 유튜브 쪽에서 막은것 같다. 한동안 방치해뒀다가 다시 실행해보니 정상적으로 실행이 되었는데 확인해보니distubejs/ytdl-core 쪽에서 최근에 업데이트를 했다고 나와있었다. 어떤게 업데이트 되었나 변경된 코드를 확인해봤는데WEB_CREATOR 라는것을 사용하던 것을WEB_EMBEDDED 으로 바꿨다고 나와있었다.어저 두개의 차이점을 검색해봤는데 WEB_CREATOR 는 크리에이터 전용 API,WEB_EMBEDDED 는 YouTube API를 직접 호출하지 않고, iframe을 통해 YouTube 서버에서 자동으로 데이터를 가져옴라고 되어있었다.크리에이터 전용 api 라고 되어있지만 기본적으..

디스코드봇 2025.02.27

[JS] 디스코드 노래 봇 7

예전에 만들어놓고 한동안 방치해놨지만 늦게나마 기록을 위해 코드도 정리할겸 전체 코드를 올리기로 했다.const { Client, GatewayIntentBits, ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } = require('discord.js');const { joinVoiceChannel, createAudioPlayer, createAudioResource, AudioPlayerStatus, getVoiceConnection } = require('@discordjs/voice');//const ytdl = require('ytdl-core'); //수정예정const ytdl = require("@distube/ytdl-core..

디스코드봇 2025.01.13

[JS] 디스코드 노래 봇 6

간만에 디스코드 봇을 건드려보는데 ytdl-core 라이브러리 대체 할 수 있도록 누군가 추가해놨다고 하니 사용해봤다.  require('ytdl-core') -> require('@distube/ytdl-core') 로 변경하면 된다.사용법도 동일하니 그냥 변경만 하면 잘 되니 그냥 사용하면 된다. 이제 여기에 embed 와 버튼을 추가해서 디스코드에서 gui 로 명령을 내릴수 있도록 만들 예정이다

디스코드봇 2024.10.17

[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..

디스코드봇 2024.08.24

[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..

디스코드봇 2024.07.14

[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..

디스코드봇 2024.06.30

[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..

디스코드봇 2024.06.16

[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..

디스코드봇 2024.06.16
반응형