diff --git a/.env.example b/.env.example index ab29147..51df4cf 100644 --- a/.env.example +++ b/.env.example @@ -28,6 +28,8 @@ PREFIX=& # Set this to true if you want the bot to stay in voice chats after sound effects and music have stopped # (you can still make the bot leave using the stop command) STAYVC=false +# Set this to true to disable music playback from YouTube +YT_DISABLED=false # Put DBL/top.gg token here DBL= diff --git a/commands/music/play.js b/commands/music/play.js index 020548e..e48eeb7 100644 --- a/commands/music/play.js +++ b/commands/music/play.js @@ -1,6 +1,7 @@ import { play } from "../../utils/soundplayer.js"; import MusicCommand from "../../classes/musicCommand.js"; -const prefixes = ["ytsearch:", "ytmsearch:", "scsearch:", "spsearch:", "amsearch:"]; +const prefixes = ["scsearch:", "spsearch:", "sprec:", "amsearch:", "dzsearch:", "dzisrc:"]; +if (process.env.YT_DISABLED !== "true") prefixes.push("ytsearch:", "ytmsearch:"); class PlayCommand extends MusicCommand { async run() { @@ -21,7 +22,7 @@ class PlayCommand extends MusicCommand { const url = new URL(query); return play(this.client, url, { channel: this.channel, member: this.member, type: this.type, interaction: this.interaction }, true); } catch { - const search = prefixes.some(v => query.startsWith(v)) ? query : !query && attachment ? attachment.url : `ytsearch:${query}`; + const search = prefixes.some(v => query.startsWith(v)) ? query : !query && attachment ? attachment.url : (process.env.YT_DISABLED !== "true" ? `ytsearch:${query}` : `dzsearch:${query}`); return play(this.client, search, { channel: this.channel, member: this.member, type: this.type, interaction: this.interaction }, true); } } diff --git a/utils/soundplayer.js b/utils/soundplayer.js index 0d54248..a5f5dc4 100644 --- a/utils/soundplayer.js +++ b/utils/soundplayer.js @@ -88,6 +88,7 @@ export async function play(client, sound, options, music = false) { } const oldQueue = queues.get(voiceChannel.guildID); if (!response.tracks || response.tracks.length === 0) return { content: "I couldn't find that song!", flags: 64 }; + if (process.env.YT_DISABLED === "true" && response.tracks[0].info.sourceName === "youtube") return "YouTube playback is disabled on this instance."; if (music) { const sortedTracks = response.tracks.map((val) => { return val.track; }); const playlistTracks = response.playlistInfo.selectedTrack ? sortedTracks : [sortedTracks[0]];