From f468d1e3adf8ec92d7a8ae706a6c28af8411bad4 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Fri, 2 Apr 2021 14:48:10 -0500 Subject: [PATCH] Replace prefix with const and add help message --- index.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 2423e7e..8a3c1ba 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ const client = new Discord.Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'] var database, collection; const DATABASE_NAME = process.env.DATABASE_NAME; const CONNECTION_URL = "localhost:27017"; +const prefix = '$'; MongoClient.connect("mongodb://" + CONNECTION_URL, { useNewUrlParser: true }, (error, client) => { if(error) { @@ -81,20 +82,36 @@ client.on("ready", () => { client.on("message", async message => { switch (message.content.toLowerCase()) { - case '$aboutserver': + case `${prefix}aboutserver`: aboutServer(message); break; + case `${prefix}help`: + helpMessage(message); + break; } - if (message.content.toLowerCase().startsWith("$bulkdelete")) { + if (message.content.toLowerCase().startsWith(`${prefix}bulkdelete`)) { bulkDelete(message); - } else if (message.content.toLowerCase().startsWith("$rolerequest")) { + } else if (message.content.toLowerCase().startsWith(`${prefix}rolerequest`)) { roleRequest(message); - } else if (message.content.toLowerCase().startsWith("$userswithrole")) { + } else if (message.content.toLowerCase().startsWith(`${prefix}userswithrole`)) { usersWithRole(message); } }); +async function helpMessage(message) { + const helpEmbed = new Discord.MessageEmbed() + .setTitle(`Helping \`${message.author.tag}\``) + .addField(`Prefix`, prefix) + .addField(`Using the bot`, "Once <@780562707254083584> joins the server, it will create a category called `Awesome Mod` and two channels within it. One is for regular members to request roles (called `#role-requests`) and the other is for bot logs (`#bot-logs`). These can be renamed and moved around but should not be deleted. <@780562707254083584> also comes with a ton of handy commands to analyze and manage your server.") + .addField(`Bulk delete command`, `${prefix}bulkDelete`) + .addField(`Role request command`, `${prefix}roleRequest [role]`) + .addField(`View users with role`, `${prefix}usersWithRole [role]`) + .setFooter(`Bot ID: ${client.user.id}`) + .setTimestamp(); + message.channel.send(helpEmbed).catch(console.error); +} + async function usersWithRole(message) { if (message.content.split(" ")[1].length < 3) { message.reply("query must contain at least 3 characters!")