Fix some permission checks, fix avatar URLs
This commit is contained in:
		
							parent
							
								
									888f2f8b4a
								
							
						
					
					
						commit
						49a60bba96
					
				
					 11 changed files with 22 additions and 19 deletions
				
			
		| 
						 | 
					@ -92,8 +92,11 @@ class ImageCommand extends Command {
 | 
				
			||||||
      if (e === "No available servers") return "I can't seem to contact the image servers, they might be down or still trying to start up. Please wait a little bit.";
 | 
					      if (e === "No available servers") return "I can't seem to contact the image servers, they might be down or still trying to start up. Please wait a little bit.";
 | 
				
			||||||
      throw e;
 | 
					      throw e;
 | 
				
			||||||
    } finally {
 | 
					    } finally {
 | 
				
			||||||
      const statusChannel = status.channel ?? await this.client.rest.channels.get(status.channelID);
 | 
					      try {
 | 
				
			||||||
      if (status && (statusChannel.messages ? statusChannel.messages.has(status.id) : await this.client.getMessage(statusChannel.id, status.id).catch(() => undefined))) await status.delete();
 | 
					        if (status) await status.delete();
 | 
				
			||||||
 | 
					      } catch {
 | 
				
			||||||
 | 
					        // no-op
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
      runningCommands.delete(this.author.id);
 | 
					      runningCommands.delete(this.author.id);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,7 +54,7 @@ class HelpCommand extends Command {
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      return embed;
 | 
					      return embed;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      if (this.guild && !this.channel.permissionsOf(this.client.user.id).has("EMBED_LINKS")) {
 | 
					      if (this.guild && !this.channel.permissionsOf(this.client.user.id.toString()).has("EMBED_LINKS")) {
 | 
				
			||||||
        this.success = false;
 | 
					        this.success = false;
 | 
				
			||||||
        return "I don't have the `Embed Links` permission!";
 | 
					        return "I don't have the `Embed Links` permission!";
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,7 @@ import Command from "../../classes/command.js";
 | 
				
			||||||
class ImageSearchCommand extends Command {
 | 
					class ImageSearchCommand extends Command {
 | 
				
			||||||
  async run() {
 | 
					  async run() {
 | 
				
			||||||
    this.success = false;
 | 
					    this.success = false;
 | 
				
			||||||
    if (this.channel && !this.channel.permissionsOf(this.client.user.id).has("EMBED_LINKS")) return "I don't have the `Embed Links` permission!";
 | 
					    if (this.channel && !this.channel.permissionsOf(this.client.user.id.toString()).has("EMBED_LINKS")) return "I don't have the `Embed Links` permission!";
 | 
				
			||||||
    const query = this.options.query ?? this.args.join(" ");
 | 
					    const query = this.options.query ?? this.args.join(" ");
 | 
				
			||||||
    if (!query || !query.trim()) return "You need to provide something to search for!";
 | 
					    if (!query || !query.trim()) return "You need to provide something to search for!";
 | 
				
			||||||
    await this.acknowledge();
 | 
					    await this.acknowledge();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,7 @@ class ImageStatsCommand extends Command {
 | 
				
			||||||
      embeds: [{
 | 
					      embeds: [{
 | 
				
			||||||
        "author": {
 | 
					        "author": {
 | 
				
			||||||
          "name": "esmBot Image Statistics",
 | 
					          "name": "esmBot Image Statistics",
 | 
				
			||||||
          "iconURL": this.client.user.avatarURL
 | 
					          "iconURL": this.client.user.avatarURL()
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        "color": 16711680,
 | 
					        "color": 16711680,
 | 
				
			||||||
        "description": `The bot is currently connected to ${connections.size} image server(s).`,
 | 
					        "description": `The bot is currently connected to ${connections.size} image server(s).`,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,7 @@ class NowPlayingCommand extends MusicCommand {
 | 
				
			||||||
        color: 16711680,
 | 
					        color: 16711680,
 | 
				
			||||||
        author: {
 | 
					        author: {
 | 
				
			||||||
          name: "Now Playing",
 | 
					          name: "Now Playing",
 | 
				
			||||||
          iconURL: this.client.user.avatarURL
 | 
					          iconURL: this.client.user.avatarURL()
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        fields: [{
 | 
					        fields: [{
 | 
				
			||||||
          name: "ℹ️ Title",
 | 
					          name: "ℹ️ Title",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,12 +5,12 @@ const prefixes = ["ytsearch:", "ytmsearch:", "scsearch:", "spsearch:", "amsearch
 | 
				
			||||||
class PlayCommand extends MusicCommand {
 | 
					class PlayCommand extends MusicCommand {
 | 
				
			||||||
  async run() {
 | 
					  async run() {
 | 
				
			||||||
    const input = this.options.query ?? this.args.join(" ");
 | 
					    const input = this.options.query ?? this.args.join(" ");
 | 
				
			||||||
    if (!input && ((!this.message || this.message?.attachments.length <= 0))) {
 | 
					    if (!input && ((!this.message || this.message?.attachments.size <= 0))) {
 | 
				
			||||||
      this.success = false;
 | 
					      this.success = false;
 | 
				
			||||||
      return "You need to provide what you want to play!";
 | 
					      return "You need to provide what you want to play!";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let query = input ? input.trim() : "";
 | 
					    let query = input ? input.trim() : "";
 | 
				
			||||||
    const attachment = this.type === "classic" ? this.message.attachments[0] : null;
 | 
					    const attachment = this.type === "classic" ? this.message.attachments.first() : null;
 | 
				
			||||||
    if (query.startsWith("||") && query.endsWith("||")) {
 | 
					    if (query.startsWith("||") && query.endsWith("||")) {
 | 
				
			||||||
      query = query.substring(2, query.length - 2);
 | 
					      query = query.substring(2, query.length - 2);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,7 +10,7 @@ class QueueCommand extends MusicCommand {
 | 
				
			||||||
    if (!this.guild) return "This command only works in servers!";
 | 
					    if (!this.guild) return "This command only works in servers!";
 | 
				
			||||||
    if (!this.member.voiceState.channelID) return "You need to be in a voice channel first!";
 | 
					    if (!this.member.voiceState.channelID) return "You need to be in a voice channel first!";
 | 
				
			||||||
    if (!this.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
 | 
					    if (!this.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
 | 
				
			||||||
    if (!this.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
 | 
					    if (!this.channel.permissionsOf(this.client.user.id.toString()).has("EMBED_LINKS")) return "I don't have the `Embed Links` permission!";
 | 
				
			||||||
    const player = this.connection;
 | 
					    const player = this.connection;
 | 
				
			||||||
    const node = nodes.filter((val) => val.name === player.player.node.name)[0];
 | 
					    const node = nodes.filter((val) => val.name === player.player.node.name)[0];
 | 
				
			||||||
    const tracks = await request(`http://${node.url}/decodetracks`, { method: "POST", body: JSON.stringify(this.queue), headers: { authorization: node.auth, "content-type": "application/json" } }).then(res => res.body.json());
 | 
					    const tracks = await request(`http://${node.url}/decodetracks`, { method: "POST", body: JSON.stringify(this.queue), headers: { authorization: node.auth, "content-type": "application/json" } }).then(res => res.body.json());
 | 
				
			||||||
| 
						 | 
					@ -30,7 +30,7 @@ class QueueCommand extends MusicCommand {
 | 
				
			||||||
        embeds: [{
 | 
					        embeds: [{
 | 
				
			||||||
          author: {
 | 
					          author: {
 | 
				
			||||||
            name: "Queue",
 | 
					            name: "Queue",
 | 
				
			||||||
            iconURL: this.client.user.avatarURL
 | 
					            iconURL: this.client.user.avatarURL()
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
          color: 16711680,
 | 
					          color: 16711680,
 | 
				
			||||||
          footer: {
 | 
					          footer: {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,7 +57,7 @@ class TagsCommand extends Command {
 | 
				
			||||||
        return `This tag is owned by **${user.username}#${user.discriminator}** (\`${getResult.author}\`).`;
 | 
					        return `This tag is owned by **${user.username}#${user.discriminator}** (\`${getResult.author}\`).`;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } else if (cmd === "list") {
 | 
					    } else if (cmd === "list") {
 | 
				
			||||||
      if (!this.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
 | 
					      if (!this.channel.permissionsOf(this.client.user.id.toString()).has("EMBED_LINKS")) return "I don't have the `Embed Links` permission!";
 | 
				
			||||||
      const tagList = await database.getTags(this.guild.id);
 | 
					      const tagList = await database.getTags(this.guild.id);
 | 
				
			||||||
      const embeds = [];
 | 
					      const embeds = [];
 | 
				
			||||||
      const groups = Object.keys(tagList).map((item, index) => {
 | 
					      const groups = Object.keys(tagList).map((item, index) => {
 | 
				
			||||||
| 
						 | 
					@ -76,7 +76,7 @@ class TagsCommand extends Command {
 | 
				
			||||||
            description: value.join("\n"),
 | 
					            description: value.join("\n"),
 | 
				
			||||||
            author: {
 | 
					            author: {
 | 
				
			||||||
              name: this.author.username,
 | 
					              name: this.author.username,
 | 
				
			||||||
              iconURL: this.author.avatarURL
 | 
					              iconURL: this.author.avatarURL()
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          }]
 | 
					          }]
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,7 @@ export default async (client, member, oldChannel) => {
 | 
				
			||||||
          queues.delete(connection.originalChannel.guildID);
 | 
					          queues.delete(connection.originalChannel.guildID);
 | 
				
			||||||
          skipVotes.delete(connection.originalChannel.guildID);
 | 
					          skipVotes.delete(connection.originalChannel.guildID);
 | 
				
			||||||
          client.rest.channels.createMessage(connection.originalChannel.id, {
 | 
					          client.rest.channels.createMessage(connection.originalChannel.id, {
 | 
				
			||||||
            content: `🔊 The voice channel session in \`${connection.originalChannel.name}\` has ended.`
 | 
					            content: `🔊 The voice channel session in \`${connection.voiceChannel.name}\` has ended.`
 | 
				
			||||||
          });
 | 
					          });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
| 
						 | 
					@ -83,7 +83,7 @@ export default async (client, member, oldChannel) => {
 | 
				
			||||||
            queues.delete(connection.originalChannel.guildID);
 | 
					            queues.delete(connection.originalChannel.guildID);
 | 
				
			||||||
            skipVotes.delete(connection.originalChannel.guildID);
 | 
					            skipVotes.delete(connection.originalChannel.guildID);
 | 
				
			||||||
            client.rest.channels.createMessage(connection.originalChannel.id, {
 | 
					            client.rest.channels.createMessage(connection.originalChannel.id, {
 | 
				
			||||||
              content: `🔊 The voice channel session in \`${connection.originalChannel.name}\` has ended.`
 | 
					              content: `🔊 The voice channel session in \`${connection.voiceChannel.name}\` has ended.`
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
          } else {
 | 
					          } else {
 | 
				
			||||||
            const randomMember = random(members);
 | 
					            const randomMember = random(members);
 | 
				
			||||||
| 
						 | 
					@ -105,7 +105,7 @@ export default async (client, member, oldChannel) => {
 | 
				
			||||||
      queues.delete(connection.originalChannel.guildID);
 | 
					      queues.delete(connection.originalChannel.guildID);
 | 
				
			||||||
      skipVotes.delete(connection.originalChannel.guildID);
 | 
					      skipVotes.delete(connection.originalChannel.guildID);
 | 
				
			||||||
      await client.rest.channels.createMessage(connection.originalChannel.id, {
 | 
					      await client.rest.channels.createMessage(connection.originalChannel.id, {
 | 
				
			||||||
        content: `🔊 The voice channel session in \`${connection.originalChannel.name}\` has ended.`
 | 
					        content: `🔊 The voice channel session in \`${connection.voiceChannel.name}\` has ended.`
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,7 +10,7 @@ class AwaitRejoin extends EventEmitter {
 | 
				
			||||||
    this.channel = channel;
 | 
					    this.channel = channel;
 | 
				
			||||||
    this.rejoined = false;
 | 
					    this.rejoined = false;
 | 
				
			||||||
    this.ended = false;
 | 
					    this.ended = false;
 | 
				
			||||||
    this.bot = channel.guild ? channel.guild.shard._client : channel._client;
 | 
					    this.bot = channel.client;
 | 
				
			||||||
    this.listener = (member, newChannel) => this.verify(member, newChannel);
 | 
					    this.listener = (member, newChannel) => this.verify(member, newChannel);
 | 
				
			||||||
    this.bot.on("voiceChannelJoin", this.listener);
 | 
					    this.bot.on("voiceChannelJoin", this.listener);
 | 
				
			||||||
    this.bot.on("voiceChannelSwitch", this.listener);
 | 
					    this.bot.on("voiceChannelSwitch", this.listener);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,9 +63,9 @@ 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.channelID) return { content: "You need to be in a voice channel first!", flags: 64 };
 | 
				
			||||||
  if (!options.channel.guild.permissionsOf(client.user.id).has("voiceConnect")) 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).has("voiceConnect")) 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 };
 | 
				
			||||||
  if (!music && manager.players.has(options.channel.guildID)) return { content: "I can't play a sound effect while other audio is playing!", flags: 64 };
 | 
					  if (!music && manager.players.has(options.channel.guildID)) return { content: "I can't play a sound effect while other audio is playing!", flags: 64 };
 | 
				
			||||||
  let node = manager.getNode();
 | 
					  let node = manager.getNode();
 | 
				
			||||||
  if (!node) {
 | 
					  if (!node) {
 | 
				
			||||||
| 
						 | 
					@ -132,7 +132,7 @@ export async function nextSong(client, options, connection, track, info, music,
 | 
				
			||||||
          color: 16711680,
 | 
					          color: 16711680,
 | 
				
			||||||
          author: {
 | 
					          author: {
 | 
				
			||||||
            name: "Now Playing",
 | 
					            name: "Now Playing",
 | 
				
			||||||
            iconURL: client.user.avatarURL
 | 
					          iconURL: client.user.avatarURL()
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
          fields: [{
 | 
					          fields: [{
 | 
				
			||||||
            name: "ℹ️ Title",
 | 
					            name: "ℹ️ Title",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue