Skip to content

Commit

Permalink
Merge pull request #23 from rarDevelopment/dev
Browse files Browse the repository at this point in the history
updating discord helper lib
  • Loading branch information
rarDevelopment authored Sep 2, 2023
2 parents 6ec4b1c + 3ee0c55 commit 6208528
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 58 deletions.
4 changes: 2 additions & 2 deletions TimeZoneBot/Commands/BirthdayAllCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task BirthdayAllSlashCommand(
.WithButton("Sort Alphabetically", $"birthdaySort:{BirthdaySortOrder.Alphabetical}",
emote: new Emoji("🔤"));

await FollowupAsync(embed: _discordFormatter.BuildRegularEmbed("Birthdays", message, Context.User), components: buttonBuilder.Build());
await FollowupAsync(embed: _discordFormatter.BuildRegularEmbedWithUserFooter("Birthdays", message, Context.User), components: buttonBuilder.Build());
}

private async Task<string> BuildAllBirthdaysMessage(IEnumerable<SocketGuildUser> members,
Expand Down Expand Up @@ -128,7 +128,7 @@ public async Task SortButton(string sortingTypeParam)
await Context.Interaction.ModifyOriginalResponseAsync(properties =>
{
properties.Embed =
_discordFormatter.BuildRegularEmbed($"Birthdays ({ParseSortByName(birthdaySortOrderType)})",
_discordFormatter.BuildRegularEmbedWithUserFooter($"Birthdays ({ParseSortByName(birthdaySortOrderType)})",
message, Context.User);
});
}
Expand Down
30 changes: 15 additions & 15 deletions TimeZoneBot/Commands/BirthdayCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,31 @@ public async Task BirthdaySlashCommand(
var birthday = await _birthdayBusinessLayer.GetBirthdayForPerson(user.Id.ToString());
if (birthday == null)
{
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Error Finding Birthday",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Error Finding Birthday",
"Could not find birthday for person.", Context.User));
return;
}

var message = BuildBirthdayMessage(birthday.Value);
await FollowupAsync(embed: _discordFormatter.BuildRegularEmbed($"{user.GetNameToDisplay()}'s Birthday",
await FollowupAsync(embed: _discordFormatter.BuildRegularEmbedWithUserFooter($"{user.GetNameToDisplay()}'s Birthday",
message, Context.User));
}
catch (PersonNotFoundException ex)
{
_logger.LogError(ex, "PersonNotFound in BirthdaySlashCommand");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Person Not Found",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Person Not Found",
"That person wasn't found!", Context.User));
}
catch (NoBirthdayException ex)
{
_logger.LogError(ex, "NoBirthday in BirthdaySlashCommand");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Birthday Not Found",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Birthday Not Found",
"No birthday is configured for this person.", Context.User));
}
catch (Exception ex)
{
_logger.LogError(ex, "Unhandled error in BirthdaySlashCommand");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Something Went Wrong",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Something Went Wrong",
"There was an unexpected error.", Context.User));
}
}
Expand All @@ -87,31 +87,31 @@ public async Task BirthdayMessageCommand(SocketMessage message)
var birthdayForPerson = await _birthdayBusinessLayer.GetBirthdayForPerson(user.Id.ToString());
if (birthdayForPerson == null)
{
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Error Finding Time",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Error Finding Time",
"Could not find time for person.", Context.User));
return;
}

var messageToSend = BuildBirthdayMessage(birthdayForPerson.Value);
await FollowupAsync(embed: _discordFormatter.BuildRegularEmbed($"{user.GetNameToDisplay()}'s Birthday",
await FollowupAsync(embed: _discordFormatter.BuildRegularEmbedWithUserFooter($"{user.GetNameToDisplay()}'s Birthday",
messageToSend, Context.User));
}
catch (PersonNotFoundException ex)
{
_logger.LogError(ex, "PersonNotFound in BirthdayMessageCommand");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Person Not Found",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Person Not Found",
"That person wasn't found!", Context.User));
}
catch (NoBirthdayException ex)
{
_logger.LogError(ex, "NoBirthday in BirthdayMessageCommand");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Birthday Not Found",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Birthday Not Found",
"No birthday is configured for this person.", Context.User));
}
catch (Exception ex)
{
_logger.LogError(ex, "Unhandled error in BirthdayMessageCommand");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Something Went Wrong",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Something Went Wrong",
"There was an unexpected error.", Context.User));
}
}
Expand All @@ -126,31 +126,31 @@ public async Task BirthdayUserCommand(SocketUser user)
var birthdayForPerson = await _birthdayBusinessLayer.GetBirthdayForPerson(user.Id.ToString());
if (birthdayForPerson == null)
{
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Error Finding Time",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Error Finding Time",
"Could not find time for person.", Context.User));
return;
}

