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 17, 2023
1 parent d9a59c3 commit 91d14b2
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions src/Miha.Discord/Services/Hosted/GuildEventScheduleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,34 @@ private async Task PostWeeklyScheduleAsync()
}

description.AppendLine("### " + day + " - " + DiscordTimestampExtensions.ToDiscordTimestamp(events.First().StartTime.Date, 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.AppendLine($" - {guildEvent.StartTime.ToDiscordTimestamp(TimestampTagStyles.ShortTime)} - {guildEvent.StartTime.ToDiscordTimestamp(TimestampTagStyles.Relative)}");

if (guildEvent.Creator is not null)
if (!events.Any())
{
description.AppendLine("No events are scheduled this day");
}
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.AppendLine($" - {guildEvent.StartTime.ToDiscordTimestamp(TimestampTagStyles.ShortTime)} - {guildEvent.StartTime.ToDiscordTimestamp(TimestampTagStyles.Relative)}");

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



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

0 comments on commit 91d14b2

Please sign in to comment.