1 |
|
/** |
2 |
|
* This file is part of SudoBot. |
3 |
|
* |
4 |
|
* Copyright (C) 2021-2022 OSN Inc. |
5 |
|
* |
6 |
|
* SudoBot is free software; you can redistribute it and/or modify it |
7 |
|
* under the terms of the GNU Affero General Public License as published by |
8 |
|
* the Free Software Foundation, either version 3 of the License, or |
9 |
|
* (at your option) any later version. |
10 |
|
* |
11 |
|
* SudoBot is distributed in the hope that it will be useful, but |
12 |
|
* WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
* GNU Affero General Public License for more details. |
15 |
|
* |
16 |
|
* You should have received a copy of the GNU Affero General Public License |
17 |
|
* along with SudoBot. If not, see <https://www.gnu.org/licenses/>. |
18 |
|
*/ |
19 |
|
|
20 |
import { formatDistanceStrict, formatDistanceToNowStrict } from "date-fns"; |
import { formatDistanceStrict, formatDistanceToNowStrict } from "date-fns"; |
21 |
import { APIEmbedField } from "discord-api-types/v9"; |
import { APIEmbedField } from "discord-api-types/v9"; |
22 |
import { Util, Message, Interaction, CacheType, CommandInteraction } from "discord.js"; |
import { Util, Message, CacheType, CommandInteraction } from "discord.js"; |
23 |
import Client from "../../client/Client"; |
import Client from "../../client/Client"; |
24 |
import MessageEmbed from "../../client/MessageEmbed"; |
import MessageEmbed from "../../client/MessageEmbed"; |
25 |
import CommandOptions from "../../types/CommandOptions"; |
import CommandOptions from "../../types/CommandOptions"; |
26 |
import InteractionOptions from "../../types/InteractionOptions"; |
import InteractionOptions from "../../types/InteractionOptions"; |
27 |
import { emoji } from "../../utils/Emoji"; |
import { emoji } from "../../utils/Emoji"; |
28 |
import getUser from "../../utils/getUser"; |
import getUser from "../../utils/getUser"; |
|
import { parseUser } from "../../utils/parseInput"; |
|
29 |
import BaseCommand from "../../utils/structures/BaseCommand"; |
import BaseCommand from "../../utils/structures/BaseCommand"; |
30 |
|
import { getUserBadges } from "./ProfileCommand"; |
31 |
|
|
32 |
export default class UserLookupCommand extends BaseCommand { |
export default class UserLookupCommand extends BaseCommand { |
33 |
supportsInteractions: boolean = true; |
supportsInteractions: boolean = true; |
72 |
} |
} |
73 |
}); |
}); |
74 |
|
|
75 |
|
|
76 |
|
if (user.hexAccentColor) { |
77 |
|
embed.setColor(user.hexAccentColor); |
78 |
|
} |
79 |
|
|
80 |
const fieldsCommon: APIEmbedField[] = [ |
const fieldsCommon: APIEmbedField[] = [ |
81 |
|
|
82 |
]; |
]; |
85 |
{ |
{ |
86 |
name: "Server Member?", |
name: "Server Member?", |
87 |
value: member ? "Yes" : "No", |
value: member ? "Yes" : "No", |
88 |
|
inline: true |
89 |
|
}, |
90 |
|
{ |
91 |
|
name: "Bot?", |
92 |
|
value: user.bot ? "Yes" : "No", |
93 |
|
inline: true |
94 |
}, |
}, |
95 |
{ |
{ |
96 |
name: "Account created", |
name: "Account created", |
97 |
value: formatDistanceToNowStrict(user.createdAt, { addSuffix: true }), |
value: user.createdAt.toLocaleString() + " (" + formatDistanceToNowStrict(user.createdAt, { addSuffix: true }) + ")", |
98 |
inline: true |
inline: true |
99 |
} |
} |
100 |
]; |
]; |
101 |
|
|
102 |
|
embed.setThumbnail(user.displayAvatarURL()); |
103 |
|
|
104 |
if (member) { |
if (member) { |
105 |
fields.push({ |
fields.push({ |
106 |
name: "Joined Server", |
name: "Joined Server", |
107 |
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", |
108 |
inline: true |
inline: true |
109 |
}); |
}); |
110 |
|
|
111 |
if (member.premiumSince) { |
if (member.premiumSince) { |
112 |
fields.push({ |
fields.push({ |
113 |
name: "Boosted Server", |
name: "Boosted Server", |
114 |
value: formatDistanceToNowStrict(member.premiumSince, { addSuffix: true }), |
value: member.premiumSince.toLocaleString() + " (" + formatDistanceToNowStrict(member.premiumSince, { addSuffix: true }) + ")", |
115 |
inline: true |
inline: true |
116 |
}); |
}); |
117 |
} |
} |
119 |
if (member.communicationDisabledUntil) { |
if (member.communicationDisabledUntil) { |
120 |
fields.push({ |
fields.push({ |
121 |
name: "Timed-out Until", |
name: "Timed-out Until", |
122 |
value: formatDistanceStrict(member.communicationDisabledUntil, new Date()), |
value: member.communicationDisabledUntil.toLocaleString() + " (" + formatDistanceStrict(member.communicationDisabledUntil, new Date()) + ")", |
123 |
inline: true |
inline: true |
124 |
}); |
}); |
125 |
} |
} |
126 |
|
|
127 |
if (member.displayAvatarURL() != user.displayAvatarURL()) { |
if (member.displayAvatarURL()) { |
128 |
embed.setThumbnail(member.displayAvatarURL()); |
embed.setThumbnail(member.displayAvatarURL()); |
129 |
} |
} |
130 |
|
|
131 |
|
if (member.nickname) { |
132 |
|
fields.push({ |
133 |
|
name: "Nickname", |
134 |
|
value: Util.escapeMarkdown(member.nickname) |
135 |
|
}); |
136 |
|
} |
137 |
|
|
138 |
|
if (member.displayHexColor) { |
139 |
|
fields.push({ |
140 |
|
name: "Guild Profile Theme Color", |
141 |
|
value: member.displayHexColor |
142 |
|
}); |
143 |
|
} |
144 |
|
|
145 |
|
if (member.displayHexColor && !user.hexAccentColor) { |
146 |
|
embed.setColor(member.displayHexColor); |
147 |
|
} |
148 |
|
|
149 |
|
if (member.voice && member.voice.channel) { |
150 |
|
fields.push({ |
151 |
|
name: "Current Voice Channel", |
152 |
|
value: member.voice.channel.toString() |
153 |
|
}); |
154 |
|
} |
155 |
|
|
156 |
|
fields.push({ |
157 |
|
name: "Completed Membership Screening", |
158 |
|
value: member.pending ? "No" : "Yes" |
159 |
|
}); |
160 |
|
|
161 |
|
fields.push({ |
162 |
|
name: "Mention", |
163 |
|
value: member.toString() |
164 |
|
}); |
165 |
|
|
166 |
|
if (member.roles.highest.id !== member.guild.id) { |
167 |
|
fields.push({ |
168 |
|
name: "Highest Role", |
169 |
|
value: member.roles.highest.toString() |
170 |
|
}); |
171 |
|
} |
172 |
} |
} |
173 |
|
|
174 |
|
const badges = getUserBadges(user).join('\n'); |
175 |
|
|
176 |
|
fields.push({ |
177 |
|
name: "Badges", |
178 |
|
value: badges.trim() === '' ? '*No badges found*' : badges |
179 |
|
}); |
180 |
|
|
181 |
fields = [...fields, ...fieldsCommon]; |
fields = [...fields, ...fieldsCommon]; |
182 |
embed.setFields(fields); |
embed.setFields(fields); |
183 |
|
embed.setTimestamp(); |
184 |
|
|
185 |
await message.reply({ |
await message.reply({ |
186 |
embeds: [ |
embeds: [ |