Simple discord bot that will serve the need to show info about the cs server with the command ++acfun
.
Setup discord.js with Typescript
Use Prettier with ESLint and TypeScript in VSCode
For your changes to take effect, use
npm run build
npm run start
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
source ~/.bashrc
nvm list-remote
nvm install v16.15.1
node -v
nvm list
- shows the currently active version on the first line
You can switch between installed versions with nvm use
nvm use v16.15.1
The correct version of Node is installed on our machine as we expected. A compatible version of npm is also available.
su steam
cd ~
git clone https://github.com/Arxero/mavbot.git
Give fle permission to the folder you are in, first go in the parent folder of mavbot
sudo chmod -R 777 mavbot/
Install npm packages
cd mavbot
npm i
Run bot
This will make dist
folder from which actual js files will be executed. You would need to run it (then stop it, just to recompile the new changes into js files) everytime when you do git pull
/update the bot form the repo.
npm run build
Create .env
file with the bot secrets
nano .env
Start the bot and logged in the discord server
npm run start
Run thge bot in the background with Screen
List screen sessions
screen -ls
Create new screen
session named mavbot
cd mavbot
screen -A -m -d -S mavbot npm run start
or
cd mavbot && screen -A -m -d -S mavbot npm run start
Kill mavbot
session
screen -X -S mavbot kill
Reattach to the screen session by typing
screen -r mavbot
Use the key sequence Ctrl-a
+ Ctrl-d
to detach from the screen session.
cd mavbot
git fetch --all
git reset --hard origin/master
git pull
git build
screen -A -m -d -S mavbot npm run start
-
Create start.sh file in the home directory for example
cd /home/steam sudo nano mavbot.sh
-
Give start.sh file permissions to be executable
sudo chmod +x mavbot.sh
-
Update
mavbot.sh
with the following:
screen -X -S mavbot kill
cd /home/steam/mavbot
screen -A -m -d -S mavbot npm run start
echo "==========Mavbot has been booted=========="
- Run
mavbot.sh
script on system startup
Run a Script on Startup in Linux
First login as the user you want to execute the script from, then open crontab and add the required line at the bottom of the file
crontab -e
@reboot sh /home/steam/mavbot.sh
cd /etc/systemd/system
sudo nano mavbot.service
[Unit]
Description=Reboots Mavbot.
[Service]
Type=simple
ExecStart=/bin/bash /home/steam/mavbot.sh
[Install]
WantedBy=multi-user.target
chmod 644 /etc/systemd/system/mavbot.service
sudo systemctl enable mavbot.service
-
to see updatable packages
ncu
-
to update them
ncu -u
-
htop
-
F4
-
search for it and copy
PID
-
exit and use
kill -9 PID
-
where
PID
is the id you copied from htop
-
SHOW CREATE TABLE mavbot.player_sessions;
ALTER TABLE mavbot.player_sessions CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
sudo apt install ttf-mscorefonts-installer
sudo fc-cache -f
in a terminal.
After that, check with
fc-match Arial
Navigate to the directory where your application is located and run the following command:
pm2 start npm --name "mavbot" -- start
pm2 list
pm2 stop <app_name|app_id>
pm2 restart <app_name|app_id>