From a878ea977c54a1bbdefd3b4b70c8d5573026d4d2 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 24 Feb 2020 01:46:30 +0100 Subject: [PATCH] Updated to be like avatar command --- commands/utility/serverIcon.js | 36 ++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/commands/utility/serverIcon.js b/commands/utility/serverIcon.js index b805e1a9..7332601f 100644 --- a/commands/utility/serverIcon.js +++ b/commands/utility/serverIcon.js @@ -21,12 +21,36 @@ class serverIconCommand extends Command { } async exec(message, args) { - if (!args.serverid) - return message.channel.send('This server icon:', {files: [message.guild.iconURL()]}); - else if (this.client.guilds.find(guild => guild.id == args.serverid)) - return message.channel.send(`${this.client.guilds.find(guild => guild.id == args.serverid).name}`, {files: [this.client.guilds.find(guild => guild.id == args.serverid).iconURL()]}); - else - return message.channel.send('Could not find any guild, am i in the guild you are trying to get the icon of?'); + const serverEmbed = this.client.util.embed() + .setColor(message.member.displayHexColor) + .setTitle('Server icon'); + + + if (!args.serverid) { + let format = message.guild.iconURL().substr(message.guild.iconURL().length - 3); + if (format == 'gif') { + serverEmbed.setAuthor(message.guild.name); + serverEmbed.setDescription(`[gif](${message.guild.iconURL({ format: 'gif', size: 2048 })})`); + serverEmbed.setImage(message.guild.iconURL({ format: 'gif', size: 2048 })); + } else { + serverEmbed.setAuthor(message.guild.name); + serverEmbed.setDescription(`[png](${message.guild.iconURL({ format: 'png', size: 2048 })}) | [jpeg](${message.guild.iconURL({ format: 'jpg', size: 2048 })}) | [webp](${message.guild.iconURL({ format: 'webp', size: 2048 })})`); + serverEmbed.setImage(message.guild.iconURL({ format: 'png', size: 2048 })); + } + return message.channel.send({embed: serverEmbed}); + } else { + let format = this.client.guilds.find(guild => guild.id == args.serverid).iconURL().substr(this.client.guilds.find(guild => guild.id == args.serverid).iconURL().length - 3); + if (format == 'gif') { + serverEmbed.setAuthor(this.client.guilds.find(guild => guild.id == args.serverid).name); + serverEmbed.setDescription(`[gif](${this.client.guilds.find(guild => guild.id == args.serverid).iconURL({ format: 'gif', size: 2048 })})`); + serverEmbed.setImage(this.client.guilds.find(guild => guild.id == args.serverid).iconURL({ format: 'gif', size: 2048 })); + } else { + serverEmbed.setAuthor(this.client.guilds.find(guild => guild.id == args.serverid).name); + serverEmbed.setDescription(`[png](${this.client.guilds.find(guild => guild.id == args.serverid).iconURL({ format: 'png', size: 2048 })}) | [jpeg](${this.client.guilds.find(guild => guild.id == args.serverid).iconURL({ format: 'jpg', size: 2048 })}) | [webp](${this.client.guilds.find(guild => guild.id == args.serverid).iconURL({ format: 'webp', size: 2048 })})`); + serverEmbed.setImage(this.client.guilds.find(guild => guild.id == args.serverid).iconURL({ format: 'png', size: 2048 })); + } + return message.channel.send({embed: serverEmbed}); + } } }