First iteration!

This commit is contained in:
Atridad Lahiji
2023-05-28 20:20:00 -06:00
commit 34100aac98
23 changed files with 1203 additions and 0 deletions

View File

@ -0,0 +1,23 @@
import type { ChatInputCommandDeniedPayload, Events } from '@sapphire/framework';
import { Listener, UserError } from '@sapphire/framework';
export class UserEvent extends Listener<typeof Events.ChatInputCommandDenied> {
public async run({ context, message: content }: UserError, { interaction }: ChatInputCommandDeniedPayload) {
// `context: { silent: true }` should make UserError silent:
// Use cases for this are for example permissions error when running the `eval` command.
if (Reflect.get(Object(context), 'silent')) return;
if (interaction.deferred || interaction.replied) {
return interaction.editReply({
content,
allowedMentions: { users: [interaction.user.id], roles: [] }
});
}
return interaction.reply({
content,
allowedMentions: { users: [interaction.user.id], roles: [] },
ephemeral: true
});
}
}

View File

@ -0,0 +1,14 @@
import { Listener, LogLevel, type ChatInputCommandSuccessPayload } from '@sapphire/framework';
import type { Logger } from '@sapphire/plugin-logger';
import { logSuccessCommand } from '../../../lib/utils';
export class UserListener extends Listener {
public run(payload: ChatInputCommandSuccessPayload) {
logSuccessCommand(payload);
}
public onLoad() {
this.enabled = (this.container.logger as Logger).level <= LogLevel.Debug;
return super.onLoad();
}
}

View File

@ -0,0 +1,23 @@
import type { ContextMenuCommandDeniedPayload, Events } from '@sapphire/framework';
import { Listener, UserError } from '@sapphire/framework';
export class UserEvent extends Listener<typeof Events.ContextMenuCommandDenied> {
public async run({ context, message: content }: UserError, { interaction }: ContextMenuCommandDeniedPayload) {
// `context: { silent: true }` should make UserError silent:
// Use cases for this are for example permissions error when running the `eval` command.
if (Reflect.get(Object(context), 'silent')) return;
if (interaction.deferred || interaction.replied) {
return interaction.editReply({
content,
allowedMentions: { users: [interaction.user.id], roles: [] }
});
}
return interaction.reply({
content,
allowedMentions: { users: [interaction.user.id], roles: [] },
ephemeral: true
});
}
}

View File

@ -0,0 +1,14 @@
import { Listener, LogLevel, type ContextMenuCommandSuccessPayload } from '@sapphire/framework';
import type { Logger } from '@sapphire/plugin-logger';
import { logSuccessCommand } from '../../../lib/utils';
export class UserListener extends Listener {
public run(payload: ContextMenuCommandSuccessPayload) {
logSuccessCommand(payload);
}
public onLoad() {
this.enabled = (this.container.logger as Logger).level <= LogLevel.Debug;
return super.onLoad();
}
}

View File

@ -0,0 +1,12 @@
import type { Events, MessageCommandDeniedPayload } from '@sapphire/framework';
import { Listener, type UserError } from '@sapphire/framework';
export class UserEvent extends Listener<typeof Events.MessageCommandDenied> {
public async run({ context, message: content }: UserError, { message }: MessageCommandDeniedPayload) {
// `context: { silent: true }` should make UserError silent:
// Use cases for this are for example permissions error when running the `eval` command.
if (Reflect.get(Object(context), 'silent')) return;
return message.reply({ content, allowedMentions: { users: [message.author.id], roles: [] } });
}
}

View File

@ -0,0 +1,15 @@
import type { MessageCommandSuccessPayload } from '@sapphire/framework';
import { Listener, LogLevel } from '@sapphire/framework';
import type { Logger } from '@sapphire/plugin-logger';
import { logSuccessCommand } from '../../../lib/utils';
export class UserEvent extends Listener {
public run(payload: MessageCommandSuccessPayload) {
logSuccessCommand(payload);
}
public onLoad() {
this.enabled = (this.container.logger as Logger).level <= LogLevel.Debug;
return super.onLoad();
}
}