Archived
Info messages displayDetails and separated deleteTimeout
This commit is contained in:
1 parent
8398034a44
commit
1699174df9
2 files changed
+46
-16
No files matched your search
@@ -298,26 +298,34 @@ There are 4 information messages:
|
|||||||
- **PERMISSION** - "Insufficient permissions" message (sent when the caller doesn't have enough permissions)
|
- **PERMISSION** - "Insufficient permissions" message (sent when the caller doesn't have enough permissions)
|
||||||
- **NOT_FOUND** - "Command not found" message (sent when someone tries to call a command that does not exist)
|
- **NOT_FOUND** - "Command not found" message (sent when someone tries to call a command that does not exist)
|
||||||
|
|
||||||
Each of these messages can be customized with these properties:
|
Their configuration is stored in _messages.system_ property.
|
||||||
|
|
||||||
- **enabled** - _boolean_ - enables or disables the message
|
Each of these messages can be customized with these properties (\* - required):
|
||||||
- **title** - _string_ - title of the message
|
|
||||||
|
- **enabled\*** - _boolean_ - enables or disables the message
|
||||||
|
- **title\*** - _string_ - title of the message
|
||||||
- **bottomText** - _string_ - text below the title (also known as description)
|
- **bottomText** - _string_ - text below the title (also known as description)
|
||||||
- **accentColor** - _ColorResolvable_ - embed color
|
- **accentColor** - _ColorResolvable_ - embed color
|
||||||
|
- **displayDetails** - _boolean_ - whether to display additional informations
|
||||||
- **showTimestamp** - _boolean_ - whether to show date and time in the footer
|
- **showTimestamp** - _boolean_ - whether to show date and time in the footer
|
||||||
- **footer** - _string_ - message footer
|
- **footer** - _string_ - message footer
|
||||||
|
- **deleteTimeout** - _number_ - time (ms) after the message gets deleted
|
||||||
|
|
||||||
|
There is also a global _deleteTimeout_ property (_messages.system.deleteTimeout_)
|
||||||
|
|
||||||
## Help message
|
## Help message
|
||||||
|
|
||||||
You can customize the help message with these properties:
|
Its configuration is stored in _messages.help_ property.
|
||||||
|
|
||||||
- **enabled** - _boolean_ - enables or disables the message
|
You can customize the help message with these properties (\* - required):
|
||||||
- **title** - _string_ - title of the message
|
|
||||||
- **bottomText** - _string_ - text below the title (also known as description)
|
- **enabled\*** - _boolean_ - enables or disables the message
|
||||||
- **accentColor** - _ColorResolvable_ - embed color
|
- **title\*** - _string_ - title of the message
|
||||||
- **description** - _string_ - description shown in the message itself
|
- **bottomText\*** - _string_ - text below the title (also known as description)
|
||||||
- **usage** - _string_ - usage displayed in the message itself
|
- **accentColor\*** - _ColorResolvable_ - embed color
|
||||||
- **visible** - _boolean_ - whether to show the help command in the list
|
- **description\*** - _string_ - description shown in the message itself
|
||||||
|
- **usage\*** - _string_ - usage displayed in the message itself
|
||||||
|
- **visible\*** - _boolean_ - whether to show the help command in the list
|
||||||
|
|
||||||
# Issues
|
# Issues
|
||||||
|
|
||||||
|
|||||||
+27
-5
@@ -8,8 +8,10 @@ export interface SystemMessageAppearance {
|
|||||||
title: string;
|
title: string;
|
||||||
bottomText?: string;
|
bottomText?: string;
|
||||||
accentColor?: ColorResolvable;
|
accentColor?: ColorResolvable;
|
||||||
|
displayDetails?: boolean;
|
||||||
showTimestamp?: boolean;
|
showTimestamp?: boolean;
|
||||||
footer?: string;
|
footer?: string;
|
||||||
|
deleteTimeout?: number;
|
||||||
}
|
}
|
||||||
interface SystemMessageData {
|
interface SystemMessageData {
|
||||||
command?: Command;
|
command?: Command;
|
||||||
@@ -31,6 +33,7 @@ export class SystemMessageManager {
|
|||||||
title: "👮♂️ Insufficient permissions",
|
title: "👮♂️ Insufficient permissions",
|
||||||
bottomText: "You don't have enough permissions to run this command",
|
bottomText: "You don't have enough permissions to run this command",
|
||||||
accentColor: "#1d1dc4",
|
accentColor: "#1d1dc4",
|
||||||
|
displayDetails: true,
|
||||||
showTimestamp: true,
|
showTimestamp: true,
|
||||||
footer: botName,
|
footer: botName,
|
||||||
};
|
};
|
||||||
@@ -39,6 +42,7 @@ export class SystemMessageManager {
|
|||||||
title: "❌ An error occurred",
|
title: "❌ An error occurred",
|
||||||
bottomText: "Something went wrong while processing your request.",
|
bottomText: "Something went wrong while processing your request.",
|
||||||
accentColor: "#ff0000",
|
accentColor: "#ff0000",
|
||||||
|
displayDetails: true,
|
||||||
showTimestamp: true,
|
showTimestamp: true,
|
||||||
footer: botName,
|
footer: botName,
|
||||||
};
|
};
|
||||||
@@ -46,6 +50,7 @@ export class SystemMessageManager {
|
|||||||
enabled: true,
|
enabled: true,
|
||||||
title: "🔍 Command not found",
|
title: "🔍 Command not found",
|
||||||
accentColor: "#ff5500",
|
accentColor: "#ff5500",
|
||||||
|
displayDetails: true,
|
||||||
showTimestamp: true,
|
showTimestamp: true,
|
||||||
footer: botName,
|
footer: botName,
|
||||||
};
|
};
|
||||||
@@ -53,8 +58,10 @@ export class SystemMessageManager {
|
|||||||
enabled: true,
|
enabled: true,
|
||||||
title: "✅ Task completed successfully",
|
title: "✅ Task completed successfully",
|
||||||
accentColor: "#00ff00",
|
accentColor: "#00ff00",
|
||||||
|
displayDetails: true,
|
||||||
showTimestamp: true,
|
showTimestamp: true,
|
||||||
footer: botName,
|
footer: botName,
|
||||||
|
deleteTimeout: Infinity,
|
||||||
};
|
};
|
||||||
this.deleteTimeout = Infinity;
|
this.deleteTimeout = Infinity;
|
||||||
}
|
}
|
||||||
@@ -77,7 +84,7 @@ export class SystemMessageManager {
|
|||||||
embed.setColor(this[type].accentColor || "#000");
|
embed.setColor(this[type].accentColor || "#000");
|
||||||
if (this[type].showTimestamp) embed.setTimestamp();
|
if (this[type].showTimestamp) embed.setTimestamp();
|
||||||
if (this[type].footer) embed.setFooter(this[type].footer || "");
|
if (this[type].footer) embed.setFooter(this[type].footer || "");
|
||||||
if (data) {
|
if (data && this[type].displayDetails) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "ERROR":
|
case "ERROR":
|
||||||
if (data.command) {
|
if (data.command) {
|
||||||
@@ -124,14 +131,29 @@ export class SystemMessageManager {
|
|||||||
}
|
}
|
||||||
if (interaction && !(interaction instanceof CommandInteraction)) {
|
if (interaction && !(interaction instanceof CommandInteraction)) {
|
||||||
const message = await interaction.reply({ embeds: [embed] });
|
const message = await interaction.reply({ embeds: [embed] });
|
||||||
if (this.deleteTimeout != Infinity && message.deletable) {
|
if (message.deletable) {
|
||||||
setTimeout(async () => {
|
if (Number.isFinite(this[type].deleteTimeout)) {
|
||||||
await message.delete();
|
setTimeout(async () => {
|
||||||
}, this.deleteTimeout || 0);
|
await message.delete().catch();
|
||||||
|
}, this[type].deleteTimeout);
|
||||||
|
} else if (this[type].deleteTimeout === undefined && Number.isFinite(this.deleteTimeout)) {
|
||||||
|
setTimeout(async () => {
|
||||||
|
await message.delete().catch();
|
||||||
|
}, this.deleteTimeout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
} else if (interaction && interaction instanceof CommandInteraction) {
|
} else if (interaction && interaction instanceof CommandInteraction) {
|
||||||
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)) {
|
||||||
|
setTimeout(async () => {
|
||||||
|
await interaction.deleteReply().catch();
|
||||||
|
}, this[type].deleteTimeout);
|
||||||
|
} else if (this[type].deleteTimeout === undefined && Number.isFinite(this.deleteTimeout)) {
|
||||||
|
setTimeout(async () => {
|
||||||
|
await interaction.deleteReply().catch();
|
||||||
|
}, this.deleteTimeout);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return embed;
|
return embed;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user