chore: Add type Context

This commit is contained in:
Siwoo Jeon 2025-03-08 18:22:32 +09:00
parent 34e9985bfd
commit 3202183d8e
Signed by: migan
GPG key ID: 036E9A8C5E8E48DA
4 changed files with 9 additions and 11 deletions

View file

@ -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<true> | ChatInputCommandInteraction<'cached'>,
) {
private async _run(ctx: Context) {
let userId: string
let username: string

View file

@ -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<true> | ChatInputCommandInteraction<'cached'>,
args?: Args,
) {
private async _run(ctx: Context, args?: Args) {
let command: string | undefined
let userId: string

View file

@ -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<true> | 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

3
src/lib/context.ts Normal file
View file

@ -0,0 +1,3 @@
import type { ChatInputCommandInteraction, Message } from 'discord.js'
export type Context = Message<true> | ChatInputCommandInteraction<'cached'>