fix event stop
This commit is contained in:
2 files changed
+9
-8
No files matched your search
+8
-7
@@ -19,7 +19,7 @@ class Event(app_commands.Group):
|
||||
async def start(self, interaction: Interaction) -> None:
|
||||
if not self.hasPermission(interaction.user): await interaction.response.send_message("You don't have permission to use this command.", ephemeral=True)
|
||||
if self.bot._running: await interaction.response.send_message("Event already started", ephemeral=True)
|
||||
self.bot.scrape_file.start()
|
||||
self.bot.scraper.start()
|
||||
self.bot._running = True
|
||||
await interaction.response.send_message("Starting new event leaderboard...", ephemeral=True)
|
||||
|
||||
@@ -28,6 +28,8 @@ class Event(app_commands.Group):
|
||||
if not self.hasPermission(interaction.user): await interaction.response.send_message("You don't have permission to use this command.", ephemeral=True)
|
||||
if not self.bot._running: await interaction.response.send_message("Event already stopped", ephemeral=True)
|
||||
|
||||
self.bot.scraper.cancel()
|
||||
|
||||
# Reset trackers
|
||||
self.bot._running = False
|
||||
self.bot.log_file = ""
|
||||
@@ -37,13 +39,12 @@ class Event(app_commands.Group):
|
||||
self.bot.gamertags = []
|
||||
self.bot.message_id = ""
|
||||
|
||||
self.sftp.close()
|
||||
self.ssh.close()
|
||||
self.sftp = None
|
||||
self.ssh = None
|
||||
self.bot.sftp.close()
|
||||
self.bot.ssh.close()
|
||||
self.bot.sftp = None
|
||||
self.bot.ssh = None
|
||||
|
||||
await interaction.response.send_message("Stopping event leaderboard...", ephemeral=True)
|
||||
self.bot.scrape_file.stop()
|
||||
|
||||
|
||||
async def setup(bot: commands.Bot) -> None:
|
||||
bot.tree.add_command(Event(bot, name="event", description="start or stop an event leaderboard"))
|
||||
@@ -78,7 +78,7 @@ class ReforgerStats(commands.Bot):
|
||||
requests.patch(f"{self.config.WEBHOOK}/messages/{self.message_id}", json=content).status_code
|
||||
|
||||
@tasks.loop(seconds=60)
|
||||
async def scrape_file(self) -> None:
|
||||
async def scraper(self: commands.Bot) -> None:
|
||||
# Create SSH && SFTP sessions if needed
|
||||
if self.ssh is None or self.sftp is None: self.sftp, self.ssh = createSSHClient(self.config)
|
||||
|
||||
|
||||
Reference in new issue
Block a user