aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/config/config.ts2
-rw-r--r--src/commands/info/guildInfo.ts4
-rw-r--r--src/commands/info/userInfo.ts91
-rw-r--r--src/commands/moderation/modlog.ts12
-rw-r--r--src/commands/utilities/suicide.ts2
5 files changed, 86 insertions, 25 deletions
diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts
index 8f2472e..580f8d2 100644
--- a/src/commands/config/config.ts
+++ b/src/commands/config/config.ts
@@ -357,7 +357,7 @@ export default class ConfigCommand extends BushCommand {
new ButtonComponent().setStyle(ButtonStyle.Primary).setCustomId('command_settingsBack').setLabel('Back')
);
settingsEmbed.setDescription(
- `${Formatters.italic(guildSettingsObj[setting].description)}\n\n**Type**: ${guildSettingsObj[setting].type}`
+ `${Formatters.italic(guildSettingsObj[setting].description)}\n\n**Type:** ${guildSettingsObj[setting].type}`
);
settingsEmbed.setFooter({
diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts
index 0aabb70..55fb0b2 100644
--- a/src/commands/info/guildInfo.ts
+++ b/src/commands/info/guildInfo.ts
@@ -129,10 +129,10 @@ export default class GuildInfoCommand extends BushCommand {
);
guildSecurity.push(
- `**Verification Level**: ${BushGuildVerificationLevel[guild.verificationLevel]}`,
+ `**Verification Level:** ${BushGuildVerificationLevel[guild.verificationLevel]}`,
`**Explicit Content Filter:** ${BushGuildExplicitContentFilter[guild.explicitContentFilter]}`,
`**Default Message Notifications:** ${BushGuildDefaultMessageNotifications[guild.defaultMessageNotifications]}`,
- `**2FA Required**: ${guild.mfaLevel === GuildMFALevel.Elevated ? 'True' : 'False'}`
+ `**2FA Required:** ${guild.mfaLevel === GuildMFALevel.Elevated ? 'True' : 'False'}`
);
} else {
guildAbout.push(
diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts
index 50cb1a8..74f8185 100644
--- a/src/commands/info/userInfo.ts
+++ b/src/commands/info/userInfo.ts
@@ -7,7 +7,15 @@ import {
type BushSlashMessage,
type BushUser
} from '#lib';
-import { ActivityType, ApplicationCommandOptionType, Embed, PermissionFlagsBits, UserFlags } from 'discord.js';
+import { APIApplication, TeamMemberMembershipState } from 'discord-api-types';
+import {
+ ActivityType,
+ ApplicationCommandOptionType,
+ ApplicationFlagsBitField,
+ Embed,
+ PermissionFlagsBits,
+ UserFlags
+} from 'discord.js';
export default class UserInfoCommand extends BushCommand {
public constructor() {
@@ -43,7 +51,7 @@ export default class UserInfoCommand extends BushCommand {
? args.user
: await client.users.fetch(`${args.user}`).catch(() => undefined);
if (user === undefined) return message.util.reply(`${util.emojis.error} Invalid user.`);
- const member = message.guild ? message.guild.members.cache.get(user.id) : undefined;
+ const member = message.guild ? await message.guild.members.fetch(user.id).catch(() => undefined) : undefined;
await user.fetch(true); // gets banner info and accent color
const userEmbed = await UserInfoCommand.makeUserInfoEmbed(user, member, message.guild);
@@ -100,12 +108,17 @@ export default class UserInfoCommand extends BushCommand {
this.generatePermissionsField(userEmbed, member);
- if (emojis) userEmbed.setDescription(`\u200B${emojis.filter((e) => e).join(' ')}`); // zero width space
+ await this.generateBotField(userEmbed, user);
+
+ if (emojis)
+ userEmbed.setDescription(
+ `\u200B${emojis.filter((e) => e).join(' ')}${userEmbed.description?.length ? `\n\n${userEmbed.description}` : ''}`
+ ); // zero width space
return userEmbed;
}
private static async generateGeneralInfoField(embed: Embed, user: BushUser) {
- const createdAt = util.timestamp(user.createdAt),
+ const createdAt = util.timestamp(user.createdAt, 'd'),
createdAtDelta = util.dateDelta(user.createdAt);
// General Info
@@ -115,7 +128,7 @@ export default class UserInfoCommand extends BushCommand {
const pronouns = await Promise.race([util.getPronounsOf(user), util.sleep(2)]); // cut off request after 2 seconds
- if (pronouns && typeof pronouns === 'string') generalInfo.push(`**Pronouns:** ${pronouns}`);
+ if (pronouns && typeof pronouns === 'string' && pronouns !== 'Unspecified') generalInfo.push(`**Pronouns:** ${pronouns}`);
embed.addField({ name: '» General Info', value: generalInfo.join('\n') });
}
@@ -123,9 +136,9 @@ export default class UserInfoCommand extends BushCommand {
private static generateServerInfoField(embed: Embed, member?: BushGuildMember | undefined) {
if (!member) return;
- const joinedAt = util.timestamp(member?.joinedAt),
+ const joinedAt = util.timestamp(member?.joinedAt, 'd'),
joinedAtDelta = member.joinedAt ? util.dateDelta(member.joinedAt, 2) : undefined,
- premiumSince = util.timestamp(member?.premiumSince),
+ premiumSince = util.timestamp(member?.premiumSince, 'd'),
premiumSinceDelta = member.premiumSince ? util.dateDelta(member.premiumSince, 2) : undefined;
// Server User Info
@@ -188,16 +201,14 @@ export default class UserInfoCommand extends BushCommand {
}
private static generateRolesField(embed: Embed, member?: BushGuildMember | undefined) {
- if (!member || !(member.roles.cache.size < 1)) return;
+ if (!member || member.roles.cache.size < 1) return;
// roles
- if (member?.roles.cache.size && member?.roles.cache.size - 1) {
- const roles = member?.roles.cache
- .filter((role) => role.name !== '@everyone')
- .sort((role1, role2) => role2.position - role1.position)
- .map((role) => `${role}`);
- embed.addField({ name: `» Role${roles.length - 1 ? 's' : ''} [${roles.length}]`, value: roles.join(', ') });
- }
+ const roles = member.roles.cache
+ .filter((role) => role.name !== '@everyone')
+ .sort((role1, role2) => role2.position - role1.position)
+ .map((role) => `${role}`);
+ embed.addField({ name: `» Role${roles.length - 1 ? 's' : ''} [${roles.length}]`, value: roles.join(', ') });
}
private static generatePermissionsField(embed: Embed, member: BushGuildMember | undefined) {
@@ -217,4 +228,54 @@ export default class UserInfoCommand extends BushCommand {
if (perms.length) embed.addField({ name: '» Important Perms', value: perms.join(' ') });
}
+
+ private static async generateBotField(embed: Embed, user: BushUser) {
+ if (!user.bot) return;
+
+ const applicationInfo = (await client.rest.get(`/applications/${user.id}/rpc`).catch(() => null)) as APIApplication | null;
+ if (!applicationInfo) return;
+
+ const flags = new ApplicationFlagsBitField(applicationInfo.flags);
+
+ const botInfo = [
+ `**Publicity:** ${applicationInfo.bot_public ? 'Public' : 'Private'}`,
+ `**Requires Code Grant:** ${applicationInfo.bot_require_code_grant ? util.emojis.check : util.emojis.cross}`,
+ `**Server Members Intent:** ${
+ flags.has('GatewayGuildMembers')
+ ? util.emojis.check
+ : flags.has('GatewayGuildMembersLimited')
+ ? util.emojis.warn
+ : util.emojis.cross
+ }`,
+ `**Presence Intent:** ${
+ flags.has('GatewayPresence')
+ ? util.emojis.check
+ : flags.has('GatewayPresenceLimited')
+ ? util.emojis.warn
+ : util.emojis.cross
+ }`,
+ `**Message Content Intent:** ${
+ flags.has('GatewayMessageContent')
+ ? util.emojis.check
+ : flags.has('GatewayMessageContentLimited')
+ ? util.emojis.warn
+ : util.emojis.cross
+ }`
+ ];
+
+ if (applicationInfo.owner || applicationInfo.team) {
+ const teamMembers = applicationInfo.owner
+ ? [applicationInfo.owner]
+ : applicationInfo
+ .team!.members.filter((tm) => tm.membership_state === TeamMemberMembershipState.Accepted)
+ .map((tm) => tm.user);
+ botInfo.push(
+ `**Developer${teamMembers.length > 1 ? 's' : ''}:** ${teamMembers
+ .map((m) => `${m.username}#${m.discriminator}`)
+ .join(', ')}`
+ );
+ }
+
+ if (botInfo.length) embed.addField({ name: '» Bot Info', value: botInfo.join('\n') });
+ }
}
diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts
index 6b8ae2d..443ffa3 100644
--- a/src/commands/moderation/modlog.ts
+++ b/src/commands/moderation/modlog.ts
@@ -81,12 +81,12 @@ export default class ModlogCommand extends BushCommand {
public static generateModlogInfo(log: ModLog, showUser: boolean): string {
const trim = (str: string): string => (str.endsWith('\n') ? str.substring(0, str.length - 1).trim() : str.trim());
- const modLog = [`**Case ID**: ${util.discord.escapeMarkdown(log.id)}`, `**Type**: ${log.type.toLowerCase()}`];
- if (showUser) modLog.push(`**User**: <@!${log.user}>`);
- modLog.push(`**Moderator**: <@!${log.moderator}>`);
- if (log.duration) modLog.push(`**Duration**: ${util.humanizeDuration(log.duration)}`);
- modLog.push(`**Reason**: ${trim(log.reason ?? 'No Reason Specified.')}`);
- modLog.push(`**Date**: ${util.timestamp(log.createdAt)}`);
+ const modLog = [`**Case ID:** ${util.discord.escapeMarkdown(log.id)}`, `**Type:** ${log.type.toLowerCase()}`];
+ if (showUser) modLog.push(`**User:** <@!${log.user}>`);
+ modLog.push(`**Moderator:** <@!${log.moderator}>`);
+ if (log.duration) modLog.push(`**Duration:** ${util.humanizeDuration(log.duration)}`);
+ modLog.push(`**Reason:** ${trim(log.reason ?? 'No Reason Specified.')}`);
+ modLog.push(`**Date:** ${util.timestamp(log.createdAt)}`);
if (log.evidence) modLog.push(`**Evidence:** ${trim(log.evidence)}`);
return modLog.join(`\n`);
}
diff --git a/src/commands/utilities/suicide.ts b/src/commands/utilities/suicide.ts
index 293008c..693896d 100644
--- a/src/commands/utilities/suicide.ts
+++ b/src/commands/utilities/suicide.ts
@@ -33,7 +33,7 @@ export default class SuicideCommand extends BushCommand {
'**Text: HOME** to 741741',
'https://suicidepreventionlifeline.org/chat/',
'',
- '**Outside the U.S**: Find a supportive resource on [this Wikipedia list of worldwide crisis hotlines](https://en.wikipedia.org/wiki/List_of_suicide_crisis_lines)'
+ '**Outside the U.S:** Find a supportive resource on [this Wikipedia list of worldwide crisis hotlines](https://en.wikipedia.org/wiki/List_of_suicide_crisis_lines)'
].join('\n')
})
.addField({