Archived
beta1e - improved stability of system messages module
This commit is contained in:
1 parent
4b37c92781
commit
484be23d15
3 files changed
+10
-8
No files matched your search
+1
-1
@@ -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",
|
||||
|
||||
+3
-3
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<MessageEmbed | Message | void>*
|
||||
*/
|
||||
async send(
|
||||
type: MessageType,
|
||||
data?: SystemMessageData,
|
||||
interaction?: TextChannel | DMChannel | NewsChannel | CommandInteraction
|
||||
interaction?: Message | CommandInteraction
|
||||
): Promise<MessageEmbed | Message | void> {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user