aboutsummaryrefslogtreecommitdiff
path: root/src/commands/info
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/info')
-rw-r--r--src/commands/info/avatar.ts6
-rw-r--r--src/commands/info/botInfo.ts4
-rw-r--r--src/commands/info/color.ts6
-rw-r--r--src/commands/info/guildInfo.ts88
-rw-r--r--src/commands/info/help.ts46
-rw-r--r--src/commands/info/icon.ts5
-rw-r--r--src/commands/info/links.ts31
-rw-r--r--src/commands/info/ping.ts8
-rw-r--r--src/commands/info/pronouns.ts6
-rw-r--r--src/commands/info/snowflake.ts60
-rw-r--r--src/commands/info/userInfo.ts30
11 files changed, 136 insertions, 154 deletions
diff --git a/src/commands/info/avatar.ts b/src/commands/info/avatar.ts
index ce2543f..58d8bca 100644
--- a/src/commands/info/avatar.ts
+++ b/src/commands/info/avatar.ts
@@ -1,5 +1,5 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
-import { GuildMember, MessageEmbed } from 'discord.js';
+import { ApplicationCommandOptionType, GuildMember, MessageEmbed, Permissions } from 'discord.js';
export default class AvatarCommand extends BushCommand {
constructor() {
@@ -18,10 +18,10 @@ export default class AvatarCommand extends BushCommand {
prompt: 'Who would you like to see the avatar of?',
retry: '{error} Choose a valid user.',
optional: true,
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
}
],
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: [],
slash: true
});
diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts
index fa572e8..3aea3cd 100644
--- a/src/commands/info/botInfo.ts
+++ b/src/commands/info/botInfo.ts
@@ -1,6 +1,6 @@
import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
-import { MessageEmbed, version as discordJSVersion } from 'discord.js';
+import { MessageEmbed, Permissions, version as discordJSVersion } from 'discord.js';
import * as os from 'os';
const { default: prettyBytes } = await import('pretty-bytes');
assert(prettyBytes);
@@ -15,7 +15,7 @@ export default class BotInfoCommand extends BushCommand {
usage: ['bot-info'],
examples: ['bot-info'],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
diff --git a/src/commands/info/color.ts b/src/commands/info/color.ts
index 5b2c818..d385c53 100644
--- a/src/commands/info/color.ts
+++ b/src/commands/info/color.ts
@@ -9,7 +9,7 @@ import {
type BushSlashMessage
} from '#lib';
import assert from 'assert';
-import { MessageEmbed, Role } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed, Permissions, Role } from 'discord.js';
import tinycolor from 'tinycolor2';
assert(tinycolor);
@@ -36,11 +36,11 @@ export default class ColorCommand extends BushCommand {
match: 'restContent',
prompt: 'What color code, role, or user would you like to find the color of?',
retry: '{error} Choose a valid color, role, or member.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts
index 7d3d170..afc5111 100644
--- a/src/commands/info/guildInfo.ts
+++ b/src/commands/info/guildInfo.ts
@@ -1,9 +1,14 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptionalArgType } from '#lib';
import assert from 'assert';
+import { GuildDefaultMessageNotifications, GuildExplicitContentFilter } from 'discord-api-types';
import {
- Constants,
+ ApplicationCommandOptionType,
Guild,
+ GuildMFALevel,
+ GuildPremiumTier,
+ GuildVerificationLevel,
MessageEmbed,
+ Permissions,
type BaseGuildVoiceChannel,
type GuildPreview,
type Snowflake,
@@ -27,11 +32,11 @@ export default class GuildInfoCommand extends BushCommand {
prompt: 'What server would you like to find information about?',
retry: '{error} Choose a valid server to find information about.',
optional: true,
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
@@ -66,20 +71,20 @@ export default class GuildInfoCommand extends BushCommand {
const guildStats: string[] = [];
const guildSecurity: string[] = [];
const verifiedGuilds = Object.values(client.consts.mappings.guilds);
- if (verifiedGuilds.includes(guild.id as typeof verifiedGuilds[number])) emojis.push(otherEmojis.BUSH_VERIFIED);
+ if (verifiedGuilds.includes(guild.id as typeof verifiedGuilds[number])) emojis.push(otherEmojis.BushVerified);
if (!isPreview && guild instanceof Guild) {
- if (guild.premiumTier !== 'NONE') emojis.push(otherEmojis[`BOOST_${guild.premiumTier}`]);
+ if (guild.premiumTier !== 'None') emojis.push(otherEmojis[`Boost${guild.premiumTier}`]);
await guild.fetch();
const channels = guild.channels.cache;
- const channelTypes = (
- ['GUILD_TEXT', 'GUILD_VOICE', 'GUILD_STAGE_VOICE', 'GUILD_STORE', 'GUILD_CATEGORY', 'THREAD'] as const
- ).map((type) => `${otherEmojis[type]} ${channels.filter((channel) => channel.type.includes(type)).size.toLocaleString()}`);
+ const channelTypes = (['Text', 'Voice', 'News', 'Stage', 'Store', 'Category', 'Thread'] as const).map(
+ (type) => `${otherEmojis[`Channel${type}`]} ${channels.filter((channel) => channel[`is${type}`]()).size.toLocaleString()}`
+ );
const guildRegions = [
...new Set(
- guild.channels.cache.filter((c) => c.isVoice()).map((c) => (c as BaseGuildVoiceChannel).rtcRegion ?? 'automatic')
+ guild.channels.cache.filter((c) => c.isVoiceBased()).map((c) => (c as BaseGuildVoiceChannel).rtcRegion ?? 'automatic')
)
] as RTCRegion[];
@@ -92,48 +97,42 @@ export default class GuildInfoCommand extends BushCommand {
`**Regions:** ${guildRegions.map((region) => client.consts.mappings.regions[region] || region).join(', ')}`
);
if (guild.premiumSubscriptionCount)
- guildAbout.push(
- `**Boosts:** Level ${Constants.PremiumTiers[guild.premiumTier]} with ${guild.premiumSubscriptionCount ?? 0} boosts`
- );
- if (guild.me?.permissions.has('MANAGE_GUILD') && guild.vanityURLCode) {
+ guildAbout.push(`**Boosts:** Level ${guild.premiumTier} with ${guild.premiumSubscriptionCount ?? 0} boosts`);
+ if (guild.me?.permissions.has(Permissions.FLAGS.MANAGE_GUILD) && guild.vanityURLCode) {
const vanityInfo: Vanity = await guild.fetchVanityData();
guildAbout.push(`**Vanity URL:** discord.gg/${vanityInfo.code}`, `**Vanity Uses:** ${vanityInfo.uses?.toLocaleString()}`);
}
- if (guild.icon) guildAbout.push(`**Icon:** [link](${guild.iconURL({ dynamic: true, size: 4096, format: 'png' })})`);
+ if (guild.icon) guildAbout.push(`**Icon:** [link](${guild.iconURL({ size: 4096, format: 'png' })})`);
if (guild.banner) guildAbout.push(`**Banner:** [link](${guild.bannerURL({ size: 4096, format: 'png' })})`);
if (guild.splash) guildAbout.push(`**Splash:** [link](${guild.splashURL({ size: 4096, format: 'png' })})`);
const EmojiTierMap = {
- TIER_3: 500,
- TIER_2: 300,
- TIER_1: 100,
- NONE: 50
+ [GuildPremiumTier.Tier3]: 500,
+ [GuildPremiumTier.Tier2]: 300,
+ [GuildPremiumTier.Tier1]: 100,
+ [GuildPremiumTier.None]: 50
} as const;
const StickerTierMap = {
- TIER_3: 60,
- TIER_2: 30,
- TIER_1: 15,
- NONE: 0
+ [GuildPremiumTier.Tier3]: 60,
+ [GuildPremiumTier.Tier2]: 30,
+ [GuildPremiumTier.Tier1]: 15,
+ [GuildPremiumTier.None]: 0
} as const;
guildStats.push(
`**Channels:** ${guild.channels.cache.size.toLocaleString()} / 500 (${channelTypes.join(', ')})`,
// subtract 1 for @everyone role
`**Roles:** ${((guild.roles.cache.size ?? 0) - 1).toLocaleString()} / 250`,
- `**Emojis:** ${guild.emojis.cache.size?.toLocaleString() ?? 0} / ${EmojiTierMap[guild.premiumTier]}`,
- `**Stickers:** ${guild.stickers.cache.size?.toLocaleString() ?? 0} / ${StickerTierMap[guild.premiumTier]}`
+ `**Emojis:** ${guild.emojis.cache.size?.toLocaleString() ?? 0} / ${(<any>EmojiTierMap)[guild.premiumTier]}`,
+ `**Stickers:** ${guild.stickers.cache.size?.toLocaleString() ?? 0} / ${(<any>StickerTierMap)[guild.premiumTier]}`
);
guildSecurity.push(
- `**Verification Level**: ${guild.verificationLevel.toLowerCase().replace(/_/g, ' ')}`,
- `**Explicit Content Filter:** ${guild.explicitContentFilter.toLowerCase().replace(/_/g, ' ')}`,
- `**Default Message Notifications:** ${
- typeof guild.defaultMessageNotifications === 'string'
- ? guild.defaultMessageNotifications.toLowerCase().replace(/_/g, ' ')
- : guild.defaultMessageNotifications
- }`,
- `**2FA Required**: ${guild.mfaLevel === 'ELEVATED' ? 'yes' : 'no'}`
+ `**Verification Level**: ${(<any>BushGuildVerificationLevel)[guild.verificationLevel]}`,
+ `**Explicit Content Filter:** ${(<any>BushGuildExplicitContentFilter)[guild.explicitContentFilter]}`,
+ `**Default Message Notifications:** ${(<any>BushGuildDefaultMessageNotifications)[guild.defaultMessageNotifications]}`,
+ `**2FA Required**: ${guild.mfaLevel === GuildMFALevel.Elevated ? 'True' : 'False'}`
);
} else {
guildAbout.push(
@@ -142,8 +141,8 @@ export default class GuildInfoCommand extends BushCommand {
}, ${util.emojis.offlineCircle} ${(
(guild.approximateMemberCount ?? 0) - (guild.approximatePresenceCount ?? 0)
).toLocaleString()})`,
- `**Emojis:** ${(guild as GuildPreview).emojis.size?.toLocaleString() ?? 0}`
- // `**Stickers:** ${(guild as GuildPreview).stickers.size}`
+ `**Emojis:** ${(guild as GuildPreview).emojis.size?.toLocaleString() ?? 0}`,
+ `**Stickers:** ${(guild as GuildPreview).stickers.size}`
);
}
@@ -174,7 +173,7 @@ export default class GuildInfoCommand extends BushCommand {
.setColor(util.colors.default)
.addField('» About', guildAbout.join('\n'));
if (guildStats.length) guildInfoEmbed.addField('» Stats', guildStats.join('\n'));
- const guildIcon = guild.iconURL({ size: 2048, format: 'png', dynamic: true });
+ const guildIcon = guild.iconURL({ size: 2048, format: 'png' });
if (guildIcon) {
guildInfoEmbed.setThumbnail(guildIcon);
}
@@ -203,3 +202,22 @@ type RTCRegion =
| 'japan'
| 'india'
| 'automatic';
+
+enum BushGuildVerificationLevel {
+ 'None' = GuildVerificationLevel.None,
+ 'Low' = GuildVerificationLevel.Low,
+ 'Medium' = GuildVerificationLevel.Medium,
+ 'High' = GuildVerificationLevel.High,
+ 'Very High' = GuildVerificationLevel.VeryHigh
+}
+
+enum BushGuildExplicitContentFilter {
+ 'Disabled' = GuildExplicitContentFilter.Disabled,
+ 'Members Without Roles' = GuildExplicitContentFilter.MembersWithoutRoles,
+ 'All Members' = GuildExplicitContentFilter.AllMembers
+}
+
+enum BushGuildDefaultMessageNotifications {
+ 'All Messages' = GuildDefaultMessageNotifications.AllMessages,
+ 'Only Mentions' = GuildDefaultMessageNotifications.OnlyMentions
+}
diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts
index 1ac7b3e..c77b5d2 100644
--- a/src/commands/info/help.ts
+++ b/src/commands/info/help.ts
@@ -1,8 +1,17 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
-import { AutocompleteInteraction, MessageActionRow, MessageButton, MessageEmbed } from 'discord.js';
+import {
+ ActionRow,
+ ApplicationCommandOptionType,
+ AutocompleteInteraction,
+ ButtonComponent,
+ ButtonStyle,
+ MessageEmbed,
+ Permissions
+} from 'discord.js';
import Fuse from 'fuse.js';
import packageDotJSON from '../../../package.json' assert { type: 'json' };
+
assert(Fuse);
assert(packageDotJSON);
@@ -22,7 +31,7 @@ export default class HelpCommand extends BushCommand {
match: 'content',
prompt: 'What command do you need help with?',
retry: '{error} Choose a valid command to find help for.',
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
optional: true,
autocomplete: true
},
@@ -31,14 +40,14 @@ export default class HelpCommand extends BushCommand {
description: 'Whether ot not to show hidden commands as well.',
match: 'flag',
flag: '--hidden',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
ownerOnly: true,
only: 'text',
optional: true
}
],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
@@ -117,40 +126,23 @@ export default class HelpCommand extends BushCommand {
if (restrictions.length) embed.addField('» Restrictions', restrictions.join('\n'));
}
- return await message.util.reply({ embeds: [embed], components: row.components.length ? [row] : undefined });
+ const params = { embeds: [embed], components: row.components.length ? [row] : undefined };
+ return await message.util.reply(params);
}
private addLinks(message: BushMessage | BushSlashMessage) {
- const row = new MessageActionRow();
+ const row = new ActionRow();
if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) {
- row.addComponents(
- new MessageButton({
- style: 'LINK',
- label: 'Invite Me',
- url: `https://discord.com/api/oauth2/authorize?client_id=${
- client.user!.id
- }&permissions=5368709119918&scope=bot%20applications.commands`
- })
- );
+ row.addComponents(new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Invite Me').setURL(util.invite));
}
if (!client.guilds.cache.get(client.config.supportGuild.id)?.members.cache.has(message.author.id)) {
row.addComponents(
- new MessageButton({
- style: 'LINK',
- label: 'Support Server',
- url: client.config.supportGuild.invite
- })
+ new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Support Server').setURL(client.config.supportGuild.invite)
);
}
if (packageDotJSON?.repository)
- row.addComponents(
- new MessageButton({
- style: 'LINK',
- label: 'GitHub',
- url: packageDotJSON.repository
- })
- );
+ row.addComponents(new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('GitHub').setURL(packageDotJSON.repository));
else void message.channel?.send('Error importing package.json, please report this to my developer.');
return row;
diff --git a/src/commands/info/icon.ts b/src/commands/info/icon.ts
index 42b7fa4..9602d40 100644
--- a/src/commands/info/icon.ts
+++ b/src/commands/info/icon.ts
@@ -1,5 +1,5 @@
import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
-import { MessageEmbed } from 'discord.js';
+import { MessageEmbed, Permissions } from 'discord.js';
export default class IconCommand extends BushCommand {
constructor() {
@@ -9,7 +9,7 @@ export default class IconCommand extends BushCommand {
description: "A command to get the server's icon",
usage: ['icon'],
examples: ['icon'],
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: [],
channel: 'guild',
slash: true
@@ -23,7 +23,6 @@ export default class IconCommand extends BushCommand {
.setImage(
message.guild!.iconURL({
size: 2048,
- dynamic: true,
format: 'png'
})!
)
diff --git a/src/commands/info/links.ts b/src/commands/info/links.ts
index b0d2007..25b040c 100644
--- a/src/commands/info/links.ts
+++ b/src/commands/info/links.ts
@@ -1,7 +1,8 @@
import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
import { assert } from 'console';
-import { MessageActionRow, MessageButton } from 'discord.js';
+import { ActionRow, ButtonComponent, ButtonStyle } from 'discord.js';
import packageDotJSON from '../../../package.json' assert { type: 'json' };
+
assert(packageDotJSON);
export default class LinksCommand extends BushCommand {
@@ -19,26 +20,14 @@ export default class LinksCommand extends BushCommand {
}
public override async exec(message: BushMessage | BushSlashMessage) {
- if (client.config.isDevelopment) return await message.util.reply(`${util.emojis.error} The dev bot cannot be invited.`);
- const ButtonRow = new MessageActionRow().addComponents(
- new MessageButton({
- style: 'LINK',
- label: 'Invite Me',
- url: `https://discord.com/api/oauth2/authorize?client_id=${
- client.user!.id
- }&permissions=5368709119918&scope=bot%20applications.commands`
- }),
- new MessageButton({
- style: 'LINK',
- label: 'Support Server',
- url: client.config.supportGuild.invite
- }),
- new MessageButton({
- style: 'LINK',
- label: 'GitHub',
- url: packageDotJSON.repository
- })
+ const buttonRow = new ActionRow();
+ if (!client.config.isDevelopment || message.author.isOwner()) {
+ buttonRow.addComponents(new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Invite Me').setURL(util.invite));
+ }
+ buttonRow.addComponents(
+ new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Support Server').setURL(client.config.supportGuild.invite),
+ new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('GitHub').setURL(packageDotJSON.repository)
);
- return await message.util.reply({ content: '\u200B', components: [ButtonRow] });
+ return await message.util.reply({ content: 'Here are some useful links:', components: [buttonRow] });
}
}
diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts
index a156368..1a8f542 100644
--- a/src/commands/info/ping.ts
+++ b/src/commands/info/ping.ts
@@ -1,5 +1,5 @@
import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
-import { MessageEmbed, type Message } from 'discord.js';
+import { MessageEmbed, Permissions, type Message } from 'discord.js';
export default class PingCommand extends BushCommand {
public constructor() {
@@ -10,7 +10,7 @@ export default class PingCommand extends BushCommand {
usage: ['ping'],
examples: ['ping'],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
@@ -24,7 +24,7 @@ export default class PingCommand extends BushCommand {
.setTitle('Pong! 🏓')
.addField('Bot Latency', botLatency, true)
.addField('API Latency', apiLatency, true)
- .setFooter({ text: message.author.username, iconURL: message.author.displayAvatarURL({ dynamic: true }) })
+ .setFooter({ text: message.author.username, iconURL: message.author.displayAvatarURL() })
.setColor(util.colors.default)
.setTimestamp();
await sentMessage.edit({
@@ -45,7 +45,7 @@ export default class PingCommand extends BushCommand {
.addField('API Latency', apiLatency, true)
.setFooter({
text: message.interaction.user.username,
- iconURL: message.interaction.user.displayAvatarURL({ dynamic: true })
+ iconURL: message.interaction.user.displayAvatarURL()
})
.setColor(util.colors.default)
.setTimestamp();
diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts
index 9b9f870..e390865 100644
--- a/src/commands/info/pronouns.ts
+++ b/src/commands/info/pronouns.ts
@@ -1,5 +1,5 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
-import { MessageEmbed } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed, Permissions } from 'discord.js';
export default class PronounsCommand extends BushCommand {
public constructor() {
@@ -17,10 +17,10 @@ export default class PronounsCommand extends BushCommand {
prompt: 'Who would you like to view the pronouns of?',
retry: '{error} Choose a valid user to view the pronouns of.',
optional: true,
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
}
],
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: [],
slash: true
});
diff --git a/src/commands/info/snowflake.ts b/src/commands/info/snowflake.ts
index 1a41257..d9ad108 100644
--- a/src/commands/info/snowflake.ts
+++ b/src/commands/info/snowflake.ts
@@ -1,18 +1,14 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import {
+ ApplicationCommandOptionType,
MessageEmbed,
+ Permissions,
SnowflakeUtil,
- type CategoryChannel,
type DeconstructedSnowflake,
- type DMChannel,
type Guild,
- type NewsChannel,
type Role,
type Snowflake,
- type StageChannel,
- type TextChannel,
- type User,
- type VoiceChannel
+ type User
} from 'discord.js';
export default class SnowflakeCommand extends BushCommand {
@@ -30,11 +26,10 @@ export default class SnowflakeCommand extends BushCommand {
type: 'snowflake',
prompt: 'What snowflake would you like to get information about?',
retry: '{error} Choose a valid snowflake.',
- optional: false,
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: [],
slash: true
});
@@ -46,35 +41,25 @@ export default class SnowflakeCommand extends BushCommand {
// Channel
if (client.channels.cache.has(snowflake)) {
- const channel = client.channels.cache.get(snowflake)!;
+ const channel = client.channels.resolve(snowflake)!;
const channelInfo = [`**Type:** ${channel.type}`];
- if (['DM', 'GROUP_DM'].includes(channel.type)) {
- const _channel = channel as DMChannel;
- channelInfo.push(`**Recipient:** ${util.discord.escapeMarkdown(_channel.recipient.tag)} (${_channel.recipient.id})`);
- snowflakeEmbed.setTitle(
- `:snowflake: DM with ${util.discord.escapeMarkdown((channel as DMChannel).recipient.tag)} \`[Channel]\``
- );
+ if (channel.isDM()) {
+ channelInfo.push(`**Recipient:** ${util.discord.escapeMarkdown(channel.recipient.tag)} (${channel.recipient.id})`);
+ snowflakeEmbed.setTitle(`:snowflake: DM with ${util.discord.escapeMarkdown(channel.recipient.tag)} \`[Channel]\``);
} else if (
- (
- [
- 'GUILD_CATEGORY',
- 'GUILD_NEWS',
- 'GUILD_TEXT',
- 'GUILD_VOICE',
- 'GUILD_STORE',
- 'GUILD_STAGE_VOICE',
- 'GUILD_NEWS_THREAD',
- 'GUILD_PUBLIC_THREAD',
- 'GUILD_PRIVATE_THREAD'
- ] as const
- ).includes(channel.type)
+ channel.isCategory() ||
+ channel.isNews() ||
+ channel.isText() ||
+ channel.isVoice() ||
+ channel.isStore() ||
+ channel.isStage() ||
+ channel.isThread()
) {
- const _channel = channel as TextChannel | VoiceChannel | NewsChannel | StageChannel | CategoryChannel | StageChannel;
channelInfo.push(
- `**Channel Name:** <#${_channel.id}> (${util.discord.escapeMarkdown(_channel.name)})`,
- `**Channel's Server:** ${util.discord.escapeMarkdown(_channel.guild.name)} (${_channel.guild.id})`
+ `**Channel Name:** <#${channel.id}> (${util.discord.escapeMarkdown(channel.name)})`,
+ `**Channel's Server:** ${util.discord.escapeMarkdown(channel.guild.name)} (${channel.guild.id})`
);
- snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(_channel.name)} \`[Channel]\``);
+ snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(channel.name)} \`[Channel]\``);
}
snowflakeEmbed.addField('» Channel Info', channelInfo.join('\n'));
}
@@ -89,7 +74,7 @@ export default class SnowflakeCommand extends BushCommand {
})`,
`**Members:** ${guild.memberCount?.toLocaleString()}`
];
- if (guild.icon) snowflakeEmbed.setThumbnail(guild.iconURL({ size: 2048, dynamic: true })!);
+ if (guild.icon) snowflakeEmbed.setThumbnail(guild.iconURL({ size: 2048 })!);
snowflakeEmbed.addField('» Server Info', guildInfo.join('\n'));
snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(guild.name)} \`[Server]\``);
}
@@ -99,7 +84,7 @@ export default class SnowflakeCommand extends BushCommand {
if (client.users.cache.has(snowflake) || fetchedUser) {
const user: User = (client.users.cache.get(snowflake) ?? fetchedUser)!;
const userInfo = [`**Name:** <@${user.id}> (${util.discord.escapeMarkdown(user.tag)})`];
- if (user.avatar) snowflakeEmbed.setThumbnail(user.avatarURL({ size: 2048, dynamic: true })!);
+ if (user.avatar) snowflakeEmbed.setThumbnail(user.avatarURL({ size: 2048 })!);
snowflakeEmbed.addField('» User Info', userInfo.join('\n'));
snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(user.tag)} \`[User]\``);
}
@@ -136,11 +121,10 @@ export default class SnowflakeCommand extends BushCommand {
const deconstructedSnowflake: DeconstructedSnowflake = SnowflakeUtil.deconstruct(snowflake);
const snowflakeInfo = [
`**Timestamp:** ${deconstructedSnowflake.timestamp}`,
- `**Created:** ${util.timestamp(deconstructedSnowflake.date)}`,
+ `**Created:** ${util.timestamp(new Date(Number(deconstructedSnowflake.timestamp)))}`,
`**Worker ID:** ${deconstructedSnowflake.workerId}`,
`**Process ID:** ${deconstructedSnowflake.processId}`,
`**Increment:** ${deconstructedSnowflake.increment}`
- // `**Binary:** ${deconstructedSnowflake.binary}`
];
snowflakeEmbed.addField('» Snowflake Info', snowflakeInfo.join('\n'));
diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts
index 609bd94..38c9ea6 100644
--- a/src/commands/info/userInfo.ts
+++ b/src/commands/info/userInfo.ts
@@ -7,7 +7,7 @@ import {
type BushSlashMessage,
type BushUser
} from '#lib';
-import { MessageEmbed } from 'discord.js';
+import { ActivityType, ApplicationCommandOptionType, MessageEmbed, Permissions, UserFlags } from 'discord.js';
// TODO: Add bot information
export default class UserInfoCommand extends BushCommand {
@@ -27,11 +27,11 @@ export default class UserInfoCommand extends BushCommand {
prompt: 'What user would you like to find information about?',
retry: '{error} Choose a valid user to find information about.',
optional: true,
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
}
],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
@@ -58,12 +58,12 @@ export default class UserInfoCommand extends BushCommand {
const userEmbed: MessageEmbed = new MessageEmbed()
.setTitle(util.discord.escapeMarkdown(user.tag))
- .setThumbnail(user.displayAvatarURL({ size: 2048, format: 'png', dynamic: true }))
+ .setThumbnail(user.displayAvatarURL({ size: 2048, format: 'png' }))
.setTimestamp();
// Flags
- if (client.config.owners.includes(user.id)) emojis.push(client.consts.mappings.otherEmojis.DEVELOPER);
- if (superUsers.includes(user.id)) emojis.push(client.consts.mappings.otherEmojis.SUPERUSER);
+ if (client.config.owners.includes(user.id)) emojis.push(client.consts.mappings.otherEmojis.Developer);
+ if (superUsers.includes(user.id)) emojis.push(client.consts.mappings.otherEmojis.Superuser);
const flags = user.flags?.toArray();
if (flags) {
flags.forEach((f) => {
@@ -77,15 +77,15 @@ export default class UserInfoCommand extends BushCommand {
if (
Number(user.discriminator) < 10 ||
client.consts.mappings.maybeNitroDiscrims.includes(user.discriminator) ||
- user.displayAvatarURL({ dynamic: true })?.endsWith('.gif') ||
- user.flags?.toArray().includes('PARTNERED_SERVER_OWNER')
+ user.displayAvatarURL()?.endsWith('.gif') ||
+ user.flags?.has(UserFlags.FLAGS.PARTNER)
) {
- emojis.push(client.consts.mappings.otherEmojis.NITRO);
+ emojis.push(client.consts.mappings.otherEmojis.Nitro);
}
- if (guild?.ownerId == user.id) emojis.push(client.consts.mappings.otherEmojis.OWNER);
- else if (member?.permissions.has('ADMINISTRATOR')) emojis.push(client.consts.mappings.otherEmojis.ADMIN);
- if (member?.premiumSinceTimestamp) emojis.push(client.consts.mappings.otherEmojis.BOOSTER);
+ if (guild?.ownerId == user.id) emojis.push(client.consts.mappings.otherEmojis.Owner);
+ else if (member?.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) emojis.push(client.consts.mappings.otherEmojis.Admin);
+ if (member?.premiumSinceTimestamp) emojis.push(client.consts.mappings.otherEmojis.Booster);
const createdAt = util.timestamp(user.createdAt),
createdAtDelta = util.dateDelta(user.createdAt),
@@ -97,7 +97,7 @@ export default class UserInfoCommand extends BushCommand {
// General Info
const generalInfo = [`**Mention:** <@${user.id}>`, `**ID:** ${user.id}`, `**Created:** ${createdAt} (${createdAtDelta} ago)`];
if (user.accentColor !== null) generalInfo.push(`**Accent Color:** ${user.hexAccentColor}`);
- if (user.banner) generalInfo.push(`**Banner:** [link](${user.bannerURL({ dynamic: true, format: 'png', size: 4096 })})`);
+ if (user.banner) generalInfo.push(`**Banner:** [link](${user.bannerURL({ format: 'png', size: 4096 })})`);
const pronouns = await Promise.race([util.getPronounsOf(user), util.sleep(2)]);
if (pronouns && typeof pronouns === 'string') generalInfo.push(`**Pronouns:** ${pronouns}`);
@@ -126,7 +126,7 @@ export default class UserInfoCommand extends BushCommand {
const activitiesNames: string[] = [];
if (member.presence.activities) {
member.presence.activities.forEach((a) => {
- if (a.type == 'CUSTOM' && a.state) {
+ if (a.type == ActivityType.Custom && a.state) {
const emoji = `${a.emoji ? `${a.emoji.toString()} ` : ''}`;
customStatus = `${emoji}${a.state}`;
}
@@ -169,7 +169,7 @@ export default class UserInfoCommand extends BushCommand {
// Important Perms
const perms = [];
- if (member?.permissions.has('ADMINISTRATOR') || guild?.ownerId == user.id) {
+ if (member?.permissions.has(Permissions.FLAGS.ADMINISTRATOR) || guild?.ownerId == user.id) {
perms.push('`Administrator`');
} else if (member?.permissions.toArray().length) {
member.permissions.toArray().forEach((permission) => {