diff --git a/src/commands/dataLength.ts b/src/commands/dataLength.ts index ef7b5e5..08f0546 100644 --- a/src/commands/dataLength.ts +++ b/src/commands/dataLength.ts @@ -1,3 +1,4 @@ +import type { Context } from '../lib/context' import { Learn, Text } from '../lib/databases' import { ApplyOptions } from '@sapphire/decorators' import { Command } from '@sapphire/framework' @@ -33,9 +34,7 @@ export default class DataLengthCommand extends Command { return await this._run(interaction) } - private async _run( - ctx: Message | ChatInputCommandInteraction<'cached'>, - ) { + private async _run(ctx: Context) { let userId: string let username: string diff --git a/src/commands/deleteLearnedData.ts b/src/commands/deleteLearnedData.ts index 4dc3c87..633fca3 100644 --- a/src/commands/deleteLearnedData.ts +++ b/src/commands/deleteLearnedData.ts @@ -1,3 +1,4 @@ +import type { Context } from '../lib/context' import { MuffinCustomId } from '../lib/customId' import { Learn } from '../lib/databases' import { ApplyOptions } from '@sapphire/decorators' @@ -49,10 +50,7 @@ export default class DeleteLearnedData extends Command { return await this._run(interaction) } - private async _run( - ctx: Message | ChatInputCommandInteraction<'cached'>, - args?: Args, - ) { + private async _run(ctx: Context, args?: Args) { let command: string | undefined let userId: string diff --git a/src/commands/learn.ts b/src/commands/learn.ts index d50362c..f5c38db 100644 --- a/src/commands/learn.ts +++ b/src/commands/learn.ts @@ -1,3 +1,4 @@ +import type { Context } from '../lib/context' import { Learn } from '../lib/databases' import { ApplyOptions } from '@sapphire/decorators' import { Args, Command } from '@sapphire/framework' @@ -53,10 +54,7 @@ export default class LearnCommand extends Command { return await this._run(interaction) } - private async _run( - ctx: Message | ChatInputCommandInteraction<'cached'>, - args?: Args, - ) { + private async _run(ctx: Context, args?: Args) { const userId = ctx instanceof Message ? ctx.author.id : ctx.user.id let command: string | undefined let result: string | undefined diff --git a/src/lib/context.ts b/src/lib/context.ts new file mode 100644 index 0000000..3b27168 --- /dev/null +++ b/src/lib/context.ts @@ -0,0 +1,3 @@ +import type { ChatInputCommandInteraction, Message } from 'discord.js' + +export type Context = Message | ChatInputCommandInteraction<'cached'>