FIX: Fixed some typos as well as fixed up the update module
This commit is contained in:
parent
8e125c9758
commit
4f065d368b
@ -23,6 +23,6 @@ config = {
|
|||||||
'twitch': {'enabled': True},
|
'twitch': {'enabled': True},
|
||||||
'update': {'enabled': True},
|
'update': {'enabled': True},
|
||||||
'data_privacy': {'enabled': True},
|
'data_privacy': {'enabled': True},
|
||||||
'term_privacy': {'enabled': True}
|
'terms_privacy': {'enabled': True}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
main.py
17
main.py
@ -60,16 +60,19 @@ class Selena(discord.Client):
|
|||||||
twitch.setup(self.tree)
|
twitch.setup(self.tree)
|
||||||
|
|
||||||
if config['modules']['update']['enabled']:
|
if config['modules']['update']['enabled']:
|
||||||
from modules.admin.update import setup as update_setup
|
from modules.admin.update import Update
|
||||||
update_setup(self.tree)
|
update = Update(self)
|
||||||
|
update.setup(self.tree)
|
||||||
|
|
||||||
if config['modules']['data_privacy']['enabled']:
|
if config['modules']['data_privacy']['enabled']:
|
||||||
from modules.admin.data_privacy import setup as data_privacy_setup
|
from modules.admin.data_privacy import DataPrivacy
|
||||||
data_privacy_setup(self.tree)
|
data_privacy = DataPrivacy(self)
|
||||||
|
data_privacy.setup(self.tree)
|
||||||
|
|
||||||
if config['modules']['term_privacy']['enabled']:
|
if config['modules']['terms_privacy']['enabled']:
|
||||||
from modules.admin.term_privacy import setup as term_privacy_setup
|
from modules.admin.terms_privacy import TermsPrivacy
|
||||||
term_privacy_setup(self.tree)
|
terms_privacy = TermsPrivacy(self)
|
||||||
|
terms_privacy.setup(self.tree)
|
||||||
|
|
||||||
|
|
||||||
bot = Selena()
|
bot = Selena()
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import discord
|
import discord
|
||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
import os
|
import os
|
||||||
import logging
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
@ -16,34 +16,20 @@ class Update:
|
|||||||
self.logger.addHandler(handler)
|
self.logger.addHandler(handler)
|
||||||
|
|
||||||
async def update_bot(self, interaction: discord.Interaction):
|
async def update_bot(self, interaction: discord.Interaction):
|
||||||
|
await interaction.response.defer(ephemeral=True)
|
||||||
|
await interaction.followup.send(embed=discord.Embed(description="Updating Selena...", color=discord.Color.green()))
|
||||||
|
self.logger.info('Starting update process...')
|
||||||
try:
|
try:
|
||||||
await interaction.response.send_message(embed=discord.Embed(description="Updating Selena...", color=discord.Color.green()))
|
subprocess.run(["git", "pull"], check=True)
|
||||||
except discord.errors.InteractionResponded:
|
self.logger.info('Successfully pulled updates from git.')
|
||||||
await interaction.followup.send(embed=discord.Embed(description="Updating Selena...", color=discord.Color.green()))
|
await interaction.followup.send(embed=discord.Embed(description="Update complete. Restarting...", color=discord.Color.green()))
|
||||||
|
|
||||||
# Fetch updates from the specified branch
|
|
||||||
branch = 'main' # change this to your branch if necessary
|
|
||||||
result = subprocess.run(['git', 'pull', 'origin', branch], capture_output=True, text=True)
|
|
||||||
|
|
||||||
if result.returncode == 0:
|
|
||||||
self.logger.info("Successfully pulled updates from the repository")
|
|
||||||
self.logger.info(result.stdout)
|
|
||||||
try:
|
|
||||||
await interaction.followup.send(embed=discord.Embed(description="Successfully updated Selena. Restarting...", color=discord.Color.green()))
|
|
||||||
except discord.errors.InteractionResponded:
|
|
||||||
await interaction.followup.send(embed=discord.Embed(description="Successfully updated Selena. Restarting...", color=discord.Color.green()))
|
|
||||||
|
|
||||||
# Restart the bot (this is just a placeholder, modify according to your setup)
|
|
||||||
os.execv(sys.executable, ['python'] + sys.argv)
|
os.execv(sys.executable, ['python'] + sys.argv)
|
||||||
else:
|
except subprocess.CalledProcessError as e:
|
||||||
self.logger.error(f"Failed to pull updates: {result.stderr}")
|
self.logger.error(f'Error during update: {e}')
|
||||||
try:
|
await interaction.followup.send(embed=discord.Embed(description=f"Update failed: {e}", color=discord.Color.red()))
|
||||||
await interaction.followup.send(embed=discord.Embed(description="Failed to update Selena. Check logs for details.", color=discord.Color.red()))
|
|
||||||
except discord.errors.InteractionResponded:
|
|
||||||
await interaction.followup.send(embed=discord.Embed(description="Failed to update Selena. Check logs for details.", color=discord.Color.red()))
|
|
||||||
|
|
||||||
def setup(self, tree: app_commands.CommandTree):
|
def setup(self, tree: app_commands.CommandTree):
|
||||||
@tree.command(name="update", description="Update the bot to the latest version")
|
@tree.command(name="update", description="Update the bot from the repository")
|
||||||
async def update_command(interaction: discord.Interaction):
|
async def update_command(interaction: discord.Interaction):
|
||||||
await self.update_bot(interaction)
|
await self.update_bot(interaction)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user