aboutsummaryrefslogtreecommitdiff
path: root/examples/discord-interactions/commands/context_menu/avatar.js
blob: fee1ccc689858646939fffd3caf4a51b0c794855 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { SlashCommand, ApplicationCommandType } from 'slash-create';

export default class AvatarCommand extends SlashCommand {
  constructor(creator) {
    super(creator, {
      // You must specify a type for context menu commands, but defaults
      // to `CHAT_INPUT`, or regular slash commands.
      type: ApplicationCommandType.USER,
      name: 'Get Avatar URL',
    });

    this.filePath = __filename;
  }

  async run(ctx) {
    // The target user can be accessed from here
    // You can also use `ctx.targetMember` for member properties
    const target = ctx.targetUser;
    return `${target.username}'s Avatar: ${target.avatarURL}`;
  }
}