diff --git a/package.json b/package.json index 15e9287..7709bd5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "commandbot", - "version": "3.0.0-s-beta1d", + "version": "3.0.0-s-beta1e", "description": "A framework that helps you create your own Discord bot easier.", "main": "dist/cjs/index.js", "module": "dist/mjs/index.js", diff --git a/src/Bot.ts b/src/Bot.ts index c5ef511..a90059f 100644 --- a/src/Bot.ts +++ b/src/Bot.ts @@ -163,7 +163,7 @@ export class Bot extends EventEmitter { await this.messages.system.send( "NOT_FOUND", { phrase: m.content, user: m.member || undefined }, - m.channel as TextChannel + m ); } else { this.emit("MESSAGE", m); @@ -176,7 +176,7 @@ export class Bot extends EventEmitter { user: m.member || undefined, command: cmdMsg?.command, }, - m.channel as TextChannel + m ); } else { await this.messages.system.send( @@ -186,7 +186,7 @@ export class Bot extends EventEmitter { user: m.member || undefined, error: e, }, - m.channel as TextChannel + m ); console.error(e); } diff --git a/src/SystemMessage.ts b/src/SystemMessage.ts index a922454..2eb6a26 100644 --- a/src/SystemMessage.ts +++ b/src/SystemMessage.ts @@ -65,13 +65,13 @@ export class SystemMessageManager { * Generates and sends a system message * @param {MessageType} type - 'ERROR' | 'PERMISSION' | 'NOT_FOUND' * @param {SystemMessageData} [data] - additional data to include in the message - * @param {TextChannel | DMChannel | NewsChannel} [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* */ async send( type: MessageType, data?: SystemMessageData, - interaction?: TextChannel | DMChannel | NewsChannel | CommandInteraction + interaction?: Message | CommandInteraction ): Promise { if (this[type]) { if (this[type].enabled === false) { @@ -154,7 +154,7 @@ export class SystemMessageManager { } } if (interaction && !(interaction instanceof CommandInteraction)) { - const message = await interaction.send({ embeds: [embed] }); + const message = await interaction.reply({ embeds: [embed] }); if (this.deleteTimeout != Infinity && message.deletable) { setTimeout(async () => { await message.delete(); @@ -165,7 +165,9 @@ export class SystemMessageManager { interaction && interaction instanceof CommandInteraction ) { - interaction.reply({ embeds: [embed] }); + interaction.replied || interaction.deferred + ? await interaction.editReply({ embeds: [embed] }) + : await interaction.reply({ embeds: [embed] }); } else { return embed; }