aboutsummaryrefslogtreecommitdiff
path: root/src/commands/leveling
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-14 12:47:57 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-14 12:47:57 -0400
commit661e4c9935aeb8760dafc7ced4bbec6cc356a033 (patch)
treebb4c12bdef067d203f100e13e05ccb705b299834 /src/commands/leveling
parenteaf592b72eb5b1d66aa2bde5151a8947570a506c (diff)
downloadtanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.tar.gz
tanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.tar.bz2
tanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.zip
remove the war crimes that I previously committed
- Remove custom typings and replace with declaration merging - Fix the typings for args - Replace all discord-api-types imports with discord.js imports - Fix discord.js breaking changes
Diffstat (limited to 'src/commands/leveling')
-rw-r--r--src/commands/leveling/leaderboard.ts4
-rw-r--r--src/commands/leveling/level.ts16
-rw-r--r--src/commands/leveling/levelRoles.ts4
-rw-r--r--src/commands/leveling/setLevel.ts4
-rw-r--r--src/commands/leveling/setXp.ts4
5 files changed, 15 insertions, 17 deletions
diff --git a/src/commands/leveling/leaderboard.ts b/src/commands/leveling/leaderboard.ts
index f476ac1..040ed4a 100644
--- a/src/commands/leveling/leaderboard.ts
+++ b/src/commands/leveling/leaderboard.ts
@@ -1,4 +1,4 @@
-import { BushCommand, ButtonPaginator, Level, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, ButtonPaginator, Level, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
@@ -28,7 +28,7 @@ export default class LeaderboardCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { page: ArgType<'integer'> }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { page: OptArgType<'integer'> }) {
assert(message.inGuild());
if (!(await message.guild.hasFeature('leveling')))
diff --git a/src/commands/leveling/level.ts b/src/commands/leveling/level.ts
index 3a9a916..34a839a 100644
--- a/src/commands/leveling/level.ts
+++ b/src/commands/leveling/level.ts
@@ -3,16 +3,14 @@ import {
BushCommand,
CanvasProgressBar,
Level,
- type BushGuild,
- type BushMessage,
- type BushSlashMessage,
- type BushUser,
- type OptArgType
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
} from '#lib';
import { SimplifyNumber } from '@notenoughupdates/simplify-number';
import assert from 'assert';
import canvas from 'canvas';
-import { ApplicationCommandOptionType, Attachment, PermissionFlagsBits } from 'discord.js';
+import { ApplicationCommandOptionType, AttachmentBuilder, Guild, PermissionFlagsBits, User } from 'discord.js';
import got from 'got';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
@@ -46,7 +44,7 @@ export default class LevelCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { user: OptArgType<'user'> }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { user: OptArgType<'user'> }) {
assert(message.inGuild());
if (!(await message.guild.hasFeature('leveling')))
@@ -60,7 +58,7 @@ export default class LevelCommand extends BushCommand {
const user = args.user ?? message.author;
try {
return await message.util.reply({
- files: [new Attachment(await this.getImage(user, message.guild), 'level.png')]
+ files: [new AttachmentBuilder(await this.getImage(user, message.guild), { name: 'level.png' })]
});
} catch (e) {
if (e instanceof Error && e.message === 'User does not have a level') {
@@ -72,7 +70,7 @@ export default class LevelCommand extends BushCommand {
}
}
- private async getImage(user: BushUser, guild: BushGuild): Promise<Buffer> {
+ private async getImage(user: User, guild: Guild): Promise<Buffer> {
const guildRows = await Level.findAll({ where: { guild: guild.id } });
const rank = guildRows.sort((a, b) => b.xp - a.xp);
const userLevelRow = guildRows.find((a) => a.user === user.id);
diff --git a/src/commands/leveling/levelRoles.ts b/src/commands/leveling/levelRoles.ts
index 9fe7dd0..afa4ab6 100644
--- a/src/commands/leveling/levelRoles.ts
+++ b/src/commands/leveling/levelRoles.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptArgType } from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -39,7 +39,7 @@ export default class LevelRolesCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: { level: ArgType<'integer'>; role: OptArgType<'role'> }
) {
assert(message.inGuild());
diff --git a/src/commands/leveling/setLevel.ts b/src/commands/leveling/setLevel.ts
index ac7df57..8abdb57 100644
--- a/src/commands/leveling/setLevel.ts
+++ b/src/commands/leveling/setLevel.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, Level, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, Level, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -36,7 +36,7 @@ export default class SetLevelCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
{ user, level }: { user: ArgType<'user'>; level: ArgType<'integer'> }
) {
assert(message.inGuild());
diff --git a/src/commands/leveling/setXp.ts b/src/commands/leveling/setXp.ts
index 1f7c981..60e0b94 100644
--- a/src/commands/leveling/setXp.ts
+++ b/src/commands/leveling/setXp.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, Level, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, Level, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -37,7 +37,7 @@ export default class SetXpCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
{ user, xp }: { user: ArgType<'user'>; xp: ArgType<'abbreviatedNumber'> }
) {
assert(message.inGuild());