Fix interaction response object issue, fix soundplayer voice state detection
This commit is contained in:
		
							parent
							
								
									ab2d6e2ef0
								
							
						
					
					
						commit
						7c9f22cd34
					
				
					 3 changed files with 19 additions and 17 deletions
				
			
		| 
						 | 
					@ -19,10 +19,10 @@ class PlayCommand extends MusicCommand {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      const url = new URL(query);
 | 
					      const url = new URL(query);
 | 
				
			||||||
      return await 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 : `ytsearch:${query}`;
 | 
				
			||||||
      return await 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);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,11 +31,8 @@ export default async (client, interaction) => {
 | 
				
			||||||
        content: result,
 | 
					        content: result,
 | 
				
			||||||
        flags: commandClass.success ? 0 : 64
 | 
					        flags: commandClass.success ? 0 : 64
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    } else if (typeof result === "object" && result.embeds) {
 | 
					    } else if (typeof result === "object") {
 | 
				
			||||||
      await interaction[replyMethod](Object.assign(result, {
 | 
					      if (result.contents && result.name) {
 | 
				
			||||||
        flags: result.flags ?? (commandClass.success ? 0 : 64)
 | 
					 | 
				
			||||||
      }));
 | 
					 | 
				
			||||||
    } else if (typeof result === "object" && result.contents) {
 | 
					 | 
				
			||||||
        const fileSize = 8388119;
 | 
					        const fileSize = 8388119;
 | 
				
			||||||
        if (result.contents.length > fileSize) {
 | 
					        if (result.contents.length > fileSize) {
 | 
				
			||||||
          if (process.env.TEMPDIR && process.env.TEMPDIR !== "") {
 | 
					          if (process.env.TEMPDIR && process.env.TEMPDIR !== "") {
 | 
				
			||||||
| 
						 | 
					@ -49,6 +46,11 @@ export default async (client, interaction) => {
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          await interaction[replyMethod](result.text ? result.text : { files: [result] });
 | 
					          await interaction[replyMethod](result.text ? result.text : { files: [result] });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        await interaction[replyMethod](Object.assign({
 | 
				
			||||||
 | 
					          flags: result.flags ?? (commandClass.success ? 0 : 64)
 | 
				
			||||||
 | 
					        }, result));
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  } catch (error) {
 | 
					  } catch (error) {
 | 
				
			||||||
    const replyMethod = interaction.acknowledged ? "editOriginal" : "createMessage";
 | 
					    const replyMethod = interaction.acknowledged ? "editOriginal" : "createMessage";
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,7 +61,7 @@ export function reload() {
 | 
				
			||||||
export async function play(client, sound, options, music = false) {
 | 
					export async function play(client, sound, options, music = false) {
 | 
				
			||||||
  if (!manager) return { content: "The sound commands are still starting up!", flags: 64 };
 | 
					  if (!manager) return { content: "The sound commands are still starting up!", flags: 64 };
 | 
				
			||||||
  if (!options.channel.guild) return { content: "This command only works in servers!", flags: 64 };
 | 
					  if (!options.channel.guild) return { content: "This command only works in servers!", flags: 64 };
 | 
				
			||||||
  if (!options.member.voiceState.channelID) return { content: "You need to be in a voice channel first!", flags: 64 };
 | 
					  if (!options.member.voiceState) return { content: "You need to be in a voice channel first!", flags: 64 };
 | 
				
			||||||
  if (!options.channel.guild.permissionsOf(client.user.id.toString()).has("CONNECT")) return { content: "I can't join this voice channel!", flags: 64 };
 | 
					  if (!options.channel.guild.permissionsOf(client.user.id.toString()).has("CONNECT")) return { content: "I can't join this voice channel!", flags: 64 };
 | 
				
			||||||
  const voiceChannel = options.channel.guild.channels.get(options.member.voiceState.channelID);
 | 
					  const voiceChannel = options.channel.guild.channels.get(options.member.voiceState.channelID);
 | 
				
			||||||
  if (!voiceChannel.permissionsOf(client.user.id.toString()).has("CONNECT")) return { content: "I don't have permission to join this voice channel!", flags: 64 };
 | 
					  if (!voiceChannel.permissionsOf(client.user.id.toString()).has("CONNECT")) return { content: "I don't have permission to join this voice channel!", flags: 64 };
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue