From 0e87bbd3940d89defcb04926587b35c8f4d1947f Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Thu, 16 Jun 2022 14:32:18 -0400 Subject: remove util classes, move config out of src --- src/commands/info/snowflake.ts | 49 +++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'src/commands/info/snowflake.ts') diff --git a/src/commands/info/snowflake.ts b/src/commands/info/snowflake.ts index e74756f..a28f4c5 100644 --- a/src/commands/info/snowflake.ts +++ b/src/commands/info/snowflake.ts @@ -1,9 +1,18 @@ -import { BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; +import { + BushCommand, + clientSendAndPermCheck, + colors, + timestamp, + type ArgType, + type CommandMessage, + type SlashMessage +} from '#lib'; import { stripIndent } from '#tags'; import { ApplicationCommandOptionType, ChannelType, EmbedBuilder, + escapeMarkdown, PermissionFlagsBits, SnowflakeUtil, type DeconstructedSnowflake, @@ -31,7 +40,7 @@ export default class SnowflakeCommand extends BushCommand { slashType: ApplicationCommandOptionType.String } ], - clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [], slash: true }); @@ -39,7 +48,7 @@ export default class SnowflakeCommand extends BushCommand { public override async exec(message: CommandMessage | SlashMessage, args: { snowflake: ArgType<'snowflake'> }) { const snowflake = `${args.snowflake}` as Snowflake; - const snowflakeEmbed = new EmbedBuilder().setTitle('Unknown :snowflake:').setColor(util.colors.default); + const snowflakeEmbed = new EmbedBuilder().setTitle('Unknown :snowflake:').setColor(colors.default); // Channel if (client.channels.cache.has(snowflake)) { @@ -47,13 +56,9 @@ export default class SnowflakeCommand extends BushCommand { const channelInfo = [`**Type:** ${BushChannelType[channel.type] ?? ChannelType[channel.type]}`]; if (channel.type === ChannelType.DM) { channelInfo.push( - `**Recipient:** ${util.discord.escapeMarkdown(channel.recipient?.tag ?? '¯\\_(ツ)_/¯')} (${ - channel.recipient?.id ?? '¯\\_(ツ)_/¯' - })` - ); - snowflakeEmbed.setTitle( - `:snowflake: DM with ${util.discord.escapeMarkdown(channel.recipient?.tag ?? '¯\\_(ツ)_/¯')} \`[Channel]\`` + `**Recipient:** ${escapeMarkdown(channel.recipient?.tag ?? '¯\\_(ツ)_/¯')} (${channel.recipient?.id ?? '¯\\_(ツ)_/¯'})` ); + snowflakeEmbed.setTitle(`:snowflake: DM with ${escapeMarkdown(channel.recipient?.tag ?? '¯\\_(ツ)_/¯')} \`[Channel]\``); } else if ( channel.type === ChannelType.GuildCategory || channel.type === ChannelType.GuildNews || @@ -63,10 +68,10 @@ export default class SnowflakeCommand extends BushCommand { channel.isThread() ) { 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}> (${escapeMarkdown(channel.name)})`, + `**Channel's Server:** ${escapeMarkdown(channel.guild.name)} (${channel.guild.id})` ); - snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(channel.name)} \`[Channel]\``); + snowflakeEmbed.setTitle(`:snowflake: ${escapeMarkdown(channel.name)} \`[Channel]\``); } snowflakeEmbed.addFields([{ name: '» Channel Info', value: channelInfo.join('\n') }]); } @@ -75,12 +80,12 @@ export default class SnowflakeCommand extends BushCommand { if (client.guilds.cache.has(snowflake)) { const guild: Guild = client.guilds.cache.get(snowflake)!; const guildInfo = stripIndent` - **Name:** ${util.discord.escapeMarkdown(guild.name)} - **Owner:** ${util.discord.escapeMarkdown(client.users.cache.get(guild.ownerId)?.tag ?? '¯\\_(ツ)_/¯')} (${guild.ownerId}) + **Name:** ${escapeMarkdown(guild.name)} + **Owner:** ${escapeMarkdown(client.users.cache.get(guild.ownerId)?.tag ?? '¯\\_(ツ)_/¯')} (${guild.ownerId}) **Members:** ${guild.memberCount?.toLocaleString()}`; if (guild.icon) snowflakeEmbed.setThumbnail(guild.iconURL({ size: 2048 })!); snowflakeEmbed.addFields([{ name: '» Server Info', value: guildInfo }]); - snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(guild.name)} \`[Server]\``); + snowflakeEmbed.setTitle(`:snowflake: ${escapeMarkdown(guild.name)} \`[Server]\``); } // User @@ -88,28 +93,28 @@ export default class SnowflakeCommand extends BushCommand { if (client.users.cache.has(snowflake) || fetchedUser) { const user: User = (client.users.cache.get(snowflake) ?? fetchedUser)!; const userInfo = stripIndent` - **Name:** <@${user.id}> (${util.discord.escapeMarkdown(user.tag)})`; + **Name:** <@${user.id}> (${escapeMarkdown(user.tag)})`; if (user.avatar) snowflakeEmbed.setThumbnail(user.avatarURL({ size: 2048 })!); snowflakeEmbed.addFields([{ name: '» User Info', value: userInfo }]); - snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(user.tag)} \`[User]\``); + snowflakeEmbed.setTitle(`:snowflake: ${escapeMarkdown(user.tag)} \`[User]\``); } // Emoji if (client.emojis.cache.has(snowflake)) { const emoji = client.emojis.cache.get(snowflake)!; const emojiInfo = stripIndent` - **Name:** ${util.discord.escapeMarkdown(emoji.name ?? '¯\\_(ツ)_/¯')} + **Name:** ${escapeMarkdown(emoji.name ?? '¯\\_(ツ)_/¯')} **Animated:** ${emoji.animated}`; if (emoji.url) snowflakeEmbed.setThumbnail(emoji.url); snowflakeEmbed.addFields([{ name: '» Emoji Info', value: emojiInfo }]); - snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(emoji.name ?? '¯\\_(ツ)_/¯')} \`[Emoji]\``); + snowflakeEmbed.setTitle(`:snowflake: ${escapeMarkdown(emoji.name ?? '¯\\_(ツ)_/¯')} \`[Emoji]\``); } // Role if (message.guild && message.guild.roles.cache.has(snowflake)) { const role: Role = message.guild.roles.cache.get(snowflake)!; const roleInfo = stripIndent` - **Name:** <@&${role.id}> (${util.discord.escapeMarkdown(role.name)}) + **Name:** <@&${role.id}> (${escapeMarkdown(role.name)}) **Members:** ${role.members.size} **Hoisted:** ${role.hoist} **Managed:** ${role.managed} @@ -117,14 +122,14 @@ export default class SnowflakeCommand extends BushCommand { **Hex Color:** ${role.hexColor}`; if (role.color) snowflakeEmbed.setColor(role.color); snowflakeEmbed.addFields([{ name: '» Role Info', value: roleInfo }]); - snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(role.name)} \`[Role]\``); + snowflakeEmbed.setTitle(`:snowflake: ${escapeMarkdown(role.name)} \`[Role]\``); } // SnowflakeInfo const deconstructedSnowflake: DeconstructedSnowflake = SnowflakeUtil.deconstruct(snowflake); const snowflakeInfo = stripIndent` **Timestamp:** ${deconstructedSnowflake.timestamp} - **Created:** ${util.timestamp(new Date(Number(deconstructedSnowflake.timestamp)))} + **Created:** ${timestamp(new Date(Number(deconstructedSnowflake.timestamp)))} **Worker ID:** ${deconstructedSnowflake.workerId} **Process ID:** ${deconstructedSnowflake.processId} **Increment:** ${deconstructedSnowflake.increment}`; -- cgit