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

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26