Updated index.js

This commit is contained in:
ShadowVR 2024-05-31 16:36:15 -04:00
parent 998c7b0f46
commit 2a14a78fbf

View file

@ -1,3 +1,5 @@
const Discord = require('discord.js'); const Discord = require('discord.js');
const chalk = require('chalk'); const chalk = require('chalk');
const fs = require('node:fs'); const fs = require('node:fs');
@ -71,9 +73,7 @@ async function registerSlashCommands() {
// Call the async function to register slash commands // Call the async function to register slash commands
registerSlashCommands(); registerSlashCommands();
// Function to update the bot from GitHub repository
async function updateBotFromGitHub() { async function updateBotFromGitHub() {
const git = simpleGit(path.resolve(__dirname)); const git = simpleGit(path.resolve(__dirname));
try { try {
@ -81,9 +81,12 @@ async function updateBotFromGitHub() {
if (!await git.checkIsRepo()) { if (!await git.checkIsRepo()) {
await git.init().addRemote('origin', 'https://git.shadowhosting.xyz/shadowvr/AI_botter.git').fetch(); await git.init().addRemote('origin', 'https://git.shadowhosting.xyz/shadowvr/AI_botter.git').fetch();
} else {
await git.fetch('origin', 'main');
} }
await git.pull('origin', 'main'); // Force update by resetting to the latest commit on the remote main branch
await git.reset(['--hard', 'origin/main']);
console.log('Bot updated from GitHub. Restarting...'); console.log('Bot updated from GitHub. Restarting...');