Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
release(v1.1.0) (#372)
Browse files Browse the repository at this point in the history
* chore: initial commit

* chore: update .gitignore

* chore: update README.md

* chore(deps): add required dependencies

* chore(config): update swcrc config

* chore(config): update tsconfig

* chore(.vscode/settings): vscode settings

* chore(src/listeners): remove dircetory and file

* chore(utils/structures): remove Logger and ProjectUtils

* chore(src/commands/developer): remove directory

* chore(src/commands/general): remove AvatarCommand

* chore(src/types): remove enum

* chore(types): update typings

* chore(config): update environment file

* chore(BaseCommand): update BaseCommand

* chore(BaseListener): update BaseListener

* chore(Whatsappbot): update WhatsappBot

* chore(DefaultCommandComponent): update default property

* chore(utils/constants): add index.ts

* chore(utils/decorators): update ApplyMetadata

* chore(utils/decorators): add index.ts

* chore(utils/functions): add impotClass

* chore(utils/functions): add mergeDefault

* chore(utils/functions): add readdirRecursive

* chore(utils/functions): add index.ts

* chore(utils/structures): update CommandHandler

* chore(utils/structures): update ListenerHandler

* chore(utils/structures): add index.ts

* chore(events): addd connectionUpdateEvent.ts

* chore(events): addd credsUpdateEvent.ts

* chore(events): addd messageUpsertEvent.ts

* chore(commands/general): add HelpCommand.ts

* chore(commands/general): add PingCommand.ts

* chore(commands/general): add StickerCommand.ts

* chore: add directory's root file

* fix(mergeDefault): eslint error

* fix(StickerCommand): eslint error

* chore(config): update default config

* chore(env): updata env example

* chore(PingCommand): update usage example

* chore(StickerCommand): update usage example

* chore(WhatsappBot): wrong Logger Level condition
  • Loading branch information
noxzym authored Dec 8, 2022
1 parent de79aca commit 72bcae9
Show file tree
Hide file tree
Showing 36 changed files with 3,702 additions and 16,977 deletions.
11 changes: 9 additions & 2 deletions .env_example
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
# IMPORTANT - What is the name of your bot?
# Example: BOT_NAME="Clytage Bot"
# Default: Clytage Bot
BOT_NAME=""
BOT_NAME="Clytage Bot"

#==============================================================================
# IMPORTANT - What should be the main prefix of your bot?
# Example: PREFIX="/"
# Default: /
PREFIX=""
PREFIX="/"

#==============================================================================
# MULTIPLE - What are the IDs (phone number) of the bot developers?
# Example: DEVS="6281234567890, 62813312394852"
DEVS=""

#==============================================================================
# IMPORTANT - What mode should the bot run in?
# Example: MODE="dev"
# Default: dev
# Options: dev, prod
MODE="prod"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,5 @@ dist
**.node-persist**
**_IGNORE_**
# end managed

auth_state
4 changes: 2 additions & 2 deletions .swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"tsx": false,
"decorators": true
},
"target": "es2021"
"target": "es5"
},
"module": {
"type": "es6"
"type": "commonjs"
}
}
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"npm.packageManager": "npm",
"files.eol": "\n",
"rpc.enabled": true
"files.eol": "\n"
}
19,410 changes: 3,169 additions & 16,241 deletions package-lock.json

Large diffs are not rendered by default.

