aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-11-10 22:12:23 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-11-10 22:12:23 -0500
commit9923f0751396decaa6febcaa54da9b6ad9b596b1 (patch)
tree5022a611ae156ff2cd6edb8c124113b539845213 /src/commands
parent8928d95b87e036f731c7a65d8646d75f5bb42c93 (diff)
downloadtanzanite-9923f0751396decaa6febcaa54da9b6ad9b596b1.tar.gz
tanzanite-9923f0751396decaa6febcaa54da9b6ad9b596b1.tar.bz2
tanzanite-9923f0751396decaa6febcaa54da9b6ad9b596b1.zip
fixed lots of shit I think
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/config/config.ts26
-rw-r--r--src/commands/config/disable.ts4
-rw-r--r--src/commands/dev/reload.ts2
-rw-r--r--src/commands/info/botInfo.ts2
-rw-r--r--src/commands/info/guildInfo.ts40
-rw-r--r--src/commands/info/icon.ts2
-rw-r--r--src/commands/info/pronouns.ts4
-rw-r--r--src/commands/info/snowflake.ts58
-rw-r--r--src/commands/info/userInfo.ts8
-rw-r--r--src/commands/leveling/level.ts9
-rw-r--r--src/commands/utilities/wolframAlpha.ts2
11 files changed, 79 insertions, 78 deletions
diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts
index 99a1147..7811663 100644
--- a/src/commands/config/config.ts
+++ b/src/commands/config/config.ts
@@ -1,19 +1,19 @@
import { BushCommand, guildSettingsObj, settingsArr, type BushMessage, type BushSlashMessage, type GuildSettings } from '#lib';
import { type ArgumentOptions, type Flag } from 'discord-akairo';
import {
- Channel,
- Formatters,
- GuildMember,
- MessageActionRow,
- MessageButton,
- MessageEmbed,
- MessageSelectMenu,
- Role,
- User,
- type Message,
- type MessageComponentInteraction,
- type MessageOptions,
- type Snowflake
+ Channel,
+ Formatters,
+ GuildMember,
+ MessageActionRow,
+ MessageButton,
+ MessageEmbed,
+ MessageSelectMenu,
+ Role,
+ User,
+ type Message,
+ type MessageComponentInteraction,
+ type MessageOptions,
+ type Snowflake
} from 'discord.js';
import _ from 'lodash';
diff --git a/src/commands/config/disable.ts b/src/commands/config/disable.ts
index a04850c..83b4608 100644
--- a/src/commands/config/disable.ts
+++ b/src/commands/config/disable.ts
@@ -79,7 +79,7 @@ export default class DisableCommand extends BushCommand {
.catch(() => false);
if (!success)
return await message.util.reply({
- content: `${util.emojis.error} There was an error globally **${action.substr(
+ content: `${util.emojis.error} There was an error globally **${action.substring(
0,
action.length - 2
)}ing** the **${commandID}** command.`,
@@ -87,7 +87,7 @@ export default class DisableCommand extends BushCommand {
});
else
return await message.util.reply({
- content: `${util.emojis.success} Successfully **${action.substr(
+ content: `${util.emojis.success} Successfully **${action.substring(
0,
action.length - 2
)}ed** the **${commandID}** command globally.`,
diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts
index cbabb48..f9b1867 100644
--- a/src/commands/dev/reload.ts
+++ b/src/commands/dev/reload.ts
@@ -40,7 +40,7 @@ export default class ReloadCommand extends BushCommand {
let output: { stdout: string; stderr: string };
try {
const s = new Date();
- output = await util.shell(`yarn build-${/* fast ? 'esbuild' : */ 'tsc'}`);
+ output = await util.shell(`yarn build:${/* fast ? 'esbuild' : */ 'tsc'}`);
await Promise.all([
client.commandHandler.reloadAll(),
client.listenerHandler.reloadAll(),
diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts
index f100317..04a1b14 100644
--- a/src/commands/info/botInfo.ts
+++ b/src/commands/info/botInfo.ts
@@ -1,7 +1,7 @@
import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
import { MessageEmbed, version as discordJSVersion } from 'discord.js';
import * as os from 'os';
-import prettyBytes from 'pretty-bytes';
+const {default: prettyBytes} = await import('pretty-bytes')
export default class BotInfoCommand extends BushCommand {
public constructor() {
diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts
index facbb45..ef1c232 100644
--- a/src/commands/info/guildInfo.ts
+++ b/src/commands/info/guildInfo.ts
@@ -1,5 +1,5 @@
import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
-import { Guild, MessageEmbed, type BaseGuildVoiceChannel, type GuildPreview, type Snowflake, type Vanity } from 'discord.js';
+import { Constants, Guild, MessageEmbed, type BaseGuildVoiceChannel, type GuildPreview, type Snowflake, type Vanity } from 'discord.js';
export default class GuildInfoCommand extends BushCommand {
public constructor() {
@@ -65,15 +65,18 @@ export default class GuildInfoCommand extends BushCommand {
if (guild.premiumTier !== 'NONE') emojis.push(otherEmojis[`BOOST_${guild.premiumTier}`]);
await guild.fetch();
const channels = guild.channels.cache;
- const channelTypes = [
- `${otherEmojis.TEXT} ${channels.filter((channel) => channel.type === 'GUILD_TEXT').size.toLocaleString()}`,
- `${otherEmojis.NEWS} ${channels.filter((channel) => channel.type === 'GUILD_NEWS').size.toLocaleString()}`,
- `${otherEmojis.VOICE} ${channels.filter((channel) => channel.type === 'GUILD_VOICE').size.toLocaleString()}`,
- `${otherEmojis.STAGE} ${channels.filter((channel) => channel.type === 'GUILD_STAGE_VOICE').size.toLocaleString()}`,
- `${otherEmojis.STORE} ${channels.filter((channel) => channel.type === 'GUILD_STORE').size.toLocaleString()}`,
- `${otherEmojis.CATEGORY} ${channels.filter((channel) => channel.type === 'GUILD_CATEGORY').size.toLocaleString()}`,
- `${otherEmojis.THREAD} ${channels.filter((channel) => channel.type.includes('_THREAD')).size.toLocaleString()}`
- ];
+
+ type ChannelType = 'GUILD_TEXT'|'GUILD_NEWS'|'GUILD_VOICE'|'GUILD_STAGE_VOICE'|'GUILD_STORE'|'GUILD_CATEGORY'|'THREAD'
+ const channelTypes = ([
+ 'GUILD_TEXT',
+ 'GUILD_VOICE',
+ 'GUILD_STAGE_VOICE',
+ 'GUILD_STORE',
+ 'GUILD_CATEGORY',
+ 'THREAD',
+ ] as ChannelType[]).map(
+ (type)=>`${otherEmojis[type]} ${channels.filter((channel) => channel.type.includes(type)).size.toLocaleString()}`
+ )
const guildRegions = [
...new Set(
@@ -82,7 +85,7 @@ export default class GuildInfoCommand extends BushCommand {
] as RTCRegion[];
guildAbout.push(
- `**Owner:** ${guild.members.cache.get(guild.ownerId)?.user.tag}`,
+ `**Owner:** ${util.discord.escapeMarkdown(guild.members.cache.get(guild.ownerId)?.user.tag ?? '¯\\_(ツ)_/¯')}`,
`**Created** ${util.timestamp(guild.createdAt)} (${util.dateDelta(guild.createdAt)})`,
`**Members:** ${guild.memberCount.toLocaleString() ?? 0} (${util.emojis.onlineCircle} ${
guild.approximatePresenceCount?.toLocaleString() ?? 0
@@ -91,9 +94,7 @@ export default class GuildInfoCommand extends BushCommand {
);
if (guild.premiumSubscriptionCount)
guildAbout.push(
- `**Boosts:** Level ${guild.premiumTier == 'NONE' ? 0 : guild.premiumTier[5]} with ${
- guild.premiumSubscriptionCount ?? 0
- } boosts`
+ `**Boosts:** Level ${Constants.PremiumTiers[guild.premiumTier]} with ${guild.premiumSubscriptionCount ?? 0} boosts`
);
if (guild.me?.permissions.has('MANAGE_GUILD') && guild.vanityURLCode) {
const vanityInfo: Vanity = await guild.fetchVanityData();
@@ -104,16 +105,15 @@ export default class GuildInfoCommand extends BushCommand {
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' })})`);
+ enum EmojiTierMap { TIER_3 = 500, TIER_2 = 300, TIER_1 = 100, NONE = 50 }
+ enum StickerTierMap { TIER_3 = 60, TIER_2 = 30, TIER_1 = 15, NONE = 0 }
+
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} / ${
- guild.premiumTier === 'TIER_3' ? 500 : guild.premiumTier === 'TIER_2' ? 300 : guild.premiumTier === 'TIER_1' ? 100 : 50
- }`,
- `**Stickers:** ${guild.stickers.cache.size?.toLocaleString() ?? 0} / ${
- guild.premiumTier === 'TIER_3' ? 60 : guild.premiumTier === 'TIER_2' ? 30 : guild.premiumTier === 'TIER_1' ? 15 : 0
- }`
+ `**Emojis:** ${guild.emojis.cache.size?.toLocaleString() ?? 0} / ${EmojiTierMap[guild.premiumTier]}`,
+ `**Stickers:** ${guild.stickers.cache.size?.toLocaleString() ?? 0} / ${StickerTierMap[guild.premiumTier]}`
);
guildSecurity.push(
diff --git a/src/commands/info/icon.ts b/src/commands/info/icon.ts
index fa4968c..2a04a65 100644
--- a/src/commands/info/icon.ts
+++ b/src/commands/info/icon.ts
@@ -29,7 +29,7 @@ export default class IconCommand extends BushCommand {
format: 'png'
})!
)
- .setTitle(message.guild!.name);
+ .setTitle(util.discord.escapeMarkdown(message.guild!.name));
await message.util.reply({ embeds: [embed] });
}
}
diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts
index fbbc5af..a7df5aa 100644
--- a/src/commands/info/pronouns.ts
+++ b/src/commands/info/pronouns.ts
@@ -44,7 +44,7 @@ export default class PronounsCommand extends BushCommand {
const pronouns = await util.getPronounsOf(user);
if (!pronouns) {
return await message.util.reply(
- `${author ? 'You do' : `${user.tag} does`} not appear to have any pronouns set. Please${
+ `${author ? 'You do' : `${util.discord.escapeMarkdown(user.tag)} does`} not appear to have any pronouns set. Please${
author ? '' : ' tell them to'
} go to https://pronoundb.org/ and set ${author ? 'your' : 'their'} pronouns.`
);
@@ -52,7 +52,7 @@ export default class PronounsCommand extends BushCommand {
return await message.util.reply({
embeds: [
new MessageEmbed({
- title: `${author ? 'Your' : `${user.tag}'s`} pronouns:`,
+ title: `${author ? 'Your' : `${util.discord.escapeMarkdown(user.tag)}'s`} pronouns:`,
description: pronouns,
footer: {
text: 'Data provided by https://pronoundb.org/'
diff --git a/src/commands/info/snowflake.ts b/src/commands/info/snowflake.ts
index a6de675..3b1a073 100644
--- a/src/commands/info/snowflake.ts
+++ b/src/commands/info/snowflake.ts
@@ -1,20 +1,18 @@
import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
import {
- MessageEmbed,
- SnowflakeUtil,
- VoiceChannel,
- type CategoryChannel,
- type Channel,
- type DeconstructedSnowflake,
- type DMChannel,
- type Emoji,
- type Guild,
- type NewsChannel,
- type Role,
- type Snowflake,
- type StageChannel,
- type TextChannel,
- type User
+ MessageEmbed,
+ SnowflakeUtil,
+ VoiceChannel,
+ type CategoryChannel,
+ type Channel,
+ type DeconstructedSnowflake,
+ type DMChannel, type Guild,
+ type NewsChannel,
+ type Role,
+ type Snowflake,
+ type StageChannel,
+ type TextChannel,
+ type User
} from 'discord.js';
export default class SnowflakeCommand extends BushCommand {
@@ -61,8 +59,8 @@ export default class SnowflakeCommand extends BushCommand {
const channelInfo = [`**Type:** ${channel.type}`];
if (['dm', 'group'].includes(channel.type)) {
const _channel = channel as DMChannel;
- channelInfo.push(`**Recipient:** ${_channel.recipient.tag} (${_channel.recipient.id})`);
- snowflakeEmbed.setTitle(`:snowflake: DM with ${(channel as DMChannel).recipient.tag} \`[Channel]\``);
+ 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]\``);
} else if (
[
'GUILD_CATEGORY',
@@ -78,10 +76,10 @@ export default class SnowflakeCommand extends BushCommand {
) {
const _channel = channel as TextChannel | VoiceChannel | NewsChannel | StageChannel | CategoryChannel | StageChannel;
channelInfo.push(
- `**Channel Name:** <#${_channel.id}> (${_channel.name})`,
- `**Channel's Server:** ${_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: ${_channel.name} \`[Channel]\``);
+ snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(_channel.name)} \`[Channel]\``);
}
snowflakeEmbed.addField('» Channel Info', channelInfo.join('\n'));
}
@@ -90,39 +88,39 @@ export default class SnowflakeCommand extends BushCommand {
if (client.guilds.cache.has(snowflake)) {
const guild: Guild = client.guilds.cache.get(snowflake)!;
const guildInfo = [
- `**Name:** ${guild.name}`,
- `**Owner:** ${client.users.cache.get(guild.ownerId)?.tag ?? '¯\\_(ツ)_/¯'} (${guild.ownerId})`,
+ `**Name:** ${util.discord.escapeMarkdown(guild.name)}`,
+ `**Owner:** ${util.discord.escapeMarkdown(client.users.cache.get(guild.ownerId)?.tag ?? '¯\\_(ツ)_/¯')} (${guild.ownerId})`,
`**Members:** ${guild.memberCount?.toLocaleString()}`
];
if (guild.icon) snowflakeEmbed.setThumbnail(guild.iconURL({ size: 2048, dynamic: true })!);
snowflakeEmbed.addField('» Server Info', guildInfo.join('\n'));
- snowflakeEmbed.setTitle(`:snowflake: ${guild.name} \`[Server]\``);
+ snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(guild.name)} \`[Server]\``);
}
// 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 userInfo = [`**Name:** <@${user.id}> (${user.tag})`];
+ const userInfo = [`**Name:** <@${user.id}> (${util.discord.escapeMarkdown(user.tag)})`];
if (user.avatar) snowflakeEmbed.setThumbnail(user.avatarURL({ size: 2048, dynamic: true })!);
snowflakeEmbed.addField('» User Info', userInfo.join('\n'));
- snowflakeEmbed.setTitle(`:snowflake: ${user.tag} \`[User]\``);
+ snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(user.tag)} \`[User]\``);
}
// Emoji
if (client.emojis.cache.has(snowflake)) {
- const emoji: Emoji = client.emojis.cache.get(snowflake)!;
- const emojiInfo = [`**Name:** ${emoji.name}`, `**Animated:** ${emoji.animated}`];
+ const emoji = client.emojis.cache.get(snowflake)!;
+ const emojiInfo = [`**Name:** ${util.discord.escapeMarkdown(emoji.name ?? '¯\\_(ツ)_/¯')}`, `**Animated:** ${emoji.animated}`];
if (emoji.url) snowflakeEmbed.setThumbnail(emoji.url);
snowflakeEmbed.addField('» Emoji Info', emojiInfo.join('\n'));
- snowflakeEmbed.setTitle(`:snowflake: ${emoji.name} \`[Emoji]\``);
+ snowflakeEmbed.setTitle(`:snowflake: ${util.discord.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 = [
- `**Name:** <@&${role.id}> (${role.name})`,
+ `**Name:** <@&${role.id}> (${util.discord.escapeMarkdown(role.name)})`,
`**Members:** ${role.members.size}`,
`**Hoisted:** ${role.hoist}`,
`**Managed:** ${role.managed}`,
@@ -131,7 +129,7 @@ export default class SnowflakeCommand extends BushCommand {
];
if (role.color) snowflakeEmbed.setColor(role.color);
snowflakeEmbed.addField('» Role Info', roleInfo.join('\n'));
- snowflakeEmbed.setTitle(`:snowflake: ${role.name} \`[Role]\``);
+ snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(role.name)} \`[Role]\``);
}
// SnowflakeInfo
diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts
index 2b87d0b..49c23c9 100644
--- a/src/commands/info/userInfo.ts
+++ b/src/commands/info/userInfo.ts
@@ -52,9 +52,9 @@ export default class UserInfoCommand extends BushCommand {
await user.fetch(true); // gets banner info and accent color
const userEmbed: MessageEmbed = new MessageEmbed()
- .setTitle(user.tag)
+ .setTitle(util.discord.escapeMarkdown(user.tag))
.setThumbnail(
- user.avatarURL({ size: 2048, format: 'png', dynamic: true }) ?? 'https://cdn.discordapp.com/embed/avatars/0.png'
+ user.displayAvatarURL({ size: 2048, format: 'png', dynamic: true })
)
.setTimestamp();
@@ -112,7 +112,7 @@ export default class UserInfoCommand extends BushCommand {
serverUserInfo.push(`**General Deletions:** 1⅓`);
if (['384620942577369088', '496409778822709251'].includes(user.id) && message.guild?.id == client.consts.mappings.guilds.bush)
serverUserInfo.push(`**General Deletions:** ⅓`);
- if (member?.nickname) serverUserInfo.push(`**Nickname:** ${member?.nickname}`);
+ if (member?.nickname) serverUserInfo.push(`**Nickname:** ${util.discord.escapeMarkdown(member?.nickname)}`);
if (serverUserInfo.length)
userEmbed.addField('» Server Info', serverUserInfo.join('\n')).setColor(member?.displayColor ?? util.colors.default);
@@ -137,7 +137,7 @@ export default class UserInfoCommand extends BushCommand {
presenceInfo.push(`**${devices.length - 1 ? 'Devices' : 'Device'}:** ${util.oxford(devices, 'and', '')}`);
if (activitiesNames.length)
presenceInfo.push(`**Activit${activitiesNames.length - 1 ? 'ies' : 'y'}:** ${util.oxford(activitiesNames, 'and', '')}`);
- if (customStatus && customStatus.length) presenceInfo.push(`**Custom Status:** ${customStatus}`);
+ if (customStatus && customStatus.length) presenceInfo.push(`**Custom Status:** ${util.discord.escapeMarkdown(customStatus)}`);
userEmbed.addField('» Presence', presenceInfo.join('\n'));
enum statusEmojis {
diff --git a/src/commands/leveling/level.ts b/src/commands/leveling/level.ts
index 0da0bf0..ea77124 100644
--- a/src/commands/leveling/level.ts
+++ b/src/commands/leveling/level.ts
@@ -11,8 +11,11 @@ import {
import canvas from 'canvas';
import { MessageAttachment } from 'discord.js';
import got from 'got';
-import { join } from 'path';
-import SimplifyNumber from 'simplify-number';
+import { dirname, join } from 'path';
+import { fileURLToPath } from 'url';
+
+// idk why I need to do default twice, it is being weird
+const { default: SimplifyNumber } = ((await import('simplify-number')).default as unknown as typeof import('simplify-number'));
export default class LevelCommand extends BushCommand {
public constructor() {
@@ -89,7 +92,7 @@ export default class LevelCommand extends BushCommand {
gray = '#23272A',
highlight = user.hexAccentColor ?? '#5865F2';
// Load roboto font
- canvas.registerFont(join(__dirname, '..', '..', '..', '..', 'lib', 'assets', 'Roboto-Regular.ttf'), {
+ canvas.registerFont(join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..', '..', 'lib', 'assets', 'Roboto-Regular.ttf'), {
family: 'Roboto'
});
// Create image canvas
diff --git a/src/commands/utilities/wolframAlpha.ts b/src/commands/utilities/wolframAlpha.ts
index bc5f939..aba0f57 100644
--- a/src/commands/utilities/wolframAlpha.ts
+++ b/src/commands/utilities/wolframAlpha.ts
@@ -1,6 +1,6 @@
import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
import { MessageEmbed, type MessageOptions } from 'discord.js';
-import WolframAlphaAPI from 'wolfram-alpha-api';
+const {default: WolframAlphaAPI} = (await import("wolfram-alpha-api")).default as unknown as typeof import( "wolfram-alpha-api")
export default class WolframAlphaCommand extends BushCommand {
public constructor() {