Compare commits

...

4 Commits

Author SHA1 Message Date
fcfb3e290f minor update to bash script 2022-01-27 21:58:23 -06:00
1bf5e9d64f updated windows scripts 2022-01-27 21:58:13 -06:00
219d3e55e7 added screen/tmux support 2022-01-27 21:04:48 -06:00
4f696e8b21 updated start scripts 2022-01-27 20:43:51 -06:00
11 changed files with 115 additions and 46 deletions

3
.gitignore vendored
View File

@@ -1,3 +1,4 @@
node_modules
token
.DS_Store
.DS_Store
log

View File

@@ -32,7 +32,8 @@ Download and install [Node.js](https://nodejs.org/en/)
<summary><b>Mac/Linux Screen</b></summary>
<br>
<p>Screen allows the bot to run in the background without a terminal present</p>
<p>Installing</p>
<p><a href="https://linuxize.com/post/how-to-use-linux-screen/">Tutorial for usage</a>, check if it's installed already before installing</p>
<p><b>Installing</b></p>
<ul>
<li>
<p>Mac</p>
@@ -54,7 +55,8 @@ Download and install [Node.js](https://nodejs.org/en/)
<summary><b>Mac/Linux Tmux</b></summary>
<br>
<p>Tmux allows the bot to run in the background without a terminal present</p>
<p>Installing</p>
<p><a href="https://linuxize.com/post/getting-started-with-tmux/">Tutorial for usage</a>, check if it's installed already before installing</p>
<p><b>Installing</b></p>
<ul>
<li>
<p>Mac</p>

1
dist/index.js vendored
View File

@@ -34,6 +34,7 @@ const api_1 = require("./api");
const discord_1 = require("./discord");
const queue_1 = require("./queue");
const CLIENT = new discord_js_1.Client({ intents: [discord_js_1.Intents.FLAGS.GUILDS] });
console.log(new Date().toISOString() + '\n\n');
if (!fs.existsSync('./token')) {
fs.writeFileSync('./token', '');
console.error('Missing Discord Token, please enter the bot token into the token file');

View File

@@ -1,43 +1,44 @@
{
"name": "1800queue",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"start": "node .",
"watch": "npm-watch",
"dev": "npm-watch"
},
"watch": {
"build": {
"patterns": [
"src"
],
"extensions": "ts",
"legacyWatch": true
"name": "1800queue",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"start": "node .",
"watch": "npm-watch",
"dev": "npm-watch",
"getname": "echo $npm_package_name"
},
"start": {
"patterns": [
"dist"
],
"extensions": "js",
"legacyWatch": true,
"runOnChangeOnly": true
"watch": {
"build": {
"patterns": [
"src"
],
"extensions": "ts",
"legacyWatch": true
},
"start": {
"patterns": [
"dist"
],
"extensions": "js",
"legacyWatch": true,
"runOnChangeOnly": true
}
},
"author": "",
"license": "MIT",
"devDependencies": {
"@types/node": "^17.0.13",
"npm-watch": "^0.11.0",
"ts-node": "^10.4.0",
"typescript": "^4.5.5"
},
"dependencies": {
"@discordjs/rest": "^0.3.0",
"cheerio": "^1.0.0-rc.10",
"discord-api-types": "^0.26.1",
"discord.js": "^13.6.0"
}
},
"author": "",
"license": "MIT",
"devDependencies": {
"@types/node": "^17.0.13",
"npm-watch": "^0.11.0",
"ts-node": "^10.4.0",
"typescript": "^4.5.5"
},
"dependencies": {
"@discordjs/rest": "^0.3.0",
"cheerio": "^1.0.0-rc.10",
"discord-api-types": "^0.26.1",
"discord.js": "^13.6.0"
}
}

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash
#change to ccurrent directory
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"

View File

@@ -1,6 +1,6 @@
#!/bin/bash
#change to ccurrent directory
#change to current directory
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"
cd ../..
@@ -27,14 +27,16 @@ echo $num > log/number
#watchdog
while true
do
#increment log file number
num=$(( num + 1 ))
echo $num > log/number
#run
npm start >> log/$num.out 2> log/$num.err
npm start 2> log/$num.err | tee log/$num.out
#give chance to close program
sleep 5
printf "\n\n\n${C1}press ${C2}Control+C${C1} to close${NC}\n\n\n"
sleep 5
done

12
scripts/mac-linux/start_screen Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
#change to ccurrent directory
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"
#start
if [[ $(screen -ls | grep $(npm run getname -s)) ]]; then
echo "Session already exists"
else
screen -S $(npm run getname -s) -d -m ./start
echo "Created session"
fi

12
scripts/mac-linux/start_tmux Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
#change to ccurrent directory
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"
#start
if [[ $(tmux ls | grep $(npm run getname -s)) ]]; then
echo "Session already exists"
else
tmux new-session -d -s $(npm run getname -s) ./start
echo "Created session"
fi

View File

@@ -0,0 +1,7 @@
@echo off
@REM change to ccurrent directory
cd %~f0\..\..\..\
@REM run
npm install

29
scripts/windows/start.bat Normal file
View File

@@ -0,0 +1,29 @@
@echo off
@Rem change to current directory
cd %~f0\..\..\..\
@Rem make log folder
if not exist log mkdir log
@Rem current file number
set /A num=0
if exist log\number set /p num=<log\number
echo %num > log\number
@Rem watchdog
:watchdog
@Rem increment log file number
set /A num=num+1
echo %num > log\number
@Rem run
powershell "npm start 2> log\%num%.err | tee log\%num%.out"
@Rem give chance to close program
timeout /t 5 /nobreak
goto watchdog

View File

@@ -6,6 +6,8 @@ import { registerCommands } from './discord';
import { createQueue, joinQueue, queueInfo } from './queue';
const CLIENT = new Client({ intents: [Intents.FLAGS.GUILDS] });
console.log(new Date().toISOString()+'\n\n');
if (!fs.existsSync('./token')) {
fs.writeFileSync('./token', '');
console.error('Missing Discord Token, please enter the bot token into the token file');