Compare commits
No commits in common. "main" and "testing" have entirely different histories.
@ -1,47 +0,0 @@
|
|||||||
name: Silvanus Production Dockerization
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
env:
|
|
||||||
DHUB_UNAME: ${{ secrets.DHUB_UNAME }}
|
|
||||||
DHUB_PWORD: ${{ secrets.DHUB_PWORD }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
|
|
||||||
build:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Pull latest from Git
|
|
||||||
run: |
|
|
||||||
pwd
|
|
||||||
whoami
|
|
||||||
mkdir -p /var/lib/act_runner/
|
|
||||||
cd /var/lib/act_runner/
|
|
||||||
if [ ! -d "silvanus" ]; then
|
|
||||||
git clone https://git.vfsh.dev/voidf1sh/silvanus
|
|
||||||
cd silvanus
|
|
||||||
else
|
|
||||||
cd silvanus
|
|
||||||
git pull
|
|
||||||
fi
|
|
||||||
git checkout ${{ gitea.ref}}
|
|
||||||
- name: Build the Docker image
|
|
||||||
run: |
|
|
||||||
cd /var/lib/act_runner/silvanus
|
|
||||||
docker build . --file Dockerfile --tag v0idf1sh/silvanus
|
|
||||||
- name: Log into Docker Hub
|
|
||||||
run: docker login -u $DHUB_UNAME -p $DHUB_PWORD
|
|
||||||
- name: Push image to Docker Hub
|
|
||||||
run: |
|
|
||||||
cd /var/lib/act_runner/silvanus
|
|
||||||
docker push v0idf1sh/silvanus
|
|
||||||
- name: Restart the container
|
|
||||||
run: |
|
|
||||||
cd /srv/docker/silvanus
|
|
||||||
docker-compose down
|
|
||||||
docker-compose up -d
|
|
0
.gitea/workflows/docker-image-dev.yml → .github/workflows/docker-image-dev.yml
vendored
Normal file → Executable file
0
.gitea/workflows/docker-image-dev.yml → .github/workflows/docker-image-dev.yml
vendored
Normal file → Executable file
35
.github/workflows/docker-image-prod.yml
vendored
Executable file
35
.github/workflows/docker-image-prod.yml
vendored
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
name: Silvanus Production Dockerization
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
env:
|
||||||
|
DHUB_UNAME: ${{ secrets.DHUB_UNAME }}
|
||||||
|
DHUB_PWORD: ${{ secrets.DHUB_PWORD }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: self-hosted
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Pull latest from Git
|
||||||
|
run: |
|
||||||
|
pwd
|
||||||
|
whoami
|
||||||
|
cd /root/silvanus
|
||||||
|
git pull
|
||||||
|
git checkout $GITHUB_HEAD_REF
|
||||||
|
- name: Build the Docker image
|
||||||
|
run: |
|
||||||
|
cd /root/silvanus
|
||||||
|
docker build . --file Dockerfile --tag v0idf1sh/silvanus
|
||||||
|
- name: Log into Docker Hub
|
||||||
|
run: docker login -u $DHUB_UNAME -p $DHUB_PWORD
|
||||||
|
- name: Push image to Docker Hub
|
||||||
|
run: |
|
||||||
|
cd /root/silvanus
|
||||||
|
docker push v0idf1sh/silvanus
|
@ -5,4 +5,5 @@ WORKDIR /usr/src/app
|
|||||||
COPY package.json ./
|
COPY package.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
COPY . .
|
COPY . .
|
||||||
CMD ["/bin/sh", "-c", "node main.js 2>&1 > /logs/$(date +%Y-%m-%d_%H-%M-%S).txt"]
|
# CMD ["/bin/sh", "-c", "node main.js 2> /logs/silvanus.err 1> /logs/silvanus.log"]
|
||||||
|
CMD ["/bin/sh", "-c", "node main.js 2> /logs/error/$(date +%Y-%m-%d_%H-%M-%S).txt 1> /logs/status/$(date +%Y-%m-%d_%H-%M-%S).txt"]
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
![Current Uptime Status](https://status.vfsh.dev/api/badge/1/status)
|
|
||||||
![Uptime Percentage](https://status.vfsh.dev/api/badge/1/uptime)
|
|
||||||
# Silvanus
|
# Silvanus
|
||||||
Silvanus is the ultimate Grow A Tree companion bot! Quickly compare your server's tree to others on the leaderboard with automatic calculation of tree height differences, active growth detection, watering time calculations, and more!
|
Silvanus is the ultimate Grow A Tree companion bot! Quickly compare your server's tree to others on the leaderboard with automatic calculation of tree height differences, active growth detection, watering time calculations, and more!
|
||||||
|
|
||||||
|
24
TODO.md
24
TODO.md
@ -1,3 +1,10 @@
|
|||||||
|
## In Progress
|
||||||
|
☑ Switch `/setup` to ask for the tree and leaderboard channels
|
||||||
|
* Switch `/compare` to check for newer trees and leaderboards when run **and** on every refresh
|
||||||
|
|
||||||
|
## Future Ideas
|
||||||
|
* Go through and comment the code
|
||||||
|
|
||||||
## Variable Structures
|
## Variable Structures
|
||||||
|
|
||||||
guildInfo = {
|
guildInfo = {
|
||||||
@ -14,18 +21,7 @@ guildInfo = {
|
|||||||
reminderOptIn: 0,
|
reminderOptIn: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
## New Table Planning
|
## Expected Behaviors
|
||||||
Table: `silvanus`.timers
|
|
||||||
|
|
||||||
id | INT | NOT NULL | AUTO INCREMENT | PRIMARY KEY
|
* Run `/compare` before `/setup`: `/compare` will search the current channel for tree and leaderboard messages, then create a comparison embed. If it can't find `/tree` or `/top trees` messages, it'll return an error saying as much.
|
||||||
status | VARCHAR(10) | NOT NULL | DEFAULT "WAITING"
|
* Run `/compare` after `/setup`: ``/compare` will search the current channel for tree and leaderboard messages, then create a comparison embed. If it can't find `/tree` or `/top trees` messages, it'll just use old data silently (odds are `/compare` is being run from another channel, that's fine)
|
||||||
dc_timecode | INT | NOT NULL | Discord timecode
|
|
||||||
guild_id | INT UNSIGNED | NOT NULL | Discord guild ID for referencing `silvanus`.guildInfo
|
|
||||||
|
|
||||||
|
|
||||||
Table: `silvanus`.auto_role_status
|
|
||||||
|
|
||||||
id | INT | NOT NULL | AUTO INCREMENT | PRIMARY KEY
|
|
||||||
user_id | INT UNSIGNED | NOT NULL
|
|
||||||
guild_id | INT UNSIGNED | NOT NULL
|
|
||||||
status | VARCHAR(10) | NOT NULL | DEFAULT "REMOVED" | OPTION: {"REMOVED", "ADDED"}
|
|
||||||
|
14
main.js
14
main.js
@ -5,8 +5,6 @@ const dotenv = require('dotenv');
|
|||||||
dotenv.config();
|
dotenv.config();
|
||||||
const token = process.env.TOKEN;
|
const token = process.env.TOKEN;
|
||||||
const statusChannelId = process.env.STATUSCHANNELID;
|
const statusChannelId = process.env.STATUSCHANNELID;
|
||||||
const heartbeatUrl = process.env.HEARTBEAT_URL;
|
|
||||||
const sendHeartbeat = typeof heartbeatUrl === 'string';
|
|
||||||
|
|
||||||
// Discord.JS
|
// Discord.JS
|
||||||
const { Client, GatewayIntentBits, Partials, ActivityType } = require('discord.js');
|
const { Client, GatewayIntentBits, Partials, ActivityType } = require('discord.js');
|
||||||
@ -28,7 +26,7 @@ const fn = require('./modules/functions.js');
|
|||||||
const strings = require('./data/strings.json');
|
const strings = require('./data/strings.json');
|
||||||
const dbfn = require('./modules/dbfn.js');
|
const dbfn = require('./modules/dbfn.js');
|
||||||
const { GuildInfo } = require('./modules/CustomClasses.js');
|
const { GuildInfo } = require('./modules/CustomClasses.js');
|
||||||
const isDev = process.env.DEBUG === "true";
|
const isDev = process.env.DEBUG;
|
||||||
let statusChannel;
|
let statusChannel;
|
||||||
|
|
||||||
client.once('ready', async () => {
|
client.once('ready', async () => {
|
||||||
@ -45,16 +43,6 @@ client.once('ready', async () => {
|
|||||||
if (isDev == 'false') {
|
if (isDev == 'false') {
|
||||||
statusChannel.send(`${new Date().toISOString()} -- \nStartup Sequence Complete <@481933290912350209>`);
|
statusChannel.send(`${new Date().toISOString()} -- \nStartup Sequence Complete <@481933290912350209>`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Heartbeat Timer
|
|
||||||
if (sendHeartbeat) {
|
|
||||||
setInterval(() => {
|
|
||||||
fn.sendHeartbeat(heartbeatUrl);
|
|
||||||
}, 30000);
|
|
||||||
if (isDev) console.log("Heartbeat interval set.");
|
|
||||||
} else {
|
|
||||||
if (isDev) console.log("No heartbeat URL set, will not send heartbeats for uptime monitoring.");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// slash-commands
|
// slash-commands
|
||||||
|
@ -20,7 +20,6 @@ const slashCommandFiles = fs.readdirSync('./slash-commands/').filter(file => fil
|
|||||||
const dotCommandFiles = fs.readdirSync('./dot-commands/').filter(file => file.endsWith('.js'));
|
const dotCommandFiles = fs.readdirSync('./dot-commands/').filter(file => file.endsWith('.js'));
|
||||||
const dbfn = require('./dbfn.js');
|
const dbfn = require('./dbfn.js');
|
||||||
const { finished } = require('stream');
|
const { finished } = require('stream');
|
||||||
const https = require('https');
|
|
||||||
|
|
||||||
const functions = {
|
const functions = {
|
||||||
// Functions for managing and creating Collections
|
// Functions for managing and creating Collections
|
||||||
@ -1046,9 +1045,9 @@ const functions = {
|
|||||||
},
|
},
|
||||||
async sendWaterReminder(guildInfo, message, channelId, guild) {
|
async sendWaterReminder(guildInfo, message, channelId, guild) {
|
||||||
const reminderChannel = await guild.channels.fetch(channelId);
|
const reminderChannel = await guild.channels.fetch(channelId);
|
||||||
// const reminderEmbed = functions.builders.waterReminderEmbed(message, guildInfo);
|
const reminderEmbed = functions.builders.waterReminderEmbed(message, guildInfo);
|
||||||
if (isDev) console.log(`WR: ${guild.name}: ${guildInfo.treeName}`);
|
if (isDev) console.log(`WR: ${guild.name}: ${guildInfo.treeName}`);
|
||||||
await reminderChannel.send(message).then(async m => {
|
await reminderChannel.send(reminderEmbed).then(async m => {
|
||||||
if (!m.deletable) return;
|
if (!m.deletable) return;
|
||||||
await this.sleep(500).then(async () => {
|
await this.sleep(500).then(async () => {
|
||||||
await m.delete().catch(e => console.error(e));
|
await m.delete().catch(e => console.error(e));
|
||||||
@ -1059,9 +1058,9 @@ const functions = {
|
|||||||
},
|
},
|
||||||
async sendFruitReminder(guildInfo, message, channelId, guild) {
|
async sendFruitReminder(guildInfo, message, channelId, guild) {
|
||||||
const reminderChannel = await guild.channels.fetch(channelId);
|
const reminderChannel = await guild.channels.fetch(channelId);
|
||||||
// const reminderEmbed = functions.builders.fruitReminderEmbed(message, guildInfo);
|
const reminderEmbed = functions.builders.fruitReminderEmbed(message, guildInfo);
|
||||||
if (isDev) console.log(`FR: ${guild.name}: ${guildInfo.treeName}`);
|
if (isDev) console.log(`FR: ${guild.name}: ${guildInfo.treeName}`);
|
||||||
await reminderChannel.send(message).then(async m => {
|
await reminderChannel.send(reminderEmbed).then(async m => {
|
||||||
if (!m.deletable) return;
|
if (!m.deletable) return;
|
||||||
await this.sleep(500).then(async () => {
|
await this.sleep(500).then(async () => {
|
||||||
await m.delete().catch(e => console.error(e));
|
await m.delete().catch(e => console.error(e));
|
||||||
@ -1143,20 +1142,6 @@ const functions = {
|
|||||||
}
|
}
|
||||||
const errorId = digits.join("");
|
const errorId = digits.join("");
|
||||||
return errorId;
|
return errorId;
|
||||||
},
|
|
||||||
async sendHeartbeat(url) {
|
|
||||||
https.get(url, async (response) => {
|
|
||||||
if (isDev) console.log("Sent Heartbeat Request: " + url);
|
|
||||||
let data = '';
|
|
||||||
|
|
||||||
response.on('data', (chunk) => data += chunk);
|
|
||||||
|
|
||||||
response.on('end', () => {
|
|
||||||
if (isDev) console.log("Received Heartbeat Response: " + data);
|
|
||||||
parsedData = JSON.parse(data);
|
|
||||||
if ( !(parsedData.ok) ) console.error("Heartbeat failed");
|
|
||||||
});
|
|
||||||
}).on("error", (error) => console.error(error));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "silvanus",
|
"name": "silvanus",
|
||||||
"version": "1.2.9",
|
"version": "1.2.7",
|
||||||
"description": "Grow A Tree Companion Bot",
|
"description": "Grow A Tree Companion Bot",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Loading…
Reference in New Issue
Block a user