Spaces:
Paused
Paused
Download src/plugin/block.js from arabdullah/ethix-md-user: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/arabdullah/ethix-md-user/resolve/main/src/plugin/block.js
- Command line
-
hf download hf://spaces/arabdullah/ethix-md-user/src/plugin/block.js
-
curl -L -o block.js https://huggingface.co/spaces/arabdullah/ethix-md-user/resolve/main/src/plugin/block.js
1.1 kB
| import config from '../../config.cjs'; | |
| const block = async (m, gss) => { | |
| try { | |
| const botNumber = await gss.decodeJid(gss.user.id); | |
| const isCreator = [botNumber, config.OWNER_NUMBER + '@s.whatsapp.net'].includes(m.sender); | |
| const prefix = config.PREFIX; | |
| const cmd = m.body.startsWith(prefix) ? m.body.slice(prefix.length).split(' ')[0].toLowerCase() : ''; | |
| const text = m.body.slice(prefix.length + cmd.length).trim(); | |
| const validCommands = ['block']; | |
| if (!validCommands.includes(cmd)) return; | |
| if (!isCreator) return m.reply("*📛 THIS IS AN OWNER COMMAND*"); | |
| let users = m.mentionedJid[0] ? m.mentionedJid[0] : m.quoted ? m.quoted.sender : text.replace(/[^0-9]/g, '') + '@s.whatsapp.net'; | |
| await gss.updateBlockStatus(users, 'block') | |
| .then((res) => m.reply(`Blocked ${users.split('@')[0]} successfully.`)) | |
| .catch((err) => m.reply(`Failed to block user: ${err}`)); | |
| } catch (error) { | |
| console.error('Error:', error); | |
| m.reply('An error occurred while processing the command.'); | |
| } | |
| }; | |
| export default block; | |