public async Task RemoveOfficerNote(IUser discordUser, string categoryName, [Summary("dd/mm/yyyy")] string dateTime, [Remainder] string comment = null) { if (DiscordUtilities.UserIsInCallingOfficersGuild(Context.User as SocketGuildUser, discordUser as SocketGuildUser)) { // TODO: This could be parsed simply by DateTime.Parse var datetimeParts = dateTime.Split('/'); var dayString = datetimeParts[0]; var monthString = datetimeParts[1]; var yearString = datetimeParts[2]; if (!int.TryParse(dayString, out var day)) { throw new Exception("Could not parse the day from the datetime string, are you using dd/mm/yyyy format?"); } if (!int.TryParse(monthString, out var month)) { throw new Exception("Could not parse the month from the datetime string, are you using dd/mm/yyyy format?"); } if (!int.TryParse(yearString, out var year)) { throw new Exception("Could not parse the year from the datetime string, are you using dd/mm/yyyy format?"); } await DbService.RemoveOfficerNotesAsync(discordUser.Id, categoryName, new DateTime(year, month, day), comment); await ReplyNewEmbed($"Removed the note successfully", Color.Green); } else { await ReplyNewEmbed("You cannot access members in other guilds.", Color.Red); } }
public async Task AddOfficerNote(IUser discordUser, string categoryName, [Remainder] string notes) { if (DiscordUtilities.UserIsInCallingOfficersGuild(Context.User as SocketGuildUser, discordUser as SocketGuildUser)) { await DbService.AddOfficerNote(categoryName, discordUser.Id, notes); await ReplyNewEmbed("Added the note successfully", Color.Green); } else { await ReplyNewEmbed("You cannot access members in other guilds.", Color.Red); } }