aboutsummaryrefslogtreecommitdiff
path: root/src/commands/info/avatar.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-30 20:45:54 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-30 20:45:54 -0400
commit535c0544086acc5af3d2806a203d6a9d6f8b94f9 (patch)
tree1238d38c5dd67ba0973887e9936a22b59b8db7fc /src/commands/info/avatar.ts
parent464425b731754c8b2024c3ac2c004758ee7ddb6d (diff)
downloadtanzanite-535c0544086acc5af3d2806a203d6a9d6f8b94f9.tar.gz
tanzanite-535c0544086acc5af3d2806a203d6a9d6f8b94f9.tar.bz2
tanzanite-535c0544086acc5af3d2806a203d6a9d6f8b94f9.zip
globalUser, new embeded activies, per server avatars
Diffstat (limited to 'src/commands/info/avatar.ts')
-rw-r--r--src/commands/info/avatar.ts26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/commands/info/avatar.ts b/src/commands/info/avatar.ts
index 7654d2f..1e6496a 100644
--- a/src/commands/info/avatar.ts
+++ b/src/commands/info/avatar.ts
@@ -1,4 +1,4 @@
-import { MessageEmbed, User } from 'discord.js';
+import { GuildMember, MessageEmbed, User } from 'discord.js';
import { BushCommand, BushMessage, BushSlashMessage } from '../../lib';
export default class AvatarCommand extends BushCommand {
@@ -14,7 +14,7 @@ export default class AvatarCommand extends BushCommand {
args: [
{
id: 'user',
- type: 'user',
+ customType: util.arg.union('member', 'globalUser'),
prompt: {
start: 'Who would you like to see the avatar of?',
retry: '{error} Choose a valid user.',
@@ -35,16 +35,20 @@ export default class AvatarCommand extends BushCommand {
});
}
- override async exec(message: BushMessage | BushSlashMessage, args: { user: User }): Promise<void> {
- const user = args.user ?? message.author;
+ override async exec(message: BushMessage | BushSlashMessage, args: { user: GuildMember | User }): Promise<void> {
+ const params: { size: 2048; format: 'png'; dynamic: true } = { size: 2048, format: 'png', dynamic: true };
+ const defaultAvatar = `https://cdn.discordapp.com/embed/avatars/${Math.ceil(Math.random() * 6) - 1}.png`;
+
+ const member = (args.user ?? message.member) instanceof GuildMember ? args.user ?? message.member : undefined;
+ const user = args.user instanceof GuildMember ? args.user.user : args.user ?? message.author;
+
+ const guildAvatar = member?.avatarURL(params);
+
+ const embed = new MessageEmbed().setTimestamp().setColor(util.colors.default).setTitle(`${user.tag}'s Avatar`);
+ guildAvatar
+ ? embed.setImage(guildAvatar).setThumbnail(user.avatarURL(params) ?? defaultAvatar)
+ : embed.setImage(user.avatarURL(params) ?? defaultAvatar);
- const embed = new MessageEmbed()
- .setTimestamp()
- .setColor(util.colors.default)
- .setTitle(`${user.tag}'s Avatar`)
- .setImage(
- user.avatarURL({ size: 2048, format: 'png', dynamic: true }) ?? 'https://cdn.discordapp.com/embed/avatars/0.png'
- );
await message.util.reply({ embeds: [embed] });
}
}