Updated index.js
This commit is contained in:
parent
998c7b0f46
commit
2a14a78fbf
1 changed files with 6 additions and 3 deletions
9
index.js
9
index.js
|
@ -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...');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue