diff --git a/mod.ts b/mod.ts index 0a9a01a..5df0bbb 100644 --- a/mod.ts +++ b/mod.ts @@ -180,7 +180,7 @@ export * from './src/cache/redis.ts' export { ColorUtil } from './src/utils/colorutil.ts' export type { Colors } from './src/utils/colorutil.ts' export { StoreChannel } from './src/structures/guildStoreChannel.ts' -export { StageVoiceChannel } from './src/structures/guildStageVoiceChannel.ts' +export { StageVoiceChannel } from './src/structures/guildVoiceStageChannel.ts' export { isCategoryChannel, isDMChannel, diff --git a/src/commands/client.ts b/src/commands/client.ts index b2dd693..22b0117 100644 --- a/src/commands/client.ts +++ b/src/commands/client.ts @@ -70,8 +70,6 @@ export class CommandClient extends Client implements CommandClientOptions { commands: CommandsManager = new CommandsManager(this) categories: CategoriesManager = new CategoriesManager(this) - _decoratedCommands?: { [name: string]: Command } - constructor(options: CommandClientOptions) { super(options) this.prefix = options.prefix @@ -116,11 +114,12 @@ export class CommandClient extends Client implements CommandClientOptions { this.caseSensitive = options.caseSensitive === undefined ? false : options.caseSensitive - if (this._decoratedCommands !== undefined) { - Object.values(this._decoratedCommands).forEach((entry) => { + const self = this as any + if (self._decoratedCommands !== undefined) { + Object.values(self._decoratedCommands).forEach((entry: any) => { this.commands.add(entry) }) - this._decoratedCommands = undefined + self._decoratedCommands = undefined } this.on( @@ -382,11 +381,11 @@ export class CommandClient extends Client implements CommandClientOptions { */ export function command(options?: CommandOptions) { return function (target: CommandClient | Extension, name: string) { - if (target._decoratedCommands === undefined) target._decoratedCommands = {} + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + const c = target as any + if (c._decoratedCommands === undefined) c._decoratedCommands = {} - const prop = ((target as unknown) as { - [name: string]: (ctx: CommandContext) => any - })[name] + const prop = c[name] if (typeof prop !== 'function') throw new Error('@command decorator can only be used on class methods') @@ -400,6 +399,6 @@ export function command(options?: CommandOptions) { if (target instanceof Extension) command.extension = target - target._decoratedCommands[command.name] = command + c._decoratedCommands[command.name] = command } } diff --git a/src/interactions/slashClient.ts b/src/interactions/slashClient.ts index e254c16..3c95c45 100644 --- a/src/interactions/slashClient.ts +++ b/src/interactions/slashClient.ts @@ -57,14 +57,6 @@ export class SlashClient extends HarmonyEventEmitter { modules: SlashModule[] = [] publicKey?: string - _decoratedSlash?: Array<{ - name: string - guild?: string - parent?: string - group?: string - handler: (interaction: Interaction) => any - }> - constructor(options: SlashOptions) { super() let id = options.id @@ -87,10 +79,11 @@ export class SlashClient extends HarmonyEventEmitter { }) } - if (this._decoratedSlash !== undefined) { - this._decoratedSlash.forEach((e) => { + const self = this as any + if (self._decoratedSlash !== undefined) { + self._decoratedSlash.forEach((e: any) => { e.handler = e.handler.bind(this.client) - this.handlers.push(e) + self.handlers.push(e) }) } diff --git a/src/structures/guildVoiceStageChannel.ts b/src/structures/guildVoiceStageChannel.ts new file mode 100644 index 0000000..67aa07a --- /dev/null +++ b/src/structures/guildVoiceStageChannel.ts @@ -0,0 +1,3 @@ +import { VoiceChannel } from './guildVoiceChannel.ts' + +export class StageVoiceChannel extends VoiceChannel { } \ No newline at end of file diff --git a/test/slash.ts b/test/slash.ts index 215cad0..ead5400 100644 --- a/test/slash.ts +++ b/test/slash.ts @@ -1,48 +1,42 @@ -import { - Client, - Intents, - event, - slash, - SlashCommandOptionType as Type -} from '../../mod.ts' -import { Interaction } from '../structures/slash.ts' +import { Client, Intents, event, slash } from '../mod.ts' +import { Interaction } from '../src/structures/slash.ts' import { TOKEN } from './config.ts' export class MyClient extends Client { @event() ready(): void { console.log(`Logged in as ${this.user?.tag}!`) - this.slash.commands.bulkEdit( - [ - { - name: 'test', - description: 'Test command.', - options: [ - { - name: 'user', - type: Type.USER, - description: 'User' - }, - { - name: 'role', - type: Type.ROLE, - description: 'Role' - }, - { - name: 'channel', - type: Type.CHANNEL, - description: 'Channel' - }, - { - name: 'string', - type: Type.STRING, - description: 'String' - } - ] - } - ], - '807935370556866560' - ) - this.slash.commands.bulkEdit([]) + // this.slash.commands.bulkEdit( + // [ + // { + // name: 'test', + // description: 'Test command.', + // options: [ + // { + // name: 'user', + // type: Type.USER, + // description: 'User' + // }, + // { + // name: 'role', + // type: Type.ROLE, + // description: 'Role' + // }, + // { + // name: 'channel', + // type: Type.CHANNEL, + // description: 'Channel' + // }, + // { + // name: 'string', + // type: Type.STRING, + // description: 'String' + // } + // ] + // } + // ], + // '807935370556866560' + // ) + // this.slash.commands.bulkEdit([]) } @slash() test(d: Interaction): void {