-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(decorators): recreate using better code
- Loading branch information
1 parent
d9db85f
commit af331dd
Showing
17 changed files
with
363 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
import { Reflector } from "@nestjs/core"; | ||
import { SetMetadata, UseGuards, applyDecorators } from "@nestjs/common"; | ||
import { CommandConfigGuard } from "../guards"; | ||
|
||
export interface CommandConfigOptions { | ||
category: string; | ||
disable: boolean; | ||
} | ||
|
||
export const CommandConfig = Reflector.createDecorator<CommandConfigOptions>(); | ||
export const CommandConfigKey = "discord::command::__config__"; | ||
|
||
export const CommandConfig = (options: CommandConfigOptions) => { | ||
return applyDecorators( | ||
SetMetadata(CommandConfigKey, options), | ||
UseGuards(CommandConfigGuard), | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
import { Reflector } from "@nestjs/core"; | ||
import { PermissionResolvable } from "discord.js"; | ||
import { SetMetadata, UseGuards, applyDecorators } from "@nestjs/common"; | ||
import type { PermissionResolvable } from "discord.js"; | ||
import { CommandPermissionsGuard } from "../guards"; | ||
|
||
export interface CommandPermissionsOptions { | ||
user: PermissionResolvable[]; | ||
bot: PermissionResolvable[]; | ||
guildOnly: boolean; | ||
testOnly: boolean; | ||
ownerOnly: boolean; | ||
guilds?: string[]; | ||
guilds?: string[]; | ||
} | ||
|
||
export const CommandPermissions = Reflector.createDecorator<CommandPermissionsOptions>(); | ||
export const CommandPermissionsKey = "discord::command::__permissions__"; | ||
|
||
export const CommandPermissions = (options: CommandPermissionsOptions) => { | ||
return applyDecorators( | ||
SetMetadata(CommandPermissionsKey, options), | ||
UseGuards(CommandPermissionsGuard), | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
export { | ||
CommandPermissions, | ||
CommandPermissionsOptions, | ||
CommandPermissionsKey, | ||
} from "./CommandPermissions.decorator"; | ||
export { CommandConfig, CommandConfigOptions } from "./CommandConfig.decorator"; | ||
export { | ||
CommandConfig, | ||
CommandConfigOptions, | ||
CommandConfigKey, | ||
} from "./CommandConfig.decorator"; | ||
export { ValidatedOptions } from "./ValidatedOptions.decorator"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.