Skip to content

Commit 62c1941

Browse files
authored
Add files via upload
1 parent 140517b commit 62c1941

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

MakeBot.sh

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
3+
if [ $(id -u) != 0 ]; then
4+
echo "Run this script as root!"
5+
exit 0
6+
fi
7+
8+
if [[ "$#" -eq 0 ]]; then
9+
echo "No arguments passed."
10+
echo "Usage: sudo ./MakeBot.sh <projectName> <Discord Bot Token>"
11+
echo "Example: sudo ./MakeBot.sh randomBotName 1312312312415135135"
12+
exit 0
13+
fi
14+
15+
fileName=$_| cut -d '/' -f 2
16+
projectName=$1
17+
oAuthToken=$2
18+
output=`node -h | grep "Command not found"`
19+
if [[ $output == '' ]]; then
20+
echo "[+] NodeJS Installed on the system!"
21+
echo "Checking version: "
22+
version=`node -v | cut -d '.' -f 1`
23+
echo "Version is $version"
24+
if [[ $version == 'v12' ]]; then
25+
echo "Checking version of npm"
26+
version_npm=`npm -v | grep "Command not found"`
27+
if [[ $version_npm =~ [0-9] ]]; then
28+
echo "[!] NPM not installed on system."
29+
echo "Beginning installation"
30+
apt install -y npm
31+
bash $fileName $projectName $oAuthToken; exit 0
32+
else
33+
echo "Preparing installation of Discord.js"
34+
mkdir $projectName && cd $projectName
35+
npm init -y
36+
npm install --save discord.js dotenv
37+
touch bot.js .env
38+
echo "$oAuthToken" > .env
39+
echo "Installation Completed! You may begin to work on your bot now."
40+
echo "Main working file: $projectName/bot.js"
41+
mv ../default.js $projectName/bot.js
42+
echo "client.login('$oAuthToken');" >> bot.js
43+
exit 0
44+
fi
45+
else
46+
echo "Upgrading to version 12"
47+
apt update
48+
apt -y install curl dirmngr apt-transport-https lsb-release ca-certificates
49+
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
50+
apt -y install nodejs
51+
clear
52+
version=`node -v`
53+
echo "Installed Version $version"
54+
echo "Restarting..."
55+
bash $fileName $projectName $oAuthToken; exit 0
56+
fi
57+
58+
59+
else
60+
echo "[!] No installation of NodeJS found on system!. Initiating installation process!"
61+
apt update
62+
apt -y install curl dirmngr apt-transport-https lsb-release ca-certificates
63+
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
64+
apt -y install nodejs
65+
clear
66+
echo "Successfully installed! Restarting..."
67+
bash $fileName $projectName $oAuthToken; exit 0
68+
fi

default.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const Discord = require('discord.js');
2+
const client = new Discord.Client();
3+
4+
client.on('message', message => {
5+
if (message.content.startsWith('ping!')) {
6+
message.reply('pong!');
7+
}
8+
});
9+
10+
client.on('ready', () => {
11+
console.log('I am ready!');
12+
});

0 commit comments

Comments
 (0)