Fix voice channel check error
This commit is contained in:
		
							parent
							
								
									a91c73b5bd
								
							
						
					
					
						commit
						c37a8a5fcf
					
				
					 3 changed files with 5 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -4,7 +4,7 @@ import { play } from "../utils/soundplayer.js";
 | 
			
		|||
// only exists to sort the various soundboard commands
 | 
			
		||||
class SoundboardCommand extends Command {
 | 
			
		||||
  async run() {
 | 
			
		||||
    return await play(this.client, this.constructor.file, { channel: this.channel, author: this.author, type: this.type, interaction: this.interaction });
 | 
			
		||||
    return await play(this.client, this.constructor.file, { channel: this.channel, author: this.author, member: this.member, type: this.type, interaction: this.interaction });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static requires = ["sound"];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,10 +15,10 @@ class PlayCommand extends MusicCommand {
 | 
			
		|||
    }
 | 
			
		||||
    try {
 | 
			
		||||
      const url = new URL(query);
 | 
			
		||||
      return await play(this.client, url, { channel: this.channel, author: this.author, type: this.type, interaction: this.interaction }, true);
 | 
			
		||||
      return await play(this.client, url, { channel: this.channel, author: this.author, member: this.member, type: this.type, interaction: this.interaction }, true);
 | 
			
		||||
    } catch {
 | 
			
		||||
      const search = query.startsWith("ytsearch:") ? query : !query && attachment ? attachment.url : `ytsearch:${query}`;
 | 
			
		||||
      return await play(this.client, search, { channel: this.channel, author: this.author, type: this.type, interaction: this.interaction }, true);
 | 
			
		||||
      return await play(this.client, search, { channel: this.channel, author: this.author, member: this.member, type: this.type, interaction: this.interaction }, true);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,9 +53,9 @@ export async function connect(client) {
 | 
			
		|||
export async function play(client, sound, options, music = false) {
 | 
			
		||||
  if (!manager) return "The sound commands are still starting up!";
 | 
			
		||||
  if (!options.channel.guild) return "This command only works in servers!";
 | 
			
		||||
  if (!options.author.voiceState.channelID) return "You need to be in a voice channel first!";
 | 
			
		||||
  if (!options.member.voiceState.channelID) return "You need to be in a voice channel first!";
 | 
			
		||||
  if (!options.channel.guild.permissionsOf(client.user.id).has("voiceConnect")) return "I can't join this voice channel!";
 | 
			
		||||
  const voiceChannel = options.channel.guild.channels.get(options.author.voiceState.channelID);
 | 
			
		||||
  const voiceChannel = options.channel.guild.channels.get(options.member.voiceState.channelID);
 | 
			
		||||
  if (!voiceChannel.permissionsOf(client.user.id).has("voiceConnect")) return "I don't have permission to join this voice channel!";
 | 
			
		||||
  const player = players.get(options.channel.guild.id);
 | 
			
		||||
  if (!music && manager.voiceStates.has(options.channel.guild.id) && (player && player.type === "music")) return "I can't play a sound effect while playing music!";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue