Added option to disable YouTube support
This commit is contained in:
		
							parent
							
								
									006ce416aa
								
							
						
					
					
						commit
						ba46701589
					
				
					 3 changed files with 6 additions and 2 deletions
				
			
		| 
						 | 
					@ -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
 | 
					# 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)
 | 
					# (you can still make the bot leave using the stop command)
 | 
				
			||||||
STAYVC=false
 | 
					STAYVC=false
 | 
				
			||||||
 | 
					# Set this to true to disable music playback from YouTube
 | 
				
			||||||
 | 
					YT_DISABLED=false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Put DBL/top.gg token here
 | 
					# Put DBL/top.gg token here
 | 
				
			||||||
DBL=
 | 
					DBL=
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
import { play } from "../../utils/soundplayer.js";
 | 
					import { play } from "../../utils/soundplayer.js";
 | 
				
			||||||
import MusicCommand from "../../classes/musicCommand.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 {
 | 
					class PlayCommand extends MusicCommand {
 | 
				
			||||||
  async run() {
 | 
					  async run() {
 | 
				
			||||||
| 
						 | 
					@ -21,7 +22,7 @@ class PlayCommand extends MusicCommand {
 | 
				
			||||||
      const url = new URL(query);
 | 
					      const url = new URL(query);
 | 
				
			||||||
      return play(this.client, url, { channel: this.channel, member: this.member, type: this.type, interaction: this.interaction }, true);
 | 
					      return play(this.client, url, { channel: this.channel, member: this.member, type: this.type, interaction: this.interaction }, true);
 | 
				
			||||||
    } catch {
 | 
					    } 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);
 | 
					      return play(this.client, search, { channel: this.channel, member: this.member, type: this.type, interaction: this.interaction }, true);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -88,6 +88,7 @@ export async function play(client, sound, options, music = false) {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  const oldQueue = queues.get(voiceChannel.guildID);
 | 
					  const oldQueue = queues.get(voiceChannel.guildID);
 | 
				
			||||||
  if (!response.tracks || response.tracks.length === 0) return { content: "I couldn't find that song!", flags: 64 };
 | 
					  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) {
 | 
					  if (music) {
 | 
				
			||||||
    const sortedTracks = response.tracks.map((val) => { return val.track; });
 | 
					    const sortedTracks = response.tracks.map((val) => { return val.track; });
 | 
				
			||||||
    const playlistTracks = response.playlistInfo.selectedTrack ? sortedTracks : [sortedTracks[0]];
 | 
					    const playlistTracks = response.playlistInfo.selectedTrack ? sortedTracks : [sortedTracks[0]];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue