Skip to content

Commit

Permalink
𝑾𝒊𝒍𝒎𝒆𝒓 𝒐𝒇𝒄
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilsmac authored Sep 21, 2024
1 parent fddda99 commit c2923a6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions plugins/command-invalid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export async function before(m) {
if (!m.text || !global.prefix.test(m.text)) {
return;
}

const usedPrefix = global.prefix.exec(m.text)[0];
const command = m.text.slice(usedPrefix.length).trim().split(' ')[0].toLowerCase();

const validCommand = (command, plugins) => {
for (let plugin of Object.values(plugins)) {
if (plugin.command && (Array.isArray(plugin.command) ? plugin.command : [plugin.command]).includes(command)) {
return true;
}
}
return false;
};

if (validCommand(command, global.plugins)) {
let chat = global.db.data.chats[m.chat];
let user = global.db.data.users[m.sender];
if (chat.isBanned) return;
if (!user.commands) {
user.commands = 0;
}
user.commands += 1;
await conn.sendPresenceUpdate('composing', m.chat);
} else {
const comando = m.text.trim().split(' ')[0];
await m.reply(`El comando "${comando}" no existe.\nUsa */menu* para ver la lista de los comandos.`);
}
}

0 comments on commit c2923a6

Please sign in to comment.