MCPcopy Create free account
hub / github.com/esmBot/esmBot / run

Method run

commands/general/avatar.js:7–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5
6class AvatarCommand extends Command {
7 async run() {
8 const member = this.getOptionMember("member") ?? this.getOptionUser("member") ?? this.args[0];
9 const server = !!this.getOptionBoolean("server");
10 let self;
11 if (server && this.guild) {
12 self = this.member ?? this.author;
13 } else {
14 self = this.author;
15 }
16 if (this.type === "classic" && this.message?.mentions.users[0])
17 return (this.message.mentions.members[0] ?? this.message.mentions.users[0])?.avatarURL(undefined, imageSize);
18 if (member && typeof member !== "string") {
19 return (member instanceof Member && !server ? member.user : member).avatarURL(undefined, imageSize);
20 }
21 if (member) {
22 const user = await mentionToObject(this.client, member, "user", {
23 guild: this.guild,
24 server,
25 });
26 if (user) return user.avatarURL(undefined, imageSize);
27 }
28 if (this.args.join(" ") !== "" && this.guild) {
29 const searched = await this.guild.searchMembers({
30 query: this.args.join(" "),
31 limit: 1,
32 });
33 if (searched.length > 0) {
34 const user = await getUser(this.client, this.guild, searched[0].user.id, server);
35 if (user) return user.avatarURL(undefined, imageSize);
36 }
37 }
38 return self.avatarURL(undefined, imageSize);
39 }
40
41 static description = "Gets a user's avatar";
42 static aliases = ["pfp", "ava"];

Callers

nothing calls this directly

Calls 5

mentionToObjectFunction · 0.85
getUserFunction · 0.85
getOptionMemberMethod · 0.80
getOptionUserMethod · 0.80
getOptionBooleanMethod · 0.80

Tested by

no test coverage detected