1+ /**
2+ * File: /home/elavanresu/ElavanResu/e-bot/commands/ping.js
3+ * Project: /home/elavanresu/ElavanResu/e-bot
4+ * Created Date: Monday, May 31st 2021, 10:04:29 pm
5+ * Author: Shubham Navale
6+ * -----
7+ * Last Modified: Mon May 31 2021
8+ * Modified By: Shubham Navale
9+ * -----
10+ * ------------------------------------
11+ * All Rights reserved
12+ */
13+ const Discord = require ( 'discord.js' )
14+ const { guestGlobalusers } = require ( '../metaData/globalUsers' )
15+ const { prefix } = require ( '../config.json' )
16+
17+ module . exports = {
18+ name : 'ping' ,
19+ description : 'Pings people for x number of times' ,
20+ args : true ,
21+ guildOnly : true ,
22+ aliases : [ 'pingme' , 'pm' ] ,
23+ usage : '<times> <tag>' ,
24+ moreInfo : `Pings people x number of times` ,
25+ cooldown : - 1 ,
26+ async execute ( message , args ) {
27+ // check perms
28+ if ( ! guestGlobalusers . hasOwnProperty ( message . author . id ) ) {
29+ return message . channel . send (
30+ new Discord . MessageEmbed ( )
31+ . setColor ( '#A6011F' )
32+ . setDescription ( `Sorry, no one is allowed to use the system features` )
33+ )
34+ }
35+
36+ if ( ! args [ 0 ] ) return message . channel . send (
37+ new Discord . MessageEmbed ( )
38+ . setColor ( '#A6011F' )
39+ . setDescription ( `Invalid Arguments. Type **${ prefix } help ping** to know more.` )
40+ )
41+
42+ if ( typeof parseInt ( args [ 0 ] ) !== 'number' || parseInt ( args [ 0 ] ) === 0 || isNaN ( parseInt ( args [ 0 ] ) ) ) return message . channel . send (
43+ new Discord . MessageEmbed ( )
44+ . setColor ( '#A6011F' )
45+ . setDescription ( `Invalid Arguments. Type **${ prefix } help ping** to know more.` )
46+ )
47+
48+ const taggedUser = message . mentions . users . first ( )
49+
50+ if ( typeof parseInt ( args [ 0 ] ) === 'number' ) {
51+ const times = parseInt ( args [ 0 ] )
52+ for ( let count = 0 ; count < times ; count ++ ) {
53+ if ( args [ 1 ] === 's' ) {
54+ await message . channel . send ( `${ taggedUser || message . author } ` )
55+ } else if ( ! taggedUser ) {
56+ await message . author . send ( `${ message . author } ` )
57+ } else {
58+ await taggedUser . send ( `${ message . author } ` )
59+ }
60+ }
61+ return
62+ }
63+ }
64+ }
0 commit comments