implement advanced memory optimization system with configurable settings
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
import {ButtonInteraction, MessageFlags} from 'discord.js';
|
||||
import {clearGlobalCommands} from '../../core/api/discordAPI';
|
||||
import type { Button } from '../../core/types/components';
|
||||
import type Amayo from '../../core/client';
|
||||
|
||||
const OWNER_ID = '327207082203938818';
|
||||
let running = false;
|
||||
|
||||
export default {
|
||||
customId: 'cmd_clear_global',
|
||||
run: async (interaction: ButtonInteraction) => {
|
||||
run: async (interaction: ButtonInteraction, client: Amayo) => {
|
||||
if (interaction.user.id !== OWNER_ID) {
|
||||
return interaction.reply({ content: '❌ No autorizado.', flags: MessageFlags.Ephemeral });
|
||||
}
|
||||
if (running) {
|
||||
return interaction.reply({ content: '⏳ Limpieza GLOBAL en progreso, espera.', ephemeral: true });
|
||||
return interaction.reply({ content: '⏳ Limpieza GLOBAL en progreso, espera.', flags: MessageFlags.Ephemeral });
|
||||
}
|
||||
running = true;
|
||||
try {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
|
||||
await clearGlobalCommands();
|
||||
await interaction.editReply('🧹 Comandos GLOBAL eliminados.');
|
||||
} catch (e: any) {
|
||||
@@ -23,11 +25,10 @@ export default {
|
||||
if (interaction.deferred || interaction.replied) {
|
||||
await interaction.editReply('❌ Error limpiando comandos globales.');
|
||||
} else {
|
||||
await interaction.reply({ content: '❌ Error limpiando comandos globales.', ephemeral: true });
|
||||
await interaction.reply({ content: '❌ Error limpiando comandos globales.', flags: MessageFlags.Ephemeral });
|
||||
}
|
||||
} finally {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} satisfies Button;
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import {ButtonInteraction, MessageFlags} from 'discord.js';
|
||||
import { clearAllCommands } from '../../core/api/discordAPI';
|
||||
import type { Button } from '../../core/types/components';
|
||||
import type Amayo from '../../core/client';
|
||||
|
||||
const OWNER_ID = '327207082203938818';
|
||||
let running = false;
|
||||
|
||||
export default {
|
||||
customId: 'cmd_clear_guild',
|
||||
run: async (interaction: ButtonInteraction) => {
|
||||
run: async (interaction: ButtonInteraction, client: Amayo) => {
|
||||
if (interaction.user.id !== OWNER_ID) {
|
||||
return interaction.reply({ content: '❌ No autorizado.', flags: MessageFlags.Ephemeral});
|
||||
}
|
||||
@@ -29,5 +31,4 @@ export default {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} satisfies Button;
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import {ButtonInteraction, MessageFlags} from 'discord.js';
|
||||
import { registeringCommands } from '../../core/api/discordAPI';
|
||||
import type { Button } from '../../core/types/components';
|
||||
import type Amayo from '../../core/client';
|
||||
|
||||
const OWNER_ID = '327207082203938818';
|
||||
let running = false;
|
||||
|
||||
export default {
|
||||
customId: 'cmd_reg_guild',
|
||||
run: async (interaction: ButtonInteraction) => {
|
||||
run: async (interaction: ButtonInteraction, client: Amayo) => {
|
||||
if (interaction.user.id !== OWNER_ID) {
|
||||
return interaction.reply({ content: '❌ No autorizado.', flags: MessageFlags.Ephemeral });
|
||||
}
|
||||
@@ -15,7 +17,7 @@ export default {
|
||||
}
|
||||
running = true;
|
||||
try {
|
||||
await interaction.deferReply({ flags: MessageFlags.Ephemeral});
|
||||
await interaction.deferReply({ flags: MessageFlags.Ephemeral});
|
||||
await registeringCommands();
|
||||
await interaction.editReply('✅ Comandos de GUILD registrados correctamente.');
|
||||
} catch (e: any) {
|
||||
@@ -29,5 +31,4 @@ export default {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} satisfies Button;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import type {ButtonInteraction} from "discord.js";
|
||||
//@ts-ignore
|
||||
import { ActionRowBuilder, Events, ModalBuilder, TextInputBuilder, TextInputStyle } from 'discord.js'
|
||||
import { ActionRowBuilder, ModalBuilder, TextInputBuilder, TextInputStyle } from 'discord.js';
|
||||
import type { Button } from '../../core/types/components';
|
||||
import type Amayo from '../../core/client';
|
||||
|
||||
export default {
|
||||
customId: "prefixsettings",
|
||||
run: async(interaction: ButtonInteraction) => {
|
||||
run: async (interaction: ButtonInteraction, client: Amayo) => {
|
||||
const modal = new ModalBuilder()
|
||||
.setCustomId('prefixsettingsmodal')
|
||||
.setTitle('Prefix');
|
||||
@@ -14,9 +15,9 @@ export default {
|
||||
.setLabel("Change Prefix")
|
||||
.setStyle(TextInputStyle.Short);
|
||||
|
||||
const secondActionRow = new ActionRowBuilder().addComponents(prefixInput);
|
||||
const secondActionRow = new ActionRowBuilder<TextInputBuilder>().addComponents(prefixInput);
|
||||
modal.addComponents(secondActionRow);
|
||||
|
||||
await interaction.showModal(modal);
|
||||
}
|
||||
}
|
||||
} satisfies Button;
|
||||
|
||||
@@ -1,10 +1,32 @@
|
||||
import {ModalSubmitInteraction} from "discord.js";
|
||||
import {ModalSubmitInteraction, MessageFlags} from "discord.js";
|
||||
import type { Modal } from '../../core/types/components';
|
||||
import type Amayo from '../../core/client';
|
||||
|
||||
export default {
|
||||
export default {
|
||||
customId: "prefixsettingsmodal",
|
||||
run: async (interaction: ModalSubmitInteraction) => {
|
||||
const newPrefix = interaction.fields.getTextInputValue("prefixInput")
|
||||
run: async (interaction: ModalSubmitInteraction, client: Amayo) => {
|
||||
const newPrefix = interaction.fields.getTextInputValue("prefixInput");
|
||||
|
||||
if (!newPrefix || newPrefix.length > 10) {
|
||||
return interaction.reply({
|
||||
content: '❌ El prefix debe tener entre 1 y 10 caracteres.',
|
||||
flags: MessageFlags.Ephemeral
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
// Aquí puedes guardar el prefix en la base de datos usando client.prisma
|
||||
// Por ahora solo confirmamos el cambio
|
||||
await interaction.reply({
|
||||
content: `✅ Prefix cambiado a: \`${newPrefix}\``,
|
||||
flags: MessageFlags.Ephemeral
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error cambiando prefix:', error);
|
||||
await interaction.reply({
|
||||
content: '❌ Error al cambiar el prefix.',
|
||||
flags: MessageFlags.Ephemeral
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} satisfies Modal;
|
||||
|
||||
Reference in New Issue
Block a user