Skip to content

Commit

Permalink
feat: pick
Browse files Browse the repository at this point in the history
  • Loading branch information
sdip15fa committed Dec 11, 2023
1 parent 982ad18 commit 767cc60
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import hm from "./hm.js";
import llama from "./llama.js";
import chess from "./chess.js";
import autoreply from "./autoreply.js";
import pick from "./pick.js";

export const commands = new Map();

Expand Down Expand Up @@ -117,3 +118,4 @@ commands.set(ttt.command.slice(1), ttt);
commands.set(llama.command.slice(1), llama);
commands.set(chess.command.slice(1), chess);
commands.set(autoreply.command.slice(1), autoreply);
commands.set(pick.command.slice(1), pick);
23 changes: 23 additions & 0 deletions commands/pick.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Client, Message } from "whatsapp-web.js";

//jshint esversion:8
const execute = async (_client: Client, msg: Message, args: string[]) => {
if (msg.hasQuotedMsg) {
args = (await msg.getQuotedMessage())?.body?.split("");
}
if (!args.length) {
return msg.reply("Please provide options!");
}
msg.reply(args[Math.floor(Math.random() * args.length)]);
};

export default {
name: "Pick", //name of the module
description: "Pick an option for you", // short description of what this command does
command: "!pick", //command with prefix. Ex command: '!test'
commandType: "plugin", //
isDependent: false, //whether this command is related/dependent to some other command
help: "Randomly pick an option.\n\n!flip [option1] [option2] [option3] etc.", // a string descring how to use this command Ex = help : 'To use this command type !test arguments'
public: true,
execute,
};

0 comments on commit 767cc60

Please sign in to comment.