var messageToSend = BuildBirthdayMessage(birthdayForPerson.Value);
await FollowupAsync(embed: _discordFormatter.BuildRegularEmbed($"{user.GetNameToDisplay()} 's Birthday",
await FollowupAsync(embed: _discordFormatter.BuildRegularEmbedWithUserFooter($"{user.GetNameToDisplay()} 's Birthday",
messageToSend, Context.User));
}
catch (PersonNotFoundException ex)
{
_logger.LogError(ex, "PersonNotFound in BirthdayUserCommand");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Person Not Found",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Person Not Found",
"That person wasn't found!", Context.User));
}
catch (NoBirthdayException ex)
{
_logger.LogError(ex, "NoBirthday in BirthdayUserCommand");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Birthday Not Found",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Birthday Not Found",
"No birthday is configured for this person.", Context.User));
}
catch (Exception ex)
{
_logger.LogError(ex, "Unhandled error in BirthdayUserCommand");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Something Went Wrong",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Something Went Wrong",
"There was an unexpected error.", Context.User));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public async Task SetReactionsEnabledSlashCommand(
if (!wasSet)
{
_logger.LogError($"Failed to set EnableBirthdayAnnouncements to {isEnabled} - SetReactionsEnabled returned false.");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Failed to Set Birthday Announcements Configuration",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Failed to Set Birthday Announcements Configuration",
"There was an error changing that setting.", Context.User));
return;
}

await FollowupAsync(embed: _discordFormatter.BuildRegularEmbed("Birthday Announcements Configuration Set Successfully",
await FollowupAsync(embed: _discordFormatter.BuildRegularEmbedWithUserFooter("Birthday Announcements Configuration Set Successfully",
$"Birthday Announcements are **{(isEnabled ? "ON" : "OFF")}**", Context.User));
}
}
6 changes: 3 additions & 3 deletions TimeZoneBot/Commands/SetBirthdayCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task SetBirthdaySlashCommand(
catch (Exception ex)
{
_logger.LogError(ex, "Failed to parse birthday from entered date");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Invalid Birthday",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Invalid Birthday",
"The provided birthday was not valid.",
member));
return;
Expand All @@ -56,12 +56,12 @@ await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Invalid Birthday",
if (!wasSet)
{
_logger.LogError($"Failed to set birthday to {birthdayDate} - SetBirthday returned false.");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Failed to Set Time Zone",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Failed to Set Time Zone",
"There was an error setting the time zone.", Context.User));
return;
}

await FollowupAsync(embed: _discordFormatter.BuildRegularEmbed("Birthday Set Successfully",
await FollowupAsync(embed: _discordFormatter.BuildRegularEmbedWithUserFooter("Birthday Set Successfully",
$"Birthday was successfully set to {birthdayDate}", Context.User));
}
}
6 changes: 3 additions & 3 deletions TimeZoneBot/Commands/SetDefaultTimeZoneCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task SetDefaultTimeZoneSlashCommand(
var timeZone = DateTimeZoneProviders.Tzdb.GetZoneOrNull(timeZoneName);
if (timeZone == null)
{
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Invalid Time Zone",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Invalid Time Zone",
"The provided time zone was not valid. Please visit https://rardk64.com/timezones/ and set your time zone there, or copy it and set it here.",
member));
return;
Expand All @@ -54,12 +54,12 @@ await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Invalid Time Zone"
if (!wasSet)
{
_logger.LogError($"Failed to set DefaultTimeZone to {timeZoneName} - SetDefaultTimeZone returned false.");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Failed to Set Time Reactions Configuration",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Failed to Set Time Reactions Configuration",
"There was an error changing that setting.", Context.User));
return;
}

