Skip to content

Commit

Permalink
QOL Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlenVelocity committed Apr 22, 2021
1 parent 89d4513 commit a9175d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions src/Handler/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Message {
const username = user?.notify || user?.vname || user?.name || ''
const { body, media } = this.getBase(M, message)

if (group.data.mod && !admin && iAdmin && !this.moderate(M, body || '')) return void null
if (group.data.mod && !admin && iAdmin && !await this.moderate(M, body || '', group.metadata, username)) return void null
if (group.data.safe && !admin && iAdmin && (await this.checkMessageandAct(M, username, group.metadata)))
return void null
if (!body) return
Expand Down Expand Up @@ -372,10 +372,18 @@ export class Message {
return false
}

moderate = (M: WAMessage, text: string): boolean => {
moderate = async (M: WAMessage, text: string, metadata: WAGroupMetadata, username: string): Promise<boolean> => {
if (this.checkForGroupLink(text)) {
this.client.reply(M.key.remoteJid as string, { body: responses['mod']['group-invite'] }, M)
this.client.groupRemove(M.key.remoteJid as string, [M.participant])
await this.client.reply(M.key.remoteJid as string, { body: responses['mod']['group-invite'] }, M)
await this.client.groupRemove(M.key.remoteJid as string, [M.participant])
console.log(
chalk.redBright('[MOD] GROUP LINK'),
chalk.yellow(moment((M.messageTimestamp as number) * 1000).format('DD/MM HH:mm:ss')),
'By',
chalk.red(username),
'in',
chalk.red(metadata.subject)
)
return false
}
return true
Expand Down
2 changes: 1 addition & 1 deletion src/lib/responses.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"not-owner": "The user of this command must be the owner of thr group",
"lyrics": "🔍 *Search Term:* {T}\n\n🎋 *Fetched Lyrics:* \n{L}",
"mod": {
"group-invite": "❌ *[Mod]* Group Link Detected! Removing..."
"group-invite": "❌ *[MOD]* Group Invite Link Detected! Removing..."
},
"warinings":{
"purge": "Are you sure? This command will kick everyone from thr group. Use this command again if this is what you want.",
Expand Down

0 comments on commit a9175d4

Please sign in to comment.