aboutsummaryrefslogtreecommitdiff
path: root/bot/src/commands/avatar.js
blob: a1db300c4e6bd1b388e4c70b4a9bdc7bda82d200 (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
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') || interaction.user;
        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 }));
        }

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