Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroX11 committed Feb 14, 2025
1 parent a1a77ff commit 9a5185b
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 4 deletions.
4 changes: 2 additions & 2 deletions plugins/chats.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Module(
return await msg.reply(
directChats.map(
(data) =>
`*From:* ${data.name}\n*Messages:* ${data.messageCount}\n*Last Chat:* ${new Date(data.lastMessageTimestamp).toLocaleString()}\n\n`
`*From:* ${data.name}\n*Messages:* ${data.messageCount}\n*Last Chat:* ${new Date(data.lastMessageTimestamp).toLocaleString()}\n`
)
);
}
Expand All @@ -41,7 +41,7 @@ Module(
const data = await Promise.all(
groupChats.map(async (data) => {
const subject = (await groupMetadata(data.jid)).subject;
return `*From:* ${subject}\n*Messages:* ${data.messageCount}\n*LastMessage:* ${new Date(data.lastMessageTimestamp).toLocaleString()}\n\n`;
return `*From:* ${subject}\n*Messages:* ${data.messageCount}\n*LastMessage:* ${new Date(data.lastMessageTimestamp).toLocaleString()}\n`;
})
);
return await msg.reply(data);
Expand Down
43 changes: 43 additions & 0 deletions plugins/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Module, editConfig, getConfig } from '#src';

Module(
{
name: 'settings',
fromMe: true,
desc: 'Get Configurations setup',
type: 'settings',
},
async (msg) => {
const config = await getConfig();
const configs = [
'prefix',
'mode',
'autoRead',
'autoStatusRead',
'autolikestatus',
'disablegc',
'disabledm',
'cmdReact',
'cmdRead',
];

const data = configs
.map((key) => `${key}: ${Array.isArray(config[key]) ? config[key].join(', ') : config[key]}`)
.join('\n');
return await msg.reply(data);
}
);

Module(
{
name: 'setprefix',
fromMe: true,
desc: 'Manage bot handler',
type: 'settings',
},
async (msg, match) => {
if (!match) return msg.reply('provide new prefix!');
await editConfig({ prefix: [match] });
return await msg.reply('prefix updated!');
}
);
32 changes: 32 additions & 0 deletions plugins/whatsapp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Module } from '#src';

Module(
{
name: 'vv',
fromMe: false,
desc: 'forward a viewonce message',
type: 'whatsapp',
},
async (msg, match, { quoted }) => {
if (!quoted || !quoted.viewonce) {
return msg.reply('Reply viewonce');
}
quoted.message[quoted.type].viewOnce = false;
await msg.forward(msg.owner, quoted, { quoted: quoted });
return msg.reply('done');
}
);

Module(
{
name: 'waname',
fromMe: true,
desc: 'Updates your WA name',
type: 'whatsapp',
},
async (msg, match, { updateProfileName }) => {
if (!match) return msg.reply('provide new name');
await updateProfileName(match);
return msg.reply('done');
}
);
3 changes: 1 addition & 2 deletions src/client/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ export async function runCommand(message, client) {
for (const cmd of commands) {
const handler = message.prefix.find((p) => message.text.startsWith(p));
const match = message.text.slice(handler?.length || 0).match(cmd.name);
const mods = { ...message, ...client };
try {
if (handler && match) {
const args = match[2] ?? '';
await cmd.function(message, args, mods);
await cmd.function(message, args, { ...message, ...client });
}
} catch (err) {
await message.error(cmd, err);
Expand Down
6 changes: 6 additions & 0 deletions src/client/serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export async function serialize(message, client) {
},
/** @type string */
jid: message.key.remoteJid,
owner: toJid(client?.user?.id),
message: msg,
type: type,
device: getDevice(message?.key?.id),
Expand All @@ -86,6 +87,11 @@ export async function serialize(message, client) {
ban: bannedusers.includes(quoted.participant),
sudo: quoted.participant === owner || sudo.includes(quoted.participant),
text: qBody,
image: quotedType === 'imageMessage',
video: quotedType === 'videoMessage',
audio: quotedType === 'audioMessage',
document: quotedType === 'documentMessage',
viewonce: quotedMessage?.[quotedType]?.viewOnce,
}
: undefined,
send: async function (content, opts = {}) {
Expand Down

0 comments on commit 9a5185b

Please sign in to comment.