-
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.
- Loading branch information
1 parent
f0ca6de
commit 6ded404
Showing
8 changed files
with
130 additions
and
11 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
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
25 changes: 25 additions & 0 deletions
25
src/listeners/commands/messageCommands/messageCommandDenied.ts
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Events, MessageCommandDeniedPayload } from "@sapphire/framework"; | ||
import { Listener, UserError } from "@sapphire/framework"; | ||
|
||
/** | ||
* The "messageCommandDenied" event listener class. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
export class UserEvent extends Listener<typeof Events.MessageCommandDenied> { | ||
/** | ||
* Runs once the event is fired | ||
* | ||
* @param context The context that contains the user error | ||
* @param message The message that contains the payload | ||
* @since 1.0.0 | ||
*/ | ||
public override async run({ context, message: content }: UserError, { message }: MessageCommandDeniedPayload) { | ||
// If the error was marked as silent, do not reply | ||
if (Reflect.get(Object(context), "silent")) return; | ||
|
||
// Reply to the message with the user error | ||
return message.reply({ content, allowedMentions: { users: [message.author.id], roles: [] } }); | ||
} | ||
} | ||
|
30 changes: 30 additions & 0 deletions
30
src/listeners/commands/messageCommands/messageCommandSuccess.ts
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { MessageCommandSuccessPayload } from "@sapphire/framework"; | ||
import { Listener, LogLevel } from "@sapphire/framework"; | ||
import { Logger } from "@sapphire/plugin-logger"; | ||
import { logSuccessCommand } from "../../../lib/utils"; | ||
|
||
/** | ||
* The "messageCommandSuccess" event listener class. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
export class UserEvent extends Listener { | ||
/** | ||
* Runs once the event is fired. | ||
* | ||
* @param payload - The payload of the event. | ||
* @since 1.0.0 | ||
*/ | ||
public override run(payload: MessageCommandSuccessPayload): void { | ||
logSuccessCommand(payload); | ||
} | ||
|
||
/** | ||
* Runs when the listener is being loaded, it enables the listener only if the logger is set to debug level | ||
* @since 1.0.0 | ||
*/ | ||
public override onLoad(): unknown { | ||
this.enabled = (<Logger>this.container.logger).level <= LogLevel.Debug; | ||
return super.onLoad(); | ||
} | ||
} |
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