aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands/config/log.ts2
-rw-r--r--src/commands/dev/eval.ts120
-rw-r--r--src/commands/dev/javascript.ts12
-rw-r--r--src/commands/info/color.ts2
-rw-r--r--src/commands/info/help.ts28
-rw-r--r--src/commands/moulberry-bush/capes.ts21
-rw-r--r--src/commands/moulberry-bush/rule.ts41
-rw-r--r--src/commands/utilities/activity.ts23
-rw-r--r--src/commands/utilities/price.ts45
-rw-r--r--src/commands/utilities/suicide.ts21
-rw-r--r--src/commands/utilities/wolframAlpha.ts13
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts2
-rw-r--r--src/lib/extensions/discord-akairo/BushCommandHandler.ts4
-rw-r--r--src/lib/extensions/discord-akairo/BushCommandUtil.ts4
-rw-r--r--src/listeners/bush/nameAutoBan.ts36
-rw-r--r--src/listeners/commands/commandCooldown.ts4
-rw-r--r--src/tasks/updatePriceItemCache.ts31
-rw-r--r--src/tasks/updateSuperUsers.ts2
18 files changed, 221 insertions, 190 deletions
diff --git a/src/commands/config/log.ts b/src/commands/config/log.ts
index ad3aacc..3072866 100644
--- a/src/commands/config/log.ts
+++ b/src/commands/config/log.ts
@@ -81,7 +81,7 @@ export default class LogCommand extends BushCommand {
? `${util.emojis.success} Successfully ${oldChannel ? 'changed' : 'set'}`
: `${util.emojis.error} Unable to ${oldChannel ? 'change' : 'set'}`
} ${
- oldChannel ? ` the **${args.log_type}** log channel from <#${oldChannel}>` : ` the \`${args.log_type}\` log channel`
+ oldChannel ? `the **${args.log_type}** log channel from <#${oldChannel}>` : `the **${args.log_type}** log channel`
} to ${args.channel ? `<#${args.channel.id}>` : '`disabled`'}`
);
}
diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts
index ac114ea..5b2f27a 100644
--- a/src/commands/dev/eval.ts
+++ b/src/commands/dev/eval.ts
@@ -1,10 +1,45 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+/* eslint-disable @typescript-eslint/no-unused-vars */
+import {
+ ActivePunishment,
+ BushCommand,
+ BushMessage,
+ BushSlashMessage,
+ Global,
+ Guild,
+ Level,
+ ModLog,
+ StickyRole,
+ type ArgType
+} from '#lib';
+import { Canvas } from 'canvas';
import { exec } from 'child_process';
-import { MessageEmbed as _MessageEmbed } from 'discord.js';
+import {
+ ButtonInteraction,
+ Collection,
+ Collector,
+ CommandInteraction,
+ ContextMenuInteraction,
+ DMChannel,
+ Emoji,
+ Interaction,
+ InteractionCollector,
+ Message,
+ MessageActionRow,
+ MessageAttachment,
+ MessageButton,
+ MessageCollector,
+ MessageEmbed,
+ MessageSelectMenu,
+ ReactionCollector,
+ Util
+} from 'discord.js';
import ts from 'typescript';
import { promisify } from 'util';
-
-const { transpile } = ts;
+const { transpile } = ts,
+ emojis = util.emojis,
+ colors = util.colors,
+ sh = promisify(exec);
+/* eslint-enable @typescript-eslint/no-unused-vars */
export default class EvalCommand extends BushCommand {
public constructor() {
@@ -21,8 +56,7 @@ export default class EvalCommand extends BushCommand {
match: 'rest',
prompt: 'What would you like to eval?',
retry: '{error} Invalid code to eval.',
- slashType: 'STRING',
- only: 'slash'
+ slashType: 'STRING'
},
{
id: 'sel_depth',
@@ -98,15 +132,6 @@ export default class EvalCommand extends BushCommand {
prompt: 'Would you like to inspect the prototype chain to find methods?',
slashType: 'BOOLEAN',
optional: true
- },
- {
- id: 'code',
- description: 'The code you would like to evaluate.',
- match: 'rest',
- prompt: 'What would you like to eval?',
- retry: '{error} Invalid code to eval.',
- slashType: 'STRING',
- only: 'text'
}
],
slash: true,
@@ -120,14 +145,14 @@ export default class EvalCommand extends BushCommand {
message: BushMessage | BushSlashMessage,
args: {
sel_depth: ArgType<'integer'>;
- code: string;
- sudo: boolean;
- silent: boolean;
- deleteMSG: boolean;
- typescript: boolean;
- hidden: boolean;
- show_proto: boolean;
- show_methods: boolean;
+ code: ArgType<'string'>;
+ sudo: ArgType<'boolean'>;
+ silent: ArgType<'boolean'>;
+ deleteMSG: ArgType<'boolean'>;
+ typescript: ArgType<'boolean'>;
+ hidden: ArgType<'boolean'>;
+ show_proto: ArgType<'boolean'>;
+ show_methods: ArgType<'boolean'>;
}
) {
if (!message.author.isOwner())
@@ -135,16 +160,16 @@ export default class EvalCommand extends BushCommand {
if (message.util.isSlashMessage(message)) {
await message.interaction.deferReply({ ephemeral: args.silent });
}
- const _isTypescript = args.typescript || args.code.includes('```ts');
- const _code = args.code.replace(/[“”]/g, '"').replace(/```*(?:js|ts)?/g, '');
+ const isTypescript = args.typescript || args.code.includes('```ts');
+ const rawCode = args.code.replace(/[“”]/g, '"').replace(/```*(?:js|ts)?/g, '');
const code: { ts: string | null; js: string; lang: 'ts' | 'js' } = {
- ts: _isTypescript ? _code : null,
- js: _isTypescript ? transpile(_code) : _code,
- lang: _isTypescript ? 'ts' : 'js'
+ ts: isTypescript ? rawCode : null,
+ js: isTypescript ? transpile(rawCode) : rawCode,
+ lang: isTypescript ? 'ts' : 'js'
};
- const embed = new _MessageEmbed();
+ const embed = new MessageEmbed();
const badPhrases = ['delete', 'destroy'];
if (badPhrases.some((p) => code[code.lang]!.includes(p)) && !args.sudo) {
@@ -152,39 +177,14 @@ export default class EvalCommand extends BushCommand {
}
/* eslint-disable @typescript-eslint/no-unused-vars */
- const sh = promisify(exec),
- me = message.member,
+ const me = message.member,
member = message.member,
bot = client,
guild = message.guild,
channel = message.channel,
config = client.config,
members = message.guild?.members,
- roles = message.guild?.roles,
- emojis = util.emojis,
- colors = util.colors,
- { ActivePunishment, Global, Guild, Level, ModLog, StickyRole } = await import('#lib'),
- {
- ButtonInteraction,
- Collection,
- Collector,
- CommandInteraction,
- ContextMenuInteraction,
- DMChannel,
- Emoji,
- Interaction,
- InteractionCollector,
- Message,
- MessageActionRow,
- MessageAttachment,
- MessageButton,
- MessageCollector,
- MessageEmbed,
- MessageSelectMenu,
- ReactionCollector,
- Util
- } = await import('discord.js'),
- { Canvas } = await import('canvas');
+ roles = message.guild?.roles;
/* eslint-enable @typescript-eslint/no-unused-vars */
const inputJS = await util.inspectCleanRedactCodeblock(code.js, 'js');
@@ -228,11 +228,13 @@ export default class EvalCommand extends BushCommand {
} else {
try {
await message.author.send({ embeds: [embed] });
- if (!args.deleteMSG) await (message as BushMessage).react(emojis.successFull);
+ if (!args.deleteMSG) await message.react(emojis.successFull);
} catch {
- if (!args.deleteMSG) await (message as BushMessage).react(emojis.errorFull);
+ if (!args.deleteMSG) await message.react(emojis.errorFull);
}
}
- if (args.deleteMSG && (message as BushMessage).deletable) await (message as BushMessage).delete();
+ if (args.deleteMSG && 'deletable' in message && message.deletable) await message.delete();
}
}
+
+/** @typedef {ActivePunishment|Global|Guild|Level|ModLog|StickyRole|ButtonInteraction|Collection|Collector|CommandInteraction|ContextMenuInteraction|DMChannel|Emoji|Interaction|InteractionCollector|Message|MessageActionRow|MessageAttachment|MessageButton|MessageCollector|MessageSelectMenu|ReactionCollector|Util|Canvas} VSCodePleaseDontRemove */
diff --git a/src/commands/dev/javascript.ts b/src/commands/dev/javascript.ts
index a5f90cb..8c5dcb4 100644
--- a/src/commands/dev/javascript.ts
+++ b/src/commands/dev/javascript.ts
@@ -17,8 +17,7 @@ export default class JavascriptCommand extends BushCommand {
match: 'rest',
prompt: 'What code would you like to run in a sand boxed environment?',
retry: '{error} Invalid code to run in a sand boxed environment.',
- slashType: 'STRING',
- only: 'slash'
+ slashType: 'STRING'
},
{
id: 'sel_depth',
@@ -30,15 +29,6 @@ export default class JavascriptCommand extends BushCommand {
prompt: 'How deep would you like to inspect the output?',
slashType: 'INTEGER',
optional: true
- },
- {
- id: 'code',
- description: 'The code you would like to run in a sand boxed environment.',
- match: 'rest',
- prompt: 'What code would you like to run in a sand boxed environment?',
- retry: '{error} Invalid code to run in a sand boxed environment.',
- slashType: 'STRING',
- only: 'text'
}
],
slash: true,
diff --git a/src/commands/info/color.ts b/src/commands/info/color.ts
index 7f3e593..2b8ba9c 100644
--- a/src/commands/info/color.ts
+++ b/src/commands/info/color.ts
@@ -52,7 +52,7 @@ export default class ColorCommand extends BushCommand {
args: { color: string | ArgType<'role'> | ArgType<'member'> }
) {
const _color = message.util.isSlashMessage(message)
- ? ((await util.arg.cast(util.arg.union(isValidTinyColor as any, 'role', 'member'), message, args.color as string)) as
+ ? ((await util.arg.cast(util.arg.union(isValidTinyColor, 'role', 'member'), message, args.color as string)) as
| string
| BushRole
| BushGuildMember)
diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts
index e1e9844..c4abf78 100644
--- a/src/commands/info/help.ts
+++ b/src/commands/info/help.ts
@@ -1,5 +1,6 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
-import { MessageActionRow, MessageButton, MessageEmbed } from 'discord.js';
+import { AutocompleteInteraction, MessageActionRow, MessageButton, MessageEmbed } from 'discord.js';
+import Fuse from 'fuse.js';
import packageDotJSON from '../../../package.json' assert { type: 'json' };
export default class HelpCommand extends BushCommand {
@@ -19,7 +20,8 @@ export default class HelpCommand extends BushCommand {
prompt: 'What command do you need help with?',
retry: '{error} Choose a valid command to find help for.',
slashType: 'STRING',
- optional: true
+ optional: true,
+ autocomplete: true
},
{
id: 'showHidden',
@@ -49,7 +51,7 @@ export default class HelpCommand extends BushCommand {
const isSuperUser = client.isSuperUser(message.author);
const command = args.command
? typeof args.command === 'string'
- ? (client.commandHandler.findCommand(args.command) as BushCommand) ?? null
+ ? client.commandHandler.findCommand(args.command) ?? null
: args.command
: null;
if (!isOwner) args.showHidden = false;
@@ -150,4 +152,24 @@ export default class HelpCommand extends BushCommand {
return row;
}
+
+ public override autocomplete(interaction: AutocompleteInteraction) {
+ const aliases = this.handler.modules.map((module) => module.aliases).flat();
+
+ const fuzzy = new Fuse(aliases, {
+ threshold: 0.5,
+ isCaseSensitive: false,
+ findAllMatches: true
+ }).search(interaction.options.getFocused().toString());
+
+ const res = fuzzy.slice(0, fuzzy.length >= 25 ? 25 : undefined).map((v) => ({ name: v.item, value: v.item }));
+
+ const startingCommands = [
+ ...this.handler.modules.filter((command) => !command.ownerOnly && !command.hidden && !command.pseudo).keys()
+ ]
+ .slice(0, 25)
+ .map((v) => ({ name: v, value: v }));
+
+ void interaction.respond(res.length ? res : startingCommands);
+ }
}
diff --git a/src/commands/moulberry-bush/capes.ts b/src/commands/moulberry-bush/capes.ts
index 4bdb360..ab6910a 100644
--- a/src/commands/moulberry-bush/capes.ts
+++ b/src/commands/moulberry-bush/capes.ts
@@ -1,5 +1,6 @@
import { BushCommand, ButtonPaginator, DeleteButton, type BushMessage, type OptionalArgType } from '#lib';
-import { type MessageEmbedOptions } from 'discord.js';
+import { AutocompleteInteraction, type MessageEmbedOptions } from 'discord.js';
+import Fuse from 'fuse.js';
import got from 'got';
export default class CapesCommand extends BushCommand {
@@ -18,8 +19,8 @@ export default class CapesCommand extends BushCommand {
prompt: 'What cape would you like to see?',
retry: '{error} Choose a cape to see.',
optional: true,
- slashType: 'STRING'
- // choices: client.consts.mappings.capes.map((v) => ({ name: v.name, value: v.name }))
+ slashType: 'STRING',
+ autocomplete: true
}
],
slash: true,
@@ -96,6 +97,20 @@ export default class CapesCommand extends BushCommand {
description: cape.purchasable ? ':money_with_wings: **purchasable** :money_with_wings:' : undefined
};
}
+
+ public override autocomplete(interaction: AutocompleteInteraction) {
+ const capes = client.consts.mappings.capes.map((v) => v.name);
+
+ const fuzzy = new Fuse(capes, {
+ threshold: 0.5,
+ isCaseSensitive: false,
+ findAllMatches: true
+ }).search(interaction.options.getFocused().toString());
+
+ const res = fuzzy.slice(0, fuzzy.length >= 25 ? 25 : undefined).map((v) => ({ name: v.item, value: v.item }));
+
+ void interaction.respond(res);
+ }
}
export interface GithubFile {
diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts
index ab2632c..28483a4 100644
--- a/src/commands/moulberry-bush/rule.ts
+++ b/src/commands/moulberry-bush/rule.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, type BushMessage, type OptionalArgType } from '#lib';
+import { AllowedMentions, BushCommand, BushSlashMessage, type BushMessage, type OptionalArgType } from '#lib';
import { MessageEmbed } from 'discord.js';
const rules = [
@@ -92,7 +92,7 @@ export default class RuleCommand extends BushCommand {
}
public override async exec(
- message: BushMessage,
+ message: BushMessage | BushSlashMessage,
{ rule, user }: { rule: OptionalArgType<'integer'>; user: OptionalArgType<'user'> }
) {
const rulesEmbed = new MessageEmbed()
@@ -114,35 +114,18 @@ export default class RuleCommand extends BushCommand {
if (rules[i]?.title && rules[i]?.description) rulesEmbed.addField(rules[i].title, rules[i].description);
}
}
- await respond();
+ await message.util.send({
+ content: user ? `<@${user.id}>` : undefined,
+ embeds: [rulesEmbed],
+ allowedMentions: AllowedMentions.users(),
+ // If the original message was a reply -> imitate it
+ reply:
+ !message.util.isSlashMessage(message) && message.reference?.messageId
+ ? { messageReference: message.reference.messageId }
+ : undefined
+ });
if (!message.util.isSlash) {
await message.delete().catch(() => {});
}
- return;
- async function respond() {
- if (!user) {
- return (
- // If the original message was a reply -> imitate it
- message.reference?.messageId && !message.util.isSlash
- ? await message.channel.messages.fetch(message.reference.messageId).then(async (message) => {
- await message.reply({ embeds: [rulesEmbed], allowedMentions: AllowedMentions.users() });
- })
- : await message.util.send({ embeds: [rulesEmbed], allowedMentions: AllowedMentions.users() })
- );
- } else {
- return message.reference?.messageId && !message.util.isSlash
- ? await message.util.send({
- content: `<@!${user.id}>`,
- embeds: [rulesEmbed],
- allowedMentions: AllowedMentions.users(),
- reply: { messageReference: message.reference.messageId }
- })
- : await message.util.send({
- content: `<@!${user.id}>`,
- embeds: [rulesEmbed],
- allowedMentions: AllowedMentions.users()
- });
- }
- }
}
}
diff --git a/src/commands/utilities/activity.ts b/src/commands/utilities/activity.ts
index 6801358..e1c2d88 100644
--- a/src/commands/utilities/activity.ts
+++ b/src/commands/utilities/activity.ts
@@ -70,24 +70,7 @@ const activityTypeCaster = (_message: Message | BushMessage | BushSlashMessage,
export default class YouTubeCommand extends BushCommand {
constructor() {
super('activity', {
- aliases: [
- 'activity',
- 'yt',
- 'youtube',
- 'chess',
- 'park',
- 'poker',
- 'fish',
- 'fishing',
- 'fishington',
- 'betrayal',
- 'doodle-crew',
- 'doodle',
- 'wood-snacks',
- 'wood',
- 'letter-tile',
- 'letter'
- ],
+ aliases: Object.values(activityMap).flatMap((a) => a.aliases),
category: 'utilities',
description: 'Allows you to play discord activities in voice channels.',
usage: [
@@ -139,7 +122,7 @@ export default class YouTubeCommand extends BushCommand {
const target_application_id = message.util.isSlash ? args.activity : activityTypeCaster(message, args.activity);
let response: string;
- const invite = await (client as any).api
+ const invite = await (<any>client).api
.channels(channel.id)
.invites.post({
data: {
@@ -152,7 +135,7 @@ export default class YouTubeCommand extends BushCommand {
}
})
.catch((e: Error | DiscordAPIError) => {
- if ((e as DiscordAPIError).code === 50013) {
+ if ((e as DiscordAPIError)?.code === 50013) {
response = `${util.emojis.error} I am missing permissions to make an invite in that channel.`;
return;
} else response = `${util.emojis.error} An error occurred while generating your invite: ${e?.message ?? e}`;
diff --git a/src/commands/utilities/price.ts b/src/commands/utilities/price.ts
index 16dd327..e2cb837 100644
--- a/src/commands/utilities/price.ts
+++ b/src/commands/utilities/price.ts
@@ -1,9 +1,11 @@
import { BushCommand, type BushMessage } from '#lib';
-import { MessageEmbed } from 'discord.js';
+import { AutocompleteInteraction, MessageEmbed } from 'discord.js';
import Fuse from 'fuse.js';
import got from 'got';
export default class PriceCommand extends BushCommand {
+ public static cachedItemList: string[] = [];
+
public constructor() {
super('price', {
aliases: ['price'],
@@ -19,7 +21,8 @@ export default class PriceCommand extends BushCommand {
match: 'content',
prompt: 'What item would you like to find the price of?',
retry: '{error} Choose a valid item.',
- slashType: 'STRING'
+ slashType: 'STRING',
+ autocomplete: true
},
{
id: 'strict',
@@ -40,14 +43,14 @@ export default class PriceCommand extends BushCommand {
public override async exec(message: BushMessage, { item, strict }: { item: string; strict: boolean }) {
if (message.util.isSlashMessage(message)) await message.interaction.deferReply();
- const errors = new Array<string>();
+ const errors: string[] = [];
//prettier-ignore
const [bazaar, currentLowestBIN, averageLowestBIN, auctionAverages] = (await Promise.all([
- got.get('https://api.hypixel.net/skyblock/bazaar').json().catch(() => errors.push('bazaar')),
- got.get('https://moulberry.codes/lowestbin.json').json().catch(() => errors.push('current lowest BIN')),
- got.get('https://moulberry.codes/auction_averages_lbin/3day.json').json().catch(() => errors.push('average Lowest BIN')),
- got.get('https://moulberry.codes/auction_averages/3day.json').json().catch(() => errors.push('auction average'))
+ got.get('https://api.hypixel.net/skyblock/bazaar').json().catch(() => { errors.push('bazaar') }),
+ got.get('https://moulberry.codes/lowestbin.json').json().catch(() => { errors.push('current lowest BIN') }),
+ got.get('https://moulberry.codes/auction_averages_lbin/3day.json').json().catch(() => { errors.push('average Lowest BIN') }),
+ got.get('https://moulberry.codes/auction_averages/3day.json').json().catch(() => { errors.push('auction average') })
])) as [Bazaar, LowestBIN, LowestBIN, AuctionAverages];
let parsedItem = item.toString().toUpperCase().replace(/ /g, '_').replace(/'S/g, '');
@@ -61,10 +64,10 @@ export default class PriceCommand extends BushCommand {
// create a set from all the item names so that there are no duplicates for the fuzzy search
const itemNames = new Set([
- ...Object.keys(averageLowestBIN || {}),
- ...Object.keys(currentLowestBIN || {}),
- ...Object.keys(auctionAverages || {}),
- ...Object.keys(bazaar?.products || {})
+ ...Object.keys(averageLowestBIN ?? {}),
+ ...Object.keys(currentLowestBIN ?? {}),
+ ...Object.keys(auctionAverages ?? {}),
+ ...Object.keys(bazaar?.products ?? {})
]);
// fuzzy search
@@ -132,15 +135,27 @@ export default class PriceCommand extends BushCommand {
priceEmbed.addField(name, price.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 }));
}
}
+
+ public override autocomplete(interaction: AutocompleteInteraction) {
+ const fuzzy = new Fuse(PriceCommand.cachedItemList, {
+ threshold: 0.5,
+ isCaseSensitive: false,
+ findAllMatches: true
+ }).search(interaction.options.getFocused().toString());
+
+ const res = fuzzy.slice(0, fuzzy.length >= 25 ? 25 : undefined).map((v) => ({ name: v.item, value: v.item }));
+
+ void interaction.respond(res);
+ }
}
-interface Summary {
+export interface Summary {
amount: number;
pricePerUnit: number;
orders: number;
}
-interface Bazaar {
+export interface Bazaar {
success: boolean;
lastUpdated: number;
products: {
@@ -163,11 +178,11 @@ interface Bazaar {
};
}
-interface LowestBIN {
+export interface LowestBIN {
[key: string]: number;
}
-interface AuctionAverages {
+export interface AuctionAverages {
[key: string]: {
price?: number;
count?: number;
diff --git a/src/commands/utilities/suicide.ts b/src/commands/utilities/suicide.ts
index f0d75a2..b347f9c 100644
--- a/src/commands/utilities/suicide.ts
+++ b/src/commands/utilities/suicide.ts
@@ -1,5 +1,5 @@
import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
-import { MessageEmbed, type Message } from 'discord.js';
+import { MessageEmbed } from 'discord.js';
export default class TemplateCommand extends BushCommand {
public constructor() {
@@ -44,17 +44,14 @@ export default class TemplateCommand extends BushCommand {
].join('\n')
);
- return (
+ return message.util.send({
+ embeds: [suicideEmbed],
+ allowedMentions: AllowedMentions.users(),
// If the original message was a reply -> imitate it
- !message.util.isSlashMessage(message) && (message as Message).reference?.messageId && message.guild && message.channel
- ? await message.channel.messages.fetch((message as Message).reference!.messageId!).then(async (message1) => {
- await message1.reply({
- embeds: [suicideEmbed],
- allowedMentions: AllowedMentions.users(),
- target: message1
- });
- })
- : await message.util.send({ embeds: [suicideEmbed], allowedMentions: AllowedMentions.users() })
- );
+ reply:
+ !message.util.isSlashMessage(message) && message.reference?.messageId
+ ? { messageReference: message.reference.messageId }
+ : undefined
+ });
}
}
diff --git a/src/commands/utilities/wolframAlpha.ts b/src/commands/utilities/wolframAlpha.ts
index 705e157..faf575c 100644
--- a/src/commands/utilities/wolframAlpha.ts
+++ b/src/commands/utilities/wolframAlpha.ts
@@ -18,8 +18,7 @@ export default class WolframAlphaCommand extends BushCommand {
match: 'rest',
prompt: 'What would you like to look up?',
retry: '{error} Pick something to look up.',
- slashType: 'STRING',
- only: 'slash'
+ slashType: 'STRING'
},
{
id: 'image',
@@ -29,16 +28,6 @@ export default class WolframAlphaCommand extends BushCommand {
prompt: 'Would you like to use the Simple API instead of the Short Answers API?',
slashType: 'BOOLEAN',
optional: true
- },
- {
- id: 'expression',
- description: 'The expression to query the Wolfram|Alpha api for.',
- type: 'string',
- match: 'rest',
- prompt: 'What would you like to look up?',
- retry: '{error} Pick something to look up.',
- slashType: 'STRING',
- only: 'text'
}
],
slash: true,
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index 30cc83f..47a3717 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -801,6 +801,8 @@ export class BushClientUtil extends ClientUtil {
: message.util.parsed?.prefix ?? client.config.prefix;
}
+ // public retryAsync<P extends [], R>(func: (...args: P) => R, repeatFreq: number, numRepeat: number): R | Promise<null> {}
+
/**
* Recursively apply provided options operations on object
* and all of the object properties that are either object or function.
diff --git a/src/lib/extensions/discord-akairo/BushCommandHandler.ts b/src/lib/extensions/discord-akairo/BushCommandHandler.ts
index a5aabb1..6c06c5b 100644
--- a/src/lib/extensions/discord-akairo/BushCommandHandler.ts
+++ b/src/lib/extensions/discord-akairo/BushCommandHandler.ts
@@ -41,3 +41,7 @@ export class BushCommandHandler extends CommandHandler {
super(client, options);
}
}
+
+export interface BushCommandHandler extends CommandHandler {
+ findCommand(name: string): BushCommand;
+}
diff --git a/src/lib/extensions/discord-akairo/BushCommandUtil.ts b/src/lib/extensions/discord-akairo/BushCommandUtil.ts
index f7dd631..7a06b35 100644
--- a/src/lib/extensions/discord-akairo/BushCommandUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushCommandUtil.ts
@@ -16,3 +16,7 @@ export class BushCommandUtil<BushMessageType extends BushMessage | BushSlashMess
super(handler, message);
}
}
+
+export interface BushCommandUtil<BushMessageType extends BushMessage | BushSlashMessage> extends CommandUtil<BushMessageType> {
+ isSlashMessage(message: BushMessage | BushSlashMessage): message is BushSlashMessage;
+}
diff --git a/src/listeners/bush/nameAutoBan.ts b/src/listeners/bush/nameAutoBan.ts
index dd702a5..0466ff0 100644
--- a/src/listeners/bush/nameAutoBan.ts
+++ b/src/listeners/bush/nameAutoBan.ts
@@ -1,12 +1,11 @@
import { AllowedMentions, BushListener, BushTextChannel, type BushClientEvents } from '#lib';
-import moment from 'moment';
export default class NameAutoBanListener extends BushListener {
public constructor() {
super('nameAutoBan', {
emitter: 'client',
event: 'guildMemberAdd',
- category: 'guild'
+ category: 'bush'
});
}
@@ -16,13 +15,6 @@ export default class NameAutoBanListener extends BushListener {
const guild = member.guild;
if (member.user.username === 'NotEnoughUpdates') {
- if (moment(member.user.createdAt).isBefore(moment().subtract(7, 'days'))) {
- return client.console.warn(
- 'nameAutoBan',
- `<<${member.user.tag}>> has not been banned because their account is older than 7 days.`
- );
- }
-
const res = await member.bushBan({
reason: "[AutoBan] 'NotEnoughUpdates' is a blacklisted name for this server.",
moderator: member.guild.me!
@@ -35,19 +27,21 @@ export default class NameAutoBanListener extends BushListener {
);
}
- await guild.sendLogChannel('automod', {
- embeds: [
- {
- title: 'Name Auto Ban',
- description: `**User:** ${member.user} (${member.user.tag})\n **Action:** Banned for using the blacklisted name 'NotEnoughUpdates'.`,
- color: client.consts.colors.red,
- author: {
- name: member.user.tag,
- iconURL: member.displayAvatarURL({ dynamic: true })
+ await guild
+ .sendLogChannel('automod', {
+ embeds: [
+ {
+ title: 'Name Auto Ban',
+ description: `**User:** ${member.user} (${member.user.tag})\n **Action:** Banned for using the blacklisted name 'NotEnoughUpdates'.`,
+ color: client.consts.colors.red,
+ author: {
+ name: member.user.tag,
+ iconURL: member.displayAvatarURL({ dynamic: true })
+ }
}
- }
- ]
- });
+ ]
+ })
+ .catch(() => {});
const content =
res === 'failed to dm'
diff --git a/src/listeners/commands/commandCooldown.ts b/src/listeners/commands/commandCooldown.ts
index 74f6a47..92b0abe 100644
--- a/src/listeners/commands/commandCooldown.ts
+++ b/src/listeners/commands/commandCooldown.ts
@@ -1,4 +1,4 @@
-import { BushListener, type BushCommandHandlerEvents, type BushMessage } from '#lib';
+import { BushListener, type BushCommandHandlerEvents } from '#lib';
export default class CommandCooldownListener extends BushListener {
public constructor() {
@@ -21,6 +21,6 @@ export default class CommandCooldownListener extends BushListener {
content: `⏳ This command is on cooldown for ${Math.round(remaining / 1000)} seconds.`,
ephemeral: true
})
- : await (message as BushMessage).react('⏳').catch(() => null);
+ : await message.react('⏳').catch(() => null);
}
}
diff --git a/src/tasks/updatePriceItemCache.ts b/src/tasks/updatePriceItemCache.ts
new file mode 100644
index 0000000..096354b
--- /dev/null
+++ b/src/tasks/updatePriceItemCache.ts
@@ -0,0 +1,31 @@
+import { BushTask } from '#lib';
+import got from 'got';
+import PriceCommand, { AuctionAverages, Bazaar, LowestBIN } from '../commands/utilities/price.js';
+
+export default class UpdatePriceItemCache extends BushTask {
+ public constructor() {
+ super('updatePriceItemCache', {
+ delay: 600_000, // 10 minutes
+ runOnStart: true
+ });
+ }
+
+ public override async exec() {
+ //prettier-ignore
+ const [bazaar, currentLowestBIN, averageLowestBIN, auctionAverages] = (await Promise.all([
+ got.get('https://api.hypixel.net/skyblock/bazaar').json().catch(() => {}),
+ got.get('https://moulberry.codes/lowestbin.json').json().catch(() => {}),
+ got.get('https://moulberry.codes/auction_averages_lbin/3day.json').json().catch(() => {}),
+ got.get('https://moulberry.codes/auction_averages/3day.json').json().catch(() => {})
+ ])) as [Bazaar, LowestBIN, LowestBIN, AuctionAverages];
+
+ const itemNames = new Set([
+ ...Object.keys(averageLowestBIN ?? {}),
+ ...Object.keys(currentLowestBIN ?? {}),
+ ...Object.keys(auctionAverages ?? {}),
+ ...Object.keys(bazaar?.products ?? {})
+ ]);
+
+ PriceCommand.cachedItemList = [...itemNames];
+ }
+}
diff --git a/src/tasks/updateSuperUsers.ts b/src/tasks/updateSuperUsers.ts
index c0937dd..db8ff0a 100644
--- a/src/tasks/updateSuperUsers.ts
+++ b/src/tasks/updateSuperUsers.ts
@@ -4,7 +4,7 @@ import { Global } from '../lib/models/Global.js';
export default class UpdateSuperUsersTask extends BushTask {
public constructor() {
super('updateSuperUsers', {
- delay: 10_000,
+ delay: 10_000, // 10 seconds
runOnStart: true
});
}