Skip to content

Commit

Permalink
Update GuildEventScheduleService.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Twinki14 committed Nov 18, 2023
1 parent 9d7fc96 commit 219fb9f
Showing 1 changed file with 33 additions and 25 deletions.
58 changes: 33 additions & 25 deletions src/Miha.Discord/Services/Hosted/GuildEventScheduleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,36 +178,44 @@ private async Task PostWeeklyScheduleAsync()
postedHeader = true;
}

_logger.LogInformation("{DateTime}", day.ToLocalDate().AtStartOfDayInZone(_easternStandardZonedClock.GetTzdbTimeZone()).ToInstant().ToUnixTimeSeconds());
description.AppendLine("### " + day.ToString("dddd") + " - " + day.ToLocalDate().AtStartOfDayInZone(_easternStandardZonedClock.GetTzdbTimeZone()).ToInstant().ToDiscordTimestamp(TimestampTagStyles.ShortDate));

foreach (var guildEvent in events.OrderBy(e => e.StartTime))
{
var location = guildEvent.Location ?? "Unknown";
var url = $"https://discord.com/events/{guildEvent.Guild.Id}/{guildEvent.Id}";

if (location is "Unknown" && guildEvent.ChannelId is not null)
{
location = "Discord";
}

description.AppendLine($"- [{location} - {guildEvent.Name}]({url})");

description.Append($" - {guildEvent.StartTime.ToDiscordTimestamp(TimestampTagStyles.ShortTime)}");
if (guildEvent.Status is GuildScheduledEventStatus.Active)
{
description.AppendLine(" - Happening now!");
}
else
{
description.AppendLine($" - {guildEvent.StartTime.ToDiscordTimestamp(TimestampTagStyles.Relative)}");
}

if (guildEvent.Creator is not null)
if (!events.Any())
{
description.AppendLine("*No events scheduled*");
}
else
{
foreach (var guildEvent in events.OrderBy(e => e.StartTime))
{
description.AppendLine($" - Hosted by {guildEvent.Creator.Mention}");
var location = guildEvent.Location ?? "Unknown";
var url = $"https://discord.com/events/{guildEvent.Guild.Id}/{guildEvent.Id}";

if (location is "Unknown" && guildEvent.ChannelId is not null)
{
location = "Discord";
}

description.AppendLine($"- [{location} - {guildEvent.Name}]({url})");

description.Append($" - {guildEvent.StartTime.ToDiscordTimestamp(TimestampTagStyles.ShortTime)}");
if (guildEvent.Status is GuildScheduledEventStatus.Active)
{
description.AppendLine(" - Happening now!");
}
else
{
description.AppendLine($" - {guildEvent.StartTime.ToDiscordTimestamp(TimestampTagStyles.Relative)}");
}

if (guildEvent.Creator is not null)
{
description.AppendLine($" - Hosted by {guildEvent.Creator.Mention}");
}
}
}

embed.WithFooter(day.ToString("dddd"));

if (!postedFooter && day == eventsByDay.Last().Key)
Expand Down

0 comments on commit 219fb9f

Please sign in to comment.