Skip to content

Commit

Permalink
DiscordListener
Browse files Browse the repository at this point in the history
  • Loading branch information
akashdeepb authored Jun 2, 2018
1 parent 4e998e9 commit 026a0c4
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
36 changes: 36 additions & 0 deletions bot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const Discord = require('discord.js');
var bot=new Discord.Client();
var HH=new Date().getHours();
var MM=new Date().getMinutes();
var i=0;
var flag=0;
const usr=require(__dirname+'/cred.json');
const key=require(__dirname+'/keywords.json');
bot.on("ready",async()=>{
console.log("\n\n\t ~ DiscordListener Online ");
bot.user.setActivity(" with Myself");
});
bot.on('message',msg=>{
if(msg.content=='~on'){
if(msg.author.id==usr.uid){
msg.author.send("\n ~ Discord Listener Online ");
flag=1;
}
}
if(msg.content=='~off'){
if(msg.author.id==usr.uid){
msg.author.send("\n ~ Discord Listener Stopped ");
flag=0;
}
}
if(flag==1){
for(i=0;i<key.keys.length;i++){
if(msg.content.includes(key.keys[i])&&msg.channel.type!='dm'){
bot.users.get(usr.uid).send("[ "+msg.author.username+" ] : "+ msg.content);
console.log("\n");
console.log(HH+":"+MM+" [ "+msg.author.username+" ] - " + msg.content );
}
}
}
});
bot.login(usr.token);
14 changes: 14 additions & 0 deletions bot_init.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@echo off
COLOR 0A
echo -- D I S C O R D L I S T E N E R --
echo B y A d B
set tab=
set /p uid=Enter USER ID :
set /p token=Enter BOT Token :
echo {>cred.json
echo %tab%"token":"%token%",>>cred.json
echo %tab%"uid":"%uid%">>cred.json
echo }>>cred.json
call npm init
call npm install discord.js --save
echo --- B O T I N I T I A L I Z A T I O N C O M P L E T E ----
14 changes: 14 additions & 0 deletions bot_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
echo -e "\t\t *** D i s c o r d L i s t e n e r B o t ***"
echo -e "\t\t\t\t ~ B y A d B ~ "
echo -e "\n\n"
read -p " U S E R I D : " uid
read -p " B O T T O K E N : " token
chmod +x keys.sh
FILENAME="cred.json"
echo "{">$FILENAME
echo -e "\t\"token\":\"$token\",">>$FILENAME
echo -e "\t\"uid\":\"$uid\"">>$FILENAME
echo "}">>$FILENAME
npm init
npm install discord.js --save
echo -e " BOT INITIALIZATION COMPLETE "
17 changes: 17 additions & 0 deletions keys.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@echo off
COLOR 0A
echo -- D i s c o r d L i s t e n e r B o t --
echo B y A d B
echo
echo
echo -- E N T E R K E Y W O R D S --
set tab=
echo {>keywords.json
echo %tab%"keys": [ A0h@dcToBlk#, ">>keywords.json
:while1
if %key% leq "END" (
set /p key=Enter Keyword :
echo %key%>>keywords.json
goto :while1
)
endlocal
15 changes: 15 additions & 0 deletions keys.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FILENAME="keywords.json"
echo -e "\t\t ~ D i s c o r d L i s t e n e r B o t "
echo -e "\t\t\t\t ~ B y A d B ~ "
echo -e "\n\n --- E N T E R K E Y W O R D S --- "
echo -e "\n\t Enter \" END \" when you are finished entering keywords \n\n"
echo "{">$FILENAME
echo -e -n "\t\"keys\": [ \"A0h@dcToBlk#\"">>$FILENAME
while [ "$key" != "END" ]
do
read -p "Enter KEYWORD : " key
echo -n ",\"$key\"">>$FILENAME
done
echo "]">>$FILENAME
echo "}">>$FILENAME
echo -e "\n\t K E Y W O R D S S A V E D \n\n "

0 comments on commit 026a0c4

Please sign in to comment.