aboutsummaryrefslogtreecommitdiff
path: root/bot/src/commands/avatar.js
blob: 3d9860859fbaa5d0eb9cee5ad458312aea226f87 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { SlashCommandBuilder } from 'discord.js';

export default {
    data: new SlashCommandBuilder()
        .setName('avatar')
        .setDescription('Gives the profile picture of the user.')
        .addUserOption(option =>
            option
                .setName('username')
                .setDescription('The user to get the avatar of.'))
        .addBooleanOption(option =>
            option
                .setName('server')
                .setDescription('Gets the member\'s server profile picture.')),

    async execute(interaction) {
        const username = interaction.options.getUser('username');
        const server = interaction.options.getBoolean('server');

        if (username && server) {
            const member = interaction.guild.members.cache.get(username.id);
            return await interaction.reply(member.avatarURL({ dynamic: true, format: 'png', size: 1024 }));
        } else if (server) {
            return await interaction.reply(interaction.member.avatarURL({ dynamic: true, format: 'png', size: 1024 }));
        }

        if (!username) {
            return await interaction.reply(interaction.user.avatarURL({ dynamic: true, format: 'png', size: 1024 }));
        } else {
            return await interaction.reply(username.avatarURL({ dynamic: true, format: 'png', size: 1024 }));
        }
    }
};