Improved logging for event_service
All checks were successful
Deploy staging on push / on-push-deploy_sh-edraft (push) Successful in 4m13s
All checks were successful
Deploy staging on push / on-push-deploy_sh-edraft (push) Successful in 4m13s
This commit is contained in:
parent
69882af0bd
commit
ad3fc94923
@ -99,6 +99,7 @@ class EventService:
|
||||
async def check_and_create_scheduled_events(self, guild: Guild):
|
||||
server = self._servers.get_server_by_discord_id(guild.id)
|
||||
scheduled_events_from_db = self._events.get_scheduled_events_by_server_id(server.id)
|
||||
self._logger.debug(__name__, f"Checking {scheduled_events_from_db.count()} events for server {guild.id}")
|
||||
for scheduled_event in scheduled_events_from_db:
|
||||
scheduled_event: ScheduledEvent = scheduled_event
|
||||
from_guild = List(DiscordEvent, guild.scheduled_events).where(
|
||||
@ -107,6 +108,7 @@ class EventService:
|
||||
and x.entity_type == scheduled_event.entity_type
|
||||
)
|
||||
if from_guild.count() != 0:
|
||||
self._logger.debug(__name__, f"Event {scheduled_event.name} already exists on discord server")
|
||||
continue
|
||||
|
||||
kwargs = {"name": scheduled_event.name, "description": scheduled_event.description}
|
||||
@ -135,9 +137,10 @@ class EventService:
|
||||
kwargs["privacy_level"] = PrivacyLevel.guild_only
|
||||
|
||||
try:
|
||||
self._logger.debug(__name__, f"Try to create scheduled event for guild {guild.name}")
|
||||
self._logger.trace(__name__, f"Try to create scheduled event for guild {guild.name}")
|
||||
await guild.create_scheduled_event(**kwargs)
|
||||
self._events.update_scheduled_event(scheduled_event)
|
||||
self._db.save_changes()
|
||||
self._logger.debug(__name__, f"Created scheduled event for guild {guild.name}")
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f"Watching scheduled events failed", e)
|
||||
|
Loading…
Reference in New Issue
Block a user