aboutsummaryrefslogtreecommitdiff
path: root/src/commands/info
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-17 20:03:05 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-17 20:03:05 -0400
commite1c613829950a534d9f45c00a033b83575be3b3c (patch)
tree2de1e5231217211ae4087c46cc74dc46c584507a /src/commands/info
parent0e87bbd3940d89defcb04926587b35c8f4d1947f (diff)
downloadtanzanite-e1c613829950a534d9f45c00a033b83575be3b3c.tar.gz
tanzanite-e1c613829950a534d9f45c00a033b83575be3b3c.tar.bz2
tanzanite-e1c613829950a534d9f45c00a033b83575be3b3c.zip
remove global client variable
Diffstat (limited to 'src/commands/info')
-rw-r--r--src/commands/info/botInfo.ts23
-rw-r--r--src/commands/info/guildInfo.ts2
-rw-r--r--src/commands/info/help.ts13
-rw-r--r--src/commands/info/links.ts4
-rw-r--r--src/commands/info/pronouns.ts3
-rw-r--r--src/commands/info/snowflake.ts27
-rw-r--r--src/commands/info/userInfo.ts16
7 files changed, 41 insertions, 47 deletions
diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts
index decbe04..25b860c 100644
--- a/src/commands/info/botInfo.ts
+++ b/src/commands/info/botInfo.ts
@@ -3,7 +3,6 @@ import {
clientSendAndPermCheck,
colors,
humanizeDuration,
- mapIDs,
shell,
type CommandMessage,
type SlashMessage
@@ -44,14 +43,14 @@ export default class BotInfoCommand extends BushCommand {
haiku = 'Haiku'
}
- const developers = (await mapIDs(client.config.owners)).map((u) => u?.tag).join('\n');
+ const developers = (await this.client.utils.mapIDs(this.client.config.owners)).map((u) => u?.tag).join('\n');
const currentCommit = (await shell('git rev-parse HEAD')).stdout.replace('\n', '');
let repoUrl = (await shell('git remote get-url origin')).stdout.replace('\n', '');
if (repoUrl.includes('.git')) repoUrl = repoUrl.substring(0, repoUrl.length - 4);
const embed = new EmbedBuilder()
.setTitle('Bot Info:')
.addFields([
- { name: '**Uptime**', value: humanizeDuration(client.uptime!, 2), inline: true },
+ { name: '**Uptime**', value: humanizeDuration(this.client.uptime!, 2), inline: true },
{
name: '**Memory Usage**',
value: `System: ${prettyBytes(os.totalmem() - os.freemem(), { binary: true })}/${prettyBytes(os.totalmem(), {
@@ -62,18 +61,18 @@ export default class BotInfoCommand extends BushCommand {
)}`,
inline: true
},
- { name: '**CPU Usage**', value: `${client.stats.cpu}%`, inline: true },
+ { name: '**CPU Usage**', value: `${this.client.stats.cpu}%`, inline: true },
{ name: '**Platform**', value: Platform[process.platform], inline: true },
- { name: '**Commands Used**', value: `${client.stats.commandsUsed.toLocaleString()}`, inline: true },
- { name: '**Slash Commands Used**', value: `${client.stats.slashCommandsUsed.toLocaleString()}`, inline: true },
- { name: '**Servers**', value: client.guilds.cache.size.toLocaleString(), inline: true },
- { name: '**Users**', value: client.users.cache.size.toLocaleString(), inline: true },
+ { name: '**Commands Used**', value: `${this.client.stats.commandsUsed.toLocaleString()}`, inline: true },
+ { name: '**Slash Commands Used**', value: `${this.client.stats.slashCommandsUsed.toLocaleString()}`, inline: true },
+ { name: '**Servers**', value: this.client.guilds.cache.size.toLocaleString(), inline: true },
+ { name: '**Users**', value: this.client.users.cache.size.toLocaleString(), inline: true },
{ name: '**Discord.js Version**', value: discordJSVersion, inline: true },
{ name: '**Node.js Version**', value: process.version.slice(1), inline: true },
- { name: '**Commands**', value: client.commandHandler.modules.size.toLocaleString(), inline: true },
- { name: '**Listeners**', value: client.listenerHandler.modules.size.toLocaleString(), inline: true },
- { name: '**Inhibitors**', value: client.inhibitorHandler.modules.size.toLocaleString(), inline: true },
- { name: '**Tasks**', value: client.taskHandler.modules.size.toLocaleString(), inline: true },
+ { name: '**Commands**', value: this.client.commandHandler.modules.size.toLocaleString(), inline: true },
+ { name: '**Listeners**', value: this.client.listenerHandler.modules.size.toLocaleString(), inline: true },
+ { name: '**Inhibitors**', value: this.client.inhibitorHandler.modules.size.toLocaleString(), inline: true },
+ { name: '**Tasks**', value: this.client.taskHandler.modules.size.toLocaleString(), inline: true },
{
name: '**Current Commit**',
value: `[${currentCommit.substring(0, 7)}](${repoUrl}/commit/${currentCommit})`,
diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts
index 92999a5..060a439 100644
--- a/src/commands/info/guildInfo.ts
+++ b/src/commands/info/guildInfo.ts
@@ -66,7 +66,7 @@ export default class GuildInfoCommand extends BushCommand {
let guild: ArgType<'guild' | 'snowflake'> | GuildPreview = args.guild ?? message.guild!;
if (typeof guild === 'string') {
- const preview = await client.fetchGuildPreview(`${args.guild}` as Snowflake).catch(() => undefined);
+ const preview = await this.client.fetchGuildPreview(`${args.guild}` as Snowflake).catch(() => undefined);
if (preview) guild = preview;
else return await message.util.reply(`${emojis.error} That guild is not discoverable or does not exist.`);
}
diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts
index 051fce5..1a19969 100644
--- a/src/commands/info/help.ts
+++ b/src/commands/info/help.ts
@@ -4,7 +4,6 @@ import {
colors,
format,
invite,
- prefix,
type ArgType,
type CommandMessage,
type OptArgType,
@@ -68,7 +67,7 @@ export default class HelpCommand extends BushCommand {
const row = this.addLinks(message);
const command = args.command
? typeof args.command === 'string'
- ? client.commandHandler.findCommand(args.command) ?? null
+ ? this.client.commandHandler.findCommand(args.command) ?? null
: args.command
: null;
@@ -82,7 +81,7 @@ export default class HelpCommand extends BushCommand {
}
private helpAll(message: CommandMessage | SlashMessage, args: HelpArgs, row: ActionRowBuilder<ButtonBuilder>) {
- const prefix_ = prefix(message);
+ const prefix_ = this.client.utils.prefix(message);
const embed = new EmbedBuilder()
.setColor(colors.default)
.setTimestamp()
@@ -211,7 +210,7 @@ export default class HelpCommand extends BushCommand {
if (command.restrictedGuilds?.length)
restrictions.push(
`__Restricted Servers__: ${command.restrictedGuilds
- .map((g) => format.inlineCode(client.guilds.cache.find((g1) => g1.id === g)?.name ?? 'Unknown'))
+ .map((g) => format.inlineCode(this.client.guilds.cache.find((g1) => g1.id === g)?.name ?? 'Unknown'))
.join(' ')}`
);
if (restrictions.length) embed.addFields([{ name: '» Restrictions', value: restrictions.join('\n') }]);
@@ -221,12 +220,12 @@ export default class HelpCommand extends BushCommand {
private addLinks(message: CommandMessage | SlashMessage) {
const row = new ActionRowBuilder<ButtonBuilder>();
- if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) {
+ if (!this.client.config.isDevelopment && !this.client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) {
row.addComponents([new ButtonBuilder({ style: ButtonStyle.Link, label: 'Invite Me', url: invite(this.client) })]);
}
- if (!client.guilds.cache.get(client.config.supportGuild.id)?.members.cache.has(message.author.id)) {
+ if (!this.client.guilds.cache.get(this.client.config.supportGuild.id)?.members.cache.has(message.author.id)) {
row.addComponents([
- new ButtonBuilder({ style: ButtonStyle.Link, label: 'Support Server', url: client.config.supportGuild.invite })
+ new ButtonBuilder({ style: ButtonStyle.Link, label: 'Support Server', url: this.client.config.supportGuild.invite })
]);
}
if (packageDotJSON?.repository)
diff --git a/src/commands/info/links.ts b/src/commands/info/links.ts
index a7ff30e..41e5c4d 100644
--- a/src/commands/info/links.ts
+++ b/src/commands/info/links.ts
@@ -21,11 +21,11 @@ export default class LinksCommand extends BushCommand {
public override async exec(message: CommandMessage | SlashMessage) {
const buttonRow = new ActionRowBuilder<ButtonBuilder>();
- if (!client.config.isDevelopment || message.author.isOwner()) {
+ if (!this.client.config.isDevelopment || message.author.isOwner()) {
buttonRow.addComponents([new ButtonBuilder({ style: ButtonStyle.Link, label: 'Invite Me', url: invite(this.client) })]);
}
buttonRow.addComponents([
- new ButtonBuilder({ style: ButtonStyle.Link, label: 'Support Server', url: client.config.supportGuild.invite }),
+ new ButtonBuilder({ style: ButtonStyle.Link, label: 'Support Server', url: this.client.config.supportGuild.invite }),
new ButtonBuilder({ style: ButtonStyle.Link, label: 'GitHub', url: packageDotJSON.repository })
]);
return await message.util.reply({ content: 'Here are some useful links:', components: [buttonRow] });
diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts
index e87ca1f..0063f4c 100644
--- a/src/commands/info/pronouns.ts
+++ b/src/commands/info/pronouns.ts
@@ -2,7 +2,6 @@ import {
AllowedMentions,
BushCommand,
clientSendAndPermCheck,
- getPronounsOf,
type CommandMessage,
type OptArgType,
type SlashMessage
@@ -40,7 +39,7 @@ export default class PronounsCommand extends BushCommand {
if (message.util.isSlashMessage(message)) await message.interaction.deferReply();
- const pronouns = await getPronounsOf(user);
+ const pronouns = await this.client.utils.getPronounsOf(user);
if (!pronouns) {
return await message.util.reply({
content: `${author ? 'You do' : `${escapeMarkdown(user.tag)} does`} not appear to have any pronouns set. Please${
diff --git a/src/commands/info/snowflake.ts b/src/commands/info/snowflake.ts
index a28f4c5..dba1378 100644
--- a/src/commands/info/snowflake.ts
+++ b/src/commands/info/snowflake.ts
@@ -16,10 +16,7 @@ import {
PermissionFlagsBits,
SnowflakeUtil,
type DeconstructedSnowflake,
- type Guild,
- type Role,
- type Snowflake,
- type User
+ type Snowflake
} from 'discord.js';
export default class SnowflakeCommand extends BushCommand {
@@ -51,8 +48,8 @@ export default class SnowflakeCommand extends BushCommand {
const snowflakeEmbed = new EmbedBuilder().setTitle('Unknown :snowflake:').setColor(colors.default);
// Channel
- if (client.channels.cache.has(snowflake)) {
- const channel = client.channels.resolve(snowflake)!;
+ if (this.client.channels.cache.has(snowflake)) {
+ const channel = this.client.channels.resolve(snowflake)!;
const channelInfo = [`**Type:** ${BushChannelType[channel.type] ?? ChannelType[channel.type]}`];
if (channel.type === ChannelType.DM) {
channelInfo.push(
@@ -77,11 +74,11 @@ export default class SnowflakeCommand extends BushCommand {
}
// Guild
- if (client.guilds.cache.has(snowflake)) {
- const guild: Guild = client.guilds.cache.get(snowflake)!;
+ if (this.client.guilds.cache.has(snowflake)) {
+ const guild = this.client.guilds.cache.get(snowflake)!;
const guildInfo = stripIndent`
**Name:** ${escapeMarkdown(guild.name)}
- **Owner:** ${escapeMarkdown(client.users.cache.get(guild.ownerId)?.tag ?? '¯\\_(ツ)_/¯')} (${guild.ownerId})
+ **Owner:** ${escapeMarkdown(this.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 }]);
@@ -89,9 +86,9 @@ export default class SnowflakeCommand extends BushCommand {
}
// User
- const fetchedUser = await client.users.fetch(`${snowflake}`).catch(() => undefined);
- if (client.users.cache.has(snowflake) || fetchedUser) {
- const user: User = (client.users.cache.get(snowflake) ?? fetchedUser)!;
+ const fetchedUser = await this.client.users.fetch(`${snowflake}`).catch(() => undefined);
+ if (this.client.users.cache.has(snowflake) || fetchedUser) {
+ const user = (this.client.users.cache.get(snowflake) ?? fetchedUser)!;
const userInfo = stripIndent`
**Name:** <@${user.id}> (${escapeMarkdown(user.tag)})`;
if (user.avatar) snowflakeEmbed.setThumbnail(user.avatarURL({ size: 2048 })!);
@@ -100,8 +97,8 @@ export default class SnowflakeCommand extends BushCommand {
}
// Emoji
- if (client.emojis.cache.has(snowflake)) {
- const emoji = client.emojis.cache.get(snowflake)!;
+ if (this.client.emojis.cache.has(snowflake)) {
+ const emoji = this.client.emojis.cache.get(snowflake)!;
const emojiInfo = stripIndent`
**Name:** ${escapeMarkdown(emoji.name ?? '¯\\_(ツ)_/¯')}
**Animated:** ${emoji.animated}`;
@@ -112,7 +109,7 @@ export default class SnowflakeCommand extends BushCommand {
// Role
if (message.guild && message.guild.roles.cache.has(snowflake)) {
- const role: Role = message.guild.roles.cache.get(snowflake)!;
+ const role = message.guild.roles.cache.get(snowflake)!;
const roleInfo = stripIndent`
**Name:** <@&${role.id}> (${escapeMarkdown(role.name)})
**Members:** ${role.members.size}
diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts
index a39e28a..73a0422 100644
--- a/src/commands/info/userInfo.ts
+++ b/src/commands/info/userInfo.ts
@@ -4,8 +4,6 @@ import {
clientSendAndPermCheck,
colors,
emojis,
- getPronounsOf,
- getShared,
mappings,
oxford,
sleep,
@@ -63,7 +61,7 @@ export default class UserInfoCommand extends BushCommand {
? message.author
: typeof args.user === 'object'
? args.user
- : await client.users.fetch(`${args.user}`).catch(() => undefined);
+ : await this.client.users.fetch(`${args.user}`).catch(() => undefined);
if (user === undefined) return message.util.reply(`${emojis.error} Invalid user.`);
const member = message.guild ? await message.guild.members.fetch(user.id).catch(() => undefined) : undefined;
await user.fetch(true); // gets banner info and accent color
@@ -75,7 +73,7 @@ export default class UserInfoCommand extends BushCommand {
public static async makeUserInfoEmbed(user: User, member?: GuildMember, guild?: Guild | null) {
const emojis = [];
- const superUsers = getShared('superUsers');
+ const superUsers = user.client.utils.getShared('superUsers');
const userEmbed = new EmbedBuilder()
.setTitle(escapeMarkdown(user.tag))
@@ -85,7 +83,7 @@ export default class UserInfoCommand extends BushCommand {
.setColor(member?.displayColor ?? colors.default);
// Flags
- if (client.config.owners.includes(user.id)) emojis.push(mappings.otherEmojis.Developer);
+ if (user.client.config.owners.includes(user.id)) emojis.push(mappings.otherEmojis.Developer);
if (superUsers.includes(user.id)) emojis.push(mappings.otherEmojis.Superuser);
const flags = user.flags?.toArray();
if (flags) {
@@ -143,7 +141,7 @@ export default class UserInfoCommand extends BushCommand {
if (user.accentColor !== null) generalInfo.push(`**Accent Color:** ${user.hexAccentColor}`);
if (user.banner) generalInfo.push(`**Banner:** [link](${user.bannerURL({ extension: 'png', size: 4096 })})`);
- const pronouns = await Promise.race([getPronounsOf(user), sleep(2 * Time.Second)]); // cut off request after 2 seconds
+ const pronouns = await Promise.race([user.client.utils.getPronounsOf(user), sleep(2 * Time.Second)]); // cut off request after 2 seconds
if (pronouns && typeof pronouns === 'string' && pronouns !== 'Unspecified') generalInfo.push(`**Pronouns:** ${pronouns}`);
@@ -211,7 +209,7 @@ export default class UserInfoCommand extends BushCommand {
}
embed.setFooter({
text: member.user.tag,
- iconURL: client.emojis.cache.get(statusEmojis[member?.presence.status])?.url ?? undefined
+ iconURL: member.client.emojis.cache.get(statusEmojis[member?.presence.status])?.url ?? undefined
});
}
@@ -258,7 +256,9 @@ export default class UserInfoCommand extends BushCommand {
public static async generateBotField(embed: EmbedBuilder, user: User, title = '» Bot Information') {
if (!user.bot) return;
- const applicationInfo = (await client.rest.get(`/applications/${user.id}/rpc`).catch(() => null)) as APIApplication | null;
+ const applicationInfo = (await user.client.rest
+ .get(`/applications/${user.id}/rpc`)
+ .catch(() => null)) as APIApplication | null;
if (!applicationInfo) return;
const flags = new ApplicationFlagsBitField(applicationInfo.flags);