/[sudobot]/trunk/src/commands/information/UserLookupCommand.ts
ViewVC logotype

Diff of /trunk/src/commands/information/UserLookupCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 285 by rakin, Mon Jul 29 17:29:22 2024 UTC revision 344 by rakin, Mon Jul 29 17:29:40 2024 UTC
# Line 1  Line 1 
1  import { formatDistanceStrict, formatDistanceToNowStrict } from "date-fns";  import { formatDistanceStrict, formatDistanceToNowStrict } from "date-fns";
2  import { APIEmbedField } from "discord-api-types/v9";  import { APIEmbedField } from "discord-api-types/v9";
3  import { Util, Message, Interaction, CacheType, CommandInteraction } from "discord.js";  import { Util, Message, CacheType, CommandInteraction } from "discord.js";
4  import Client from "../../client/Client";  import Client from "../../client/Client";
5  import MessageEmbed from "../../client/MessageEmbed";  import MessageEmbed from "../../client/MessageEmbed";
6  import CommandOptions from "../../types/CommandOptions";  import CommandOptions from "../../types/CommandOptions";
7  import InteractionOptions from "../../types/InteractionOptions";  import InteractionOptions from "../../types/InteractionOptions";
8  import { emoji } from "../../utils/Emoji";  import { emoji } from "../../utils/Emoji";
9  import getUser from "../../utils/getUser";  import getUser from "../../utils/getUser";
 import { parseUser } from "../../utils/parseInput";  
10  import BaseCommand from "../../utils/structures/BaseCommand";  import BaseCommand from "../../utils/structures/BaseCommand";
11    import { getUserBadges } from "./ProfileCommand";
12    
13  export default class UserLookupCommand extends BaseCommand {  export default class UserLookupCommand extends BaseCommand {
14      supportsInteractions: boolean = true;      supportsInteractions: boolean = true;
# Line 53  export default class UserLookupCommand e Line 53  export default class UserLookupCommand e
53              }              }
54          });          });
55    
56    
57            if (user.hexAccentColor) {            
58                embed.setColor(user.hexAccentColor);
59            }
60    
61          const fieldsCommon: APIEmbedField[] = [            const fieldsCommon: APIEmbedField[] = [  
62                            
63          ];          ];
# Line 61  export default class UserLookupCommand e Line 66  export default class UserLookupCommand e
66              {              {
67                  name: "Server Member?",                  name: "Server Member?",
68                  value: member ? "Yes" : "No",                  value: member ? "Yes" : "No",
69                    inline: true
70                },
71                {
72                    name: "Bot?",
73                    value: user.bot ? "Yes" : "No",
74                    inline: true
75              },              },
76              {              {
77                  name: "Account created",                  name: "Account created",
78                  value: formatDistanceToNowStrict(user.createdAt, { addSuffix: true }),                  value: user.createdAt.toLocaleString() + " (" + formatDistanceToNowStrict(user.createdAt, { addSuffix: true }) + ")",
79                  inline: true                  inline: true
80              }              }
81          ];          ];
82    
83            embed.setThumbnail(user.displayAvatarURL());
84    
85          if (member) {          if (member) {
86              fields.push({              fields.push({
87                  name: "Joined Server",                  name: "Joined Server",
88                  value: member.joinedAt ? formatDistanceToNowStrict(member.joinedAt, { addSuffix: true }) : "Information not available",                  value: member.joinedAt ? member.joinedAt.toLocaleString() + " (" + formatDistanceToNowStrict(member.joinedAt, { addSuffix: true }) + ")" : "Information not available",
89                  inline: true                  inline: true
90              });              });
91    
92              if (member.premiumSince) {              if (member.premiumSince) {
93                  fields.push({                  fields.push({
94                      name: "Boosted Server",                      name: "Boosted Server",
95                      value: formatDistanceToNowStrict(member.premiumSince, { addSuffix: true }),                      value: member.premiumSince.toLocaleString() + " (" + formatDistanceToNowStrict(member.premiumSince, { addSuffix: true }) + ")",
96                      inline: true                      inline: true
97                  });                  });
98              }              }
# Line 87  export default class UserLookupCommand e Line 100  export default class UserLookupCommand e
100              if (member.communicationDisabledUntil) {              if (member.communicationDisabledUntil) {
101                  fields.push({                  fields.push({
102                      name: "Timed-out Until",                      name: "Timed-out Until",
103                      value: formatDistanceStrict(member.communicationDisabledUntil, new Date()),                      value: member.communicationDisabledUntil.toLocaleString() + " (" + formatDistanceStrict(member.communicationDisabledUntil, new Date()) + ")",
104                      inline: true                      inline: true
105                  });                  });
106              }              }
107    
108              if (member.displayAvatarURL() != user.displayAvatarURL()) {              if (member.displayAvatarURL()) {
109                  embed.setThumbnail(member.displayAvatarURL());                  embed.setThumbnail(member.displayAvatarURL());
110              }              }
111    
112                if (member.nickname) {
113                    fields.push({
114                        name: "Nickname",
115                        value: Util.escapeMarkdown(member.nickname)
116                    });
117                }
118    
119                if (member.displayHexColor) {
120                    fields.push({
121                        name: "Guild Profile Theme Color",
122                        value: member.displayHexColor
123                    });
124                }
125                
126                if (member.displayHexColor && !user.hexAccentColor) {
127                    embed.setColor(member.displayHexColor);
128                }
129    
130                if (member.voice && member.voice.channel) {
131                    fields.push({
132                        name: "Current Voice Channel",
133                        value: member.voice.channel.toString()
134                    });
135                }
136    
137                fields.push({
138                    name: "Completed Membership Screening",
139                    value: member.pending ? "No" : "Yes"
140                });
141    
142                fields.push({
143                    name: "Mention",
144                    value: member.toString()
145                });
146    
147                if (member.roles.highest.id !== member.guild.id) {
148                    fields.push({
149                        name: "Highest Role",
150                        value: member.roles.highest.toString()
151                    });
152                }
153          }          }
154    
155            const badges = getUserBadges(user).join('\n');
156    
157            fields.push({
158                name: "Badges",
159                value: badges.trim() === '' ? '*No badges found*' : badges
160            });
161    
162          fields = [...fields, ...fieldsCommon];          fields = [...fields, ...fieldsCommon];
163          embed.setFields(fields);          embed.setFields(fields);
164            embed.setTimestamp();
165                    
166          await message.reply({          await message.reply({
167              embeds: [              embeds: [

Legend:
Removed from v.285  
changed lines
  Added in v.344

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26