Archived
fixed not found message not firing and added some minor changes
This commit is contained in:
1 parent
3004787cf0
commit
1e2966dfa9
4 files changed
+21
-7
No files matched your search
@@ -3,7 +3,7 @@ import { CommandInteractionData } from "../types/commands.js";
|
|||||||
import { MessageCommand } from "../structures/MessageCommand.js";
|
import { MessageCommand } from "../structures/MessageCommand.js";
|
||||||
import { CommandManager } from "./CommandManager.js";
|
import { CommandManager } from "./CommandManager.js";
|
||||||
import { CommandNotFound } from "../errors.js";
|
import { CommandNotFound } from "../errors.js";
|
||||||
import { ObjectParameter, Parameter } from "../structures/Parameter.js";
|
import { Parameter, TargetParameter } from "../structures/Parameter.js";
|
||||||
|
|
||||||
export class MessageCommandManager extends CommandManager {
|
export class MessageCommandManager extends CommandManager {
|
||||||
protected readonly _list: MessageCommand[] = [];
|
protected readonly _list: MessageCommand[] = [];
|
||||||
@@ -31,7 +31,7 @@ export class MessageCommandManager extends CommandManager {
|
|||||||
optional: false,
|
optional: false,
|
||||||
type: "target",
|
type: "target",
|
||||||
});
|
});
|
||||||
const inputParameter = new ObjectParameter(parameter, i.targetId);
|
const inputParameter = new TargetParameter(parameter, i.targetId);
|
||||||
return {
|
return {
|
||||||
command: command,
|
command: command,
|
||||||
parameters: [inputParameter],
|
parameters: [inputParameter],
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { CommandInteraction, Message, MessageEmbed } from "discord.js";
|
import { Interaction, Message, MessageEmbed } from "discord.js";
|
||||||
import { SystemMessageAppearance, SystemMessageData, MessageType } from "../types/SystemMessage.js";
|
import { SystemMessageAppearance, SystemMessageData, MessageType } from "../types/SystemMessage.js";
|
||||||
|
|
||||||
export class SystemMessageManager {
|
export class SystemMessageManager {
|
||||||
@@ -78,7 +78,7 @@ export class SystemMessageManager {
|
|||||||
* @param {Message | CommandInteraction} [interaction] - if specified, the generated message will be sent in this channel
|
* @param {Message | CommandInteraction} [interaction] - if specified, the generated message will be sent in this channel
|
||||||
* @returns {Promise<MessageEmbed | Message | void>} A message that got sent or *void*
|
* @returns {Promise<MessageEmbed | Message | void>} A message that got sent or *void*
|
||||||
*/
|
*/
|
||||||
public async send(type: MessageType, data?: SystemMessageData, interaction?: Message | CommandInteraction): Promise<MessageEmbed | Message | void> {
|
public async send(type: MessageType, data?: SystemMessageData, interaction?: Message | Interaction): Promise<MessageEmbed | Message | void> {
|
||||||
if (this[type]) {
|
if (this[type]) {
|
||||||
if (this[type].enabled === false) {
|
if (this[type].enabled === false) {
|
||||||
return;
|
return;
|
||||||
@@ -134,7 +134,7 @@ export class SystemMessageManager {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (interaction && !(interaction instanceof CommandInteraction)) {
|
if (interaction && !(interaction instanceof Interaction)) {
|
||||||
const message = await interaction.reply({ embeds: [embed] });
|
const message = await interaction.reply({ embeds: [embed] });
|
||||||
if (message.deletable) {
|
if (message.deletable) {
|
||||||
if (Number.isFinite(this[type].deleteTimeout)) {
|
if (Number.isFinite(this[type].deleteTimeout)) {
|
||||||
@@ -148,7 +148,7 @@ export class SystemMessageManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
} else if (interaction && interaction instanceof CommandInteraction) {
|
} else if (interaction && interaction instanceof Interaction && (interaction.isCommand() || interaction.isContextMenu())) {
|
||||||
interaction.replied || interaction.deferred ? await interaction.editReply({ embeds: [embed] }) : await interaction.reply({ embeds: [embed] });
|
interaction.replied || interaction.deferred ? await interaction.editReply({ embeds: [embed] }) : await interaction.reply({ embeds: [embed] });
|
||||||
if (Number.isFinite(this[type].deleteTimeout)) {
|
if (Number.isFinite(this[type].deleteTimeout)) {
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ export class Bot extends EventEmitter {
|
|||||||
} else if (e instanceof OperationSuccess) {
|
} else if (e instanceof OperationSuccess) {
|
||||||
await this.messages.system.send("SUCCESS", undefined, i as CommandInteraction);
|
await this.messages.system.send("SUCCESS", undefined, i as CommandInteraction);
|
||||||
} else if (e instanceof CommandNotFound) {
|
} else if (e instanceof CommandNotFound) {
|
||||||
await this.messages.system.send("NOT_FOUND", { user: i.user, phrase: e.query });
|
await this.messages.system.send("NOT_FOUND", { user: i.user, phrase: e.query }, i);
|
||||||
} else {
|
} else {
|
||||||
await this.messages.system.send(
|
await this.messages.system.send(
|
||||||
"ERROR",
|
"ERROR",
|
||||||
|
|||||||
@@ -162,3 +162,17 @@ export class NullParameter extends InputParameter {
|
|||||||
super(parameter, null);
|
super(parameter, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class TargetParameter extends InputParameter {
|
||||||
|
constructor(parameter: Parameter, targetId: string) {
|
||||||
|
super(parameter, targetId);
|
||||||
|
}
|
||||||
|
|
||||||
|
toMessage(c: TextChannel) {
|
||||||
|
return c.messages.cache.get(this.value?.toString() || "");
|
||||||
|
}
|
||||||
|
|
||||||
|
async toUser(g: Guild) {
|
||||||
|
return await g.members.fetch({ query: this.value?.toString() });
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user