case 'tagall':
case 'marcar': {
if (!isGroup) return reply(resposta.group)
if (!isGroupAdmins) return reply(resposta.adm)
let metadata = await client.groupMetadata(from)
let tall = `
👥 MARCANDEIROS DO GRUPO 👥
Claro! Aqui está o código organizado para melhor legibilidade e estrutura. As partes semelhantes foram agrupadas e a formatação foi melhorada:
javascript
// Mensagem de botão para anti-sticker
const createButtonMessage02 = (pushname, groupName, isAntiSticker, buttons02) => ({
text: `╭═─────═⌘═────═╮
👑 𝐀𝐍𝐓𝐈 STICKER 👑
𝐔𝐒𝐔Á𝐑𝐈𝐎: ${pushname}
𝐆𝐑𝐔𝐏𝐎: ${groupName}
╰═─────═⌘═────═╯`,
footer: `STATUS DO ANTI-STICKER AGORA: ${isAntiSticker ? 'ATIVADO' : 'DESATIVADO'}\n`,
buttons: buttons02,
headerType: 4,
contextInfo: { forwardingScore: 999, isForwarded: true }
});
// Envia a mensagem de anti-sticker
client.sendMessage(from, createButtonMessage02(pushname, groupName, isAntiSticker, buttons02), { quoted: info });
// Controle do comando antiimg
case 'antiimg':
if (!isGroup) return reply(resposta.grupo);
if (!isGroupAdmins) return reply(resposta.adm);
if (!isBotGroupAdmins) return reply(resposta.botadm);
const toggleAntiImg = Number(args[0]);
if (toggleAntiImg === 1) {
if (isAntiImg) return reply('Já está ativo.');
antiimg.push(from);
fs.writeFileSync('./arquivos/funções/antiimg.json', JSON.stringify(antiimg));
return reply('🎗 Ativou com sucesso o recurso de anti imagem nesse grupo 🎗');
}
if (toggleAntiImg === 0) {
if (!isAntiImg) return reply('Já está desativado.');
antiimg.splice(antiimg.indexOf(from), 1); // Correcao para remover o grupo correto
fs.writeFileSync('./arquivos/funções/antiimg.json', JSON.stringify(antiimg));
return reply('🎗 Desativou com sucesso o recurso de anti imagem nesse grupo 🎗');
}
// Criação da mensagem de estado do anti-imagem
const buttons002 = [{
buttonId: `${prefix + command} ${isAntiImg ? 0 : 1}`,
buttonText: { displayText: `[🎗] ${isAntiImg ? 'DESATIVAR' : 'ATIVAR'} [🎗]` },
type: 1
}];
const buttonMessage02 = {
text: `╭═─────═⌘═────═╮
👑 𝐀𝐍𝐓𝐈 𝐈𝐌𝐀𝐆𝐄𝐌 👑
𝐔𝐒𝐔Á𝐑𝐈𝐎: ${pushname}
𝐆𝐑𝐔𝐏𝐎: ${groupName}
╰═─────═⌘═────═╯`,
footer: `STATUS DO ANTI-IMG AGORA: ${isAntiImg ? 'ATIVADO' : 'DESATIVADO'}\n`,
buttons: buttons002,
headerType: 4,
contextInfo: { forwardingScore: 999, isForwarded: true }
};
// Envia a mensagem de anti-imagem
client.sendMessage(from, buttonMessage02, { quoted: info });
break;
// Comando para marcar todos os usuários
case 'tagall':
case 'marcar': {
if (!isGroup) return reply(resposta.group);
if (!isGroupAdmins) return reply(resposta.adm);
let metadata = await client.groupMetadata(from);
let tall = `👥 *MARCANDEIROS DO GRUPO* 👥`;
// Lógica para marcar todos os usuários aqui
}
Alterações Realizadas:
Declaração de Função: Criei uma função createButtonMessage02 para evitar repetição de código ao criar mensagens de botão.
Verificação e Resposta: Usei return nas respostas para interromper a execução após enviar uma mensagem, tornando o fluxo mais claro.
Remoção do Item: Corrigi a lógica ao remover o grupo da lista antiimg usando antiimg.indexOf(from) para garantir que o item correto seja removido.
Estrutura e Consistência: Melhorei a formatação geral para facilitar a leitura, como a indentação e a organização das variáveis.
Com essas alterações, o código deve ser mais fácil de entender e manter.