69 changes: 36 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
{
"name": "whatsapp-bot",
"version": "1.0.0",
"version": "1.1.0",
"description": "A simple and easy-to-use WhatsApp bot project, written in TypeScript.",
"homepage": "https://github.com/Clytage/whatsapp-bot#readme",
"bugs": {
"url": "https://github.com/Clytage/whatsapp-bot/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Clytage/whatsapp-bot.git"
},
"license": "BSD-3-Clause",
"author": "Clytage <[email protected]>",
"main": "dist",
"type": "module",
"scripts": {
"build": "npm run lint && npm run compile",
"compile": "swc src -d dist",
Expand All @@ -15,58 +24,48 @@
"start": "node --es-module-specifier-resolution=node -r dotenv/config .",
"start:dev": "rimraf ./dist && npm run build && npm start"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Clytage/whatsapp-bot.git"
},
"author": "Clytage <[email protected]>",
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/Clytage/whatsapp-bot/issues"
},
"homepage": "https://github.com/Clytage/whatsapp-bot#readme",
"engines": {
"node": ">=16",
"npm": ">=7"
"prettier": {
"arrowParens": "avoid",
"tabWidth": 4,
"trailingComma": "none"
},
"eslintConfig": {
"extends": [
"@clytage-pkg/eslint-config/typescript",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": [
"prettier"
],
"plugins": [
"extends": [
"@clytage-pkg/eslint-config/typescript",
"prettier"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"class-methods-use-this": 0
},
"ignorePatterns": [
"dist/*"
]
},
"prettier": {
"tabWidth": 4,
"trailingComma": "none",
"arrowParens": "avoid"
},
"dependencies": {
"@adiwajshing/baileys": "^4.4.0",
"@discordjs/collection": "1.3.0",
"@sapphire/async-queue": "^1.5.0",
"colorette": "2.0.19",
"dayjs": "1.11.7",
"@hapi/boom": "^10.0.0",
"dayjs": "1.11.6",
"dotenv": "16.0.3",
"got": "^12.5.3",
"tslib": "2.4.1"
"ffmpeg-static": "^5.1.0",
"pino": "^8.7.0",
"pino-pretty": "^9.1.1",
"qrcode-terminal": "^0.12.0",
"sharp": "^0.30.5",
"tslib": "2.4.1",
"wa-sticker-formatter": "^4.3.2"
},
"devDependencies": {
"@clytage-pkg/eslint-config": "1.5.0",
"@open-wa/wa-automate": "^4.52.0",
"@swc/cli": "0.1.57",
"@swc/core": "^1.3.21",
"@types/node": "18.11.11",
"@types/node": "18.11.10",
"@typescript-eslint/eslint-plugin": "5.44.0",
"@typescript-eslint/parser": "5.44.0",
"eslint": "^8.28.0",
Expand All @@ -76,5 +75,9 @@
"rimraf": "3.0.2",
"ts-node": "10.9.1",
"typescript": "4.9.3"
},
"engines": {
"node": ">=16",
"npm": ">=7"
}
}
83 changes: 0 additions & 83 deletions src/commands/developer/EvalCommand.ts

This file was deleted.

40 changes: 0 additions & 40 deletions src/commands/general/AvatarCommand.ts

This file was deleted.

55 changes: 28 additions & 27 deletions src/commands/general/HelpCommand.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
import { ApplyMetadata } from "../../utils/decorators/ApplyMetadata";
import { proto } from "@adiwajshing/baileys";
import { BaseCommand } from "../../structures/BaseCommand";
import { ICommandComponent } from "../../types";
import { Message } from "@open-wa/wa-automate";
import { ApplyMetadata } from "../../utils/decorators";

@ApplyMetadata<ICommandComponent>({
name: "help",
description: "Display help message.",
usage: "help [command]"
aliases: ["h", "?"],
description: "Get help with the bot",
usage: "{PREFIX}help [command]"
})
export default class HelpCommand extends BaseCommand {
public async execute(message: Message, args: string[]): Promise<void> {
public async executeCommand(
args: string[],
data: proto.IWebMessageInfo
): Promise<void> {
if (args[0]) {
const command =
this.whatsappbot.commands.get(args[0]) ??
this.whatsappbot.commands.get(
this.whatsappbot.commands.aliases.get(args[0]) ?? ""
this.client.commandHandler.get(args[0]) ??
this.client.commandHandler.get(
this.client.commandHandler.aliases.get(args[0]) ?? ""
);

if (!command) {
await this.whatsappbot.client.sendText(
message.chatId,
"Command not found."
);
await this.client.socket?.sendMessage(data.key.remoteJid!, {
text: "Command not found"
});
return undefined;
}

await this.whatsappbot.client.sendText(
message.chatId,
`*${this.whatsappbot.config.botName}* - ${
await this.client.socket?.sendMessage(data.key.remoteJid!, {
text: `*${this.client.config.botName}* - ${
command.meta.name
}\n\n${command.meta.description!}\nUsage: ${
this.whatsappbot.config.prefix
}${command.meta.usage!}`
);
}\n\n${command.meta
.description!}\nUsage: ${command.meta.usage!.replace(
"{PREFIX}",
this.client.config.prefix
)}`
});
} else {
let commmandList = "";
Object.values(this.whatsappbot.commands.categories)
Object.values(this.client.commandHandler.categories)
.map(commands => commands!.filter(Boolean))
.sort((a, b) =>
a[0].meta.category!.localeCompare(
Expand All @@ -49,12 +51,11 @@ export default class HelpCommand extends BaseCommand {
.map(commands => {
const category = commands[0].meta.category!;
const cmds = commands.map(cmd => cmd.meta.name).join(", ");
commmandList += `*${category.toUpperCase()}*\n${cmds}\n`;
commmandList += `*${category.toUpperCase()}*\n\`\`\`${cmds}\`\`\`\n`;
});
await this.whatsappbot.client.sendText(
message.chatId,
`*${this.whatsappbot.config.botName}* - Command List\n\n${commmandList}`
);
await this.client.socket?.sendMessage(data.key.remoteJid!, {
text: `*${this.client.config.botName}* - Command List\n\n${commmandList}`
});
}
}
}
Loading

0 comments on commit 72bcae9

Please sign in to comment.