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

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

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

revision 263 by rakin, Mon Jul 29 17:29:16 2024 UTC revision 264 by rakin, Mon Jul 29 17:29:16 2024 UTC
# Line 1  Line 1 
1  import { ColorResolvable, CommandInteraction, GuildMember, Message, User } from 'discord.js';  import { ColorResolvable, CommandInteraction, GuildMember, Message, User, UserFlags } from 'discord.js';
2  import BaseCommand from '../../utils/structures/BaseCommand';  import BaseCommand from '../../utils/structures/BaseCommand';
3  import DiscordClient from '../../client/Client';  import DiscordClient from '../../client/Client';
4  import CommandOptions from '../../types/CommandOptions';  import CommandOptions from '../../types/CommandOptions';
# Line 69  export default class ProfileCommand exte Line 69  export default class ProfileCommand exte
69          };              };    
70    
71          const statusText = '' + ((user?.presence?.clientStatus?.desktop ? 'Desktop (' + status(user?.presence?.clientStatus?.desktop) + ')\n' : '') + (user?.presence?.clientStatus?.web ? 'Web (' + status(user?.presence?.clientStatus?.web) + ')\n' : '') + (user?.presence?.clientStatus?.mobile ? 'Mobile (' + status(user?.presence?.clientStatus?.mobile) + ')' : ''));          const statusText = '' + ((user?.presence?.clientStatus?.desktop ? 'Desktop (' + status(user?.presence?.clientStatus?.desktop) + ')\n' : '') + (user?.presence?.clientStatus?.web ? 'Web (' + status(user?.presence?.clientStatus?.web) + ')\n' : '') + (user?.presence?.clientStatus?.mobile ? 'Mobile (' + status(user?.presence?.clientStatus?.mobile) + ')' : ''));
72          const state = user?.presence?.activities.find(a => a.type === 'CUSTOM')?.state;          // const state = user?.presence?.activities.find(a => a.type === 'CUSTOM')?.state;
73            let activities: string[] | string = [];
74    
75            if (user?.presence) {
76                for (const a of user?.presence?.activities.values()!) {
77                    console.log(a);
78                    
79                    if (a.type === 'CUSTOM') {
80                        activities.push(`${a.emoji?.toString()} ${a.state}`);
81                    }
82                    else if (a.type === 'LISTENING') {
83                        if (a.name === 'Spotify') {
84                            activities.push(`:notes: Listening to **Spotify**: **${a.state?.replace(/\;/, ',')} - ${a.details}**`);
85                            continue;
86                        }
87    
88                        activities.push(`:musical_note: Listening to **${a.name}**`);
89                    }
90                    else if (a.type === 'COMPETING') {
91                        activities.push(`:fire: Competing **${a.name}**`);
92                    }
93                    else if (a.type === 'PLAYING') {
94                        activities.push(`:video_game: Playing **${a.name}**`);
95                    }
96                    else if (a.type === 'STREAMING') {
97                        activities.push(`:video_camera: Streaming **${a.name}**`);
98                    }
99                    else if (a.type === 'WATCHING') {
100                        activities.push(`:tv: Watching **${a.name}**`);
101                    }
102                }
103            }
104    
105            activities = activities.join('\n');
106    
107            const { FLAGS } = UserFlags;
108    
109            const getUserBadges = (user: User) => {
110                const badges = [];
111    
112                if (user.flags?.has(FLAGS.BUGHUNTER_LEVEL_1))
113                    badges.push('Bughunter Level 1');
114                if (user.flags?.has(FLAGS.BUGHUNTER_LEVEL_2))
115                    badges.push('Bughunter Level 2');
116                if (user.flags?.has(FLAGS.DISCORD_CERTIFIED_MODERATOR))
117                    badges.push('Discord Certified Moderator');
118                if (user.flags?.has(FLAGS.DISCORD_EMPLOYEE))
119                    badges.push('Discord Staff');
120                if (user.flags?.has(FLAGS.EARLY_SUPPORTER))
121                    badges.push('Early Nitro Supporter');
122                if (user.flags?.has(FLAGS.EARLY_VERIFIED_BOT_DEVELOPER))
123                    badges.push('Early Verified Bot Developer');
124                if (user.flags?.has(FLAGS.HOUSE_BALANCE))
125                    badges.push('HypeSquad Balance');
126                if (user.flags?.has(FLAGS.HOUSE_BRILLIANCE))
127                    badges.push('HypeSquad Brilliance');
128                if (user.flags?.has(FLAGS.HOUSE_BRAVERY))
129                    badges.push('HypeSquad Bravery');
130                if (user.flags?.has(FLAGS.HYPESQUAD_EVENTS))
131                    badges.push('HypeSquad Events');
132                if (user.flags?.has(FLAGS.PARTNERED_SERVER_OWNER))
133                    badges.push('Partnered Server Owner');
134                if (user.flags?.has(FLAGS.BOT_HTTP_INTERACTIONS))
135                    badges.push('Supports Interactions');
136                if (user.flags?.has(FLAGS.VERIFIED_BOT))
137                    badges.push('Verified Bot');
138                
139                return badges.map(b => `🔵 ${b}`);
140            };
141    
142            const fields = [
143                {
144                    name: "Nickname",
145                    value: `${user!.nickname?.replace(/\*\<\>\@\_\~\|/g, '') ?? '*Nickname not set*'}`
146                },
147                {
148                    name: "Account Created",
149                    value: `${user!.user.createdAt.toLocaleDateString('en-US')} (${timeSince(user!.user.createdTimestamp)})`
150                },
151                {
152                    name: "Joined at",
153                    value: `${user!.joinedAt!.toLocaleDateString('en-US')} (${timeSince(user!.joinedTimestamp!)})`
154                },
155                {
156                    name: 'Active Devices',
157                    value: `${statusText === '' ? 'Offline/Invisible' : statusText}`
158                },
159                {
160                    name: 'Status',
161                    value: `${activities?.trim() === '' ? '*No status set*' : activities}`
162                },
163                {
164                    name: 'Roles',
165                    value: user?.roles.cache.filter(role => role.id !== msg.guild!.id).sort((role1, role2) => {
166                        return role2.position - role1.position;
167                    }).reduce((acc, value) => `${acc} ${roleMention(value.id)}`, '')!.trim()!
168                }
169            ];
170    
171            const badges = getUserBadges(user!.user);
172    
173            if (badges.length > 0) {
174                fields.push({
175                    name: 'Badges',
176                    value: badges.join("\n")
177                });
178            }
179    
180          await msg.reply({          await msg.reply({
181              embeds: [              embeds: [
# Line 79  export default class ProfileCommand exte Line 185  export default class ProfileCommand exte
185                      name: user?.user.tag!,                      name: user?.user.tag!,
186                      iconURL: user!.user.displayAvatarURL()                      iconURL: user!.user.displayAvatarURL()
187                  })                  })
188                  .setImage(user!.displayAvatarURL({                  .setThumbnail(user!.displayAvatarURL({
                     size: 4096  
                 }))  
                 .setURL(user!.displayAvatarURL({  
189                      size: 4096                      size: 4096
190                  }))                  }))
191                  .setFields([                  .setFields(fields)
192                      {                  .setFooter({
193                          name: "ID",                      text: `${user!.id} - ${user?.user.bot ? 'Bot' : 'User'}`
194                          value: `${user!.id}`                  })
                     },  
                     {  
                         name: "Nickname",  
                         value: `${user!.nickname?.replace(/\*\<\>\@\_\~\|/g, '') ?? '*Nickname not set*'}`  
                     },  
                     {  
                         name: "Account Created",  
                         value: `${user!.user.createdAt.toLocaleDateString('en-US')} (${timeSince(user!.user.createdTimestamp)})`  
                     },  
                     {  
                         name: "Joined at",  
                         value: `${user!.joinedAt!.toLocaleDateString('en-US')} (${timeSince(user!.joinedTimestamp!)})`  
                     },  
                     {  
                         name: 'Active Devices',  
                         value: `${statusText === '' ? 'Offline/Invisible' : statusText}`  
                     },  
                     {  
                         name: 'Custom Status',  
                         value: `${state ?? '*No custom status set*'}`  
                     },  
                     {  
                         name: 'Roles',  
                         value: user?.roles.cache.filter(role => role.id !== msg.guild!.id).sort((role1, role2) => {  
                             return role2.position - role1.position;  
                         }).reduce((acc, value) => `${acc} ${roleMention(value.id)}`, '')!.trim()!  
                     }  
                 ])  
195              ]              ]
196          });          });
197      }      }

Legend:
Removed from v.263  
changed lines
  Added in v.264

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26