await FollowupAsync(embed: _discordFormatter.BuildRegularEmbed("Default Time Zone Set Successfully",
await FollowupAsync(embed: _discordFormatter.BuildRegularEmbedWithUserFooter("Default Time Zone Set Successfully",
$"Server Default Time Zone is set to **{timeZoneName}**", Context.User));
}
}
4 changes: 2 additions & 2 deletions TimeZoneBot/Commands/SetReactionsEnabledCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public async Task SetReactionsEnabledSlashCommand(
if (!wasSet)
{
_logger.LogError($"Failed to set EnableReactions to {isEnabled} - SetReactionsEnabled returned false.");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Failed to Set Time Reactions Configuration",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Failed to Set Time Reactions Configuration",
"There was an error changing that setting.", Context.User));
return;
}

await FollowupAsync(embed: _discordFormatter.BuildRegularEmbed("Time Reactions Configuration Set Successfully",
await FollowupAsync(embed: _discordFormatter.BuildRegularEmbedWithUserFooter("Time Reactions Configuration Set Successfully",
$"Time Reactions are **{(isEnabled ? "ON" : "OFF")}**", Context.User));
}
}
12 changes: 6 additions & 6 deletions TimeZoneBot/Commands/SetTimeZoneCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task SetTimeZoneSlashCommand(
var timeZone = DateTimeZoneProviders.Tzdb.GetZoneOrNull(timeZoneName);
if (timeZone == null)
{
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Invalid Time Zone",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Invalid Time Zone",
"The provided time zone was not valid. Please visit https://rardk64.com/timezones/ and set your time zone there, or copy it and set it here..",
member));
return;
Expand All @@ -49,7 +49,7 @@ await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Invalid Time Zone"
if (!wasSet)
{
_logger.LogError($"Failed to set time zone with name {timeZoneName} - SetTimeZone returned false.");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Failed to Set Time Zone",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Failed to Set Time Zone",
"There was an error setting the time zone.", Context.User));
return;
}
Expand All @@ -59,24 +59,24 @@ await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Failed to Set Time
var time = await _timeZoneBusinessLayer.GetTimeForPerson(Context.User.Id.ToString());
if (time == null)
{
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Error Finding Time",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Error Finding Time",
"Could not find time for person.", Context.User));
return;
}

await FollowupAsync(embed: _discordFormatter.BuildRegularEmbed("Time Zone Set Successfully",
await FollowupAsync(embed: _discordFormatter.BuildRegularEmbedWithUserFooter("Time Zone Set Successfully",
$"Time Zone was successfully set to {timeZoneName}, and the current time should be: {TimeHelpers.FormatTime(time.Value.TimeOfDay)}", Context.User));
}
catch (NoTimeZoneException ex)
{
_logger.LogError(ex, "NoTimeZone in SetTimeZoneCommand");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Time Zone Not Found",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Time Zone Not Found",
"The associated time zone was not valid.", Context.User));
}
catch (Exception ex)
{
_logger.LogError(ex, "Unhandled error in SetTimeZoneCommand");
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbed("Something Went Wrong",
await FollowupAsync(embed: _discordFormatter.BuildErrorEmbedWithUserFooter("Something Went Wrong",
"There was an unexpected error.", Context.User));
}
}
Expand Down
2 changes: 1 addition & 1 deletion TimeZoneBot/Commands/TimeAllCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async Task TimeAllSlashCommand(

if (!string.IsNullOrEmpty(messageToSend))
{
await FollowupAsync(embed: _discordFormatter.BuildRegularEmbed("Current Time for Everyone in this Channel",
await FollowupAsync(embed: _discordFormatter.BuildRegularEmbedWithUserFooter("Current Time for Everyone in this Channel",
messageToSend, Context.User));
}
}
Expand Down
Loading

0 comments on commit 6208528

Please sign in to comment.