Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ Bob The Bot has many features all of which are `/slash` commands for ease of use
- `/preview message [link]` Preview a Discord message from any server Bob is in.
- `/preview color [color]` Preview what a color looks like, and get more information.

### ⏰ Reminder Commands:
- `/remind set [message] [month] [day] [hour] [minute] [timezone]` Bob will DM you a reminder at a specified time.
- `/remind in [message] [days] [hours] [minutes]` Bob will DM you a reminder after a relative amount of time.
- `/remind delete [id]` Delete one of your scheduled reminders.
- `/remind list` List your upcoming reminders.

### 🕖 Schedule Commands:
- `/schedule message [message] [channel] [month] [day] [hour] [minute] [timezone]` Bob will send your message at a specified time.
- `/schedule announcement [title] [description] [color] [channel] [month] [day] [hour] [minute] [timezone]` Bob will send an embed at a specified time.
Expand Down
104 changes: 103 additions & 1 deletion commands/debug-group/debugCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,11 @@ public async Task AllTableStats()
int newsChannelEntriesCount = await dbContext.NewsChannel.CountAsync();
int scheduledMessageEntriesCount = await dbContext.ScheduledMessage.CountAsync();
int scheduledAnnouncementEntriesCount = await dbContext.ScheduledAnnouncement.CountAsync();
int scheduledReminderEntriesCount = await dbContext.ScheduledReminder.CountAsync();
int welcomeImageEntriesCount = await dbContext.WelcomeImage.CountAsync();
int memoryEntriesCount = await dbContext.Memory.CountAsync();
int tagEntriesCount = await dbContext.Tag.CountAsync();
int reactBoardMessageEntriesCount = await dbContext.ReactBoardMessage.CountAsync();
double size = await dbContext.GetDatabaseSizeBytes();

var embed = new EmbedBuilder
Expand All @@ -174,7 +177,10 @@ public async Task AllTableStats()
.AddField(name: "NewsChannel Entries", value: $"`{newsChannelEntriesCount}`", inline: true)
.AddField(name: "Scheduled Message Entries", value: $"`{scheduledMessageEntriesCount}`", inline: true)
.AddField(name: "Scheduled Announcement Entries", value: $"`{scheduledAnnouncementEntriesCount}`", inline: true)
.AddField(name: "Memory Entries", value: $"{memoryEntriesCount}`", inline: true)
.AddField(name: "Scheduled Reminder Entries", value: $"`{scheduledReminderEntriesCount}`", inline: true)
.AddField(name: "Memory Entries", value: $"`{memoryEntriesCount}`", inline: true)
.AddField(name: "Tag Entries", value: $"`{tagEntriesCount}`", inline: true)
.AddField(name: "ReactBoard Message Entries", value: $"`{reactBoardMessageEntriesCount}`", inline: true)
.AddField(name: "Size (Bytes)", value: $"`{size}`", inline: true)
.AddField(name: "Size (MegaBytes)", value: $"`{size / 1024 / 1024}`", inline: true)
.AddField(name: "Size (GigaBytes)", value: $"`{size / 1024 / 1024 / 1024}`", inline: true);
Expand Down Expand Up @@ -631,6 +637,102 @@ public async Task RemoveScheduledAnnouncement(string announcementId)
await FollowupAsync(text: $"✅ Deleted Scheduled Announcement `{parsedAnnouncementId}`.");
}
}

[SlashCommand("remove-scheduled-reminder", "Removes the ScheduledReminder with the given ID from the database.")]
public async Task RemoveScheduledReminder(string reminderId)
{
await DeferAsync();

if (!ulong.TryParse(reminderId, out ulong parsedId))
{
await FollowupAsync(text: $"❌ The given `reminderId` is not valid.");
return;
}

var reminder = await dbContext.GetScheduledReminder(parsedId);
if (reminder == null)
{
await FollowupAsync(text: $"❌ No reminder found with ID `{reminderId}`.");
return;
}

await dbContext.RemoveScheduledReminder(parsedId);

if (Bob.Commands.Helpers.Schedule.ScheduledTasks.TryGetValue(parsedId, out var cts))
{
cts.Cancel();
Bob.Commands.Helpers.Schedule.ScheduledTasks.Remove(parsedId);
}

await FollowupAsync(text: $"✅ Deleted Scheduled Reminder `{parsedId}`.");
}

[SlashCommand("set-user-reminder-total", "Edit the scheduled reminder total for a user.")]
public async Task SetUserReminderTotal(int value, IUser user = null, string userId = null)
{
await DeferAsync();

bool conversionResult = ulong.TryParse(userId, out ulong parsedId);

if (user == null && userId == null)
{
await FollowupAsync(text: $"❌ You **must** specify a `user` **or** a `userId`.");
return;
}

IUser discordUser = user ?? await Client.GetShardFor(Context.Guild).GetUserAsync(parsedId);

if (discordUser.IsBot)
{
await FollowupAsync(text: $"❌ You **cannot** perform this action on bots.");
}
else if (user != null && conversionResult != false && user.Id != parsedId)
{
await FollowupAsync(text: $"❌ The given `user` **and** `userId` must have matching IDs.");
}
else if (value < 0)
{
await FollowupAsync(text: $"❌ The given `value` must be greater than 0 (The field is a `uint`).");
}
else
{
User dbUser = await dbContext.GetOrCreateUserAsync(user == null ? parsedId : user.Id);
dbUser.TotalReminders = (uint)value;
await dbContext.SaveChangesAsync();

await FollowupAsync(text: $"✅ `Reminder Count of User: {discordUser.GlobalName}, {discordUser.Id} updated.`\n{UserDebugging.GetUserPropertyString(dbUser)}");
}
}

[SlashCommand("get-user-reminders", "Lists all scheduled reminders for a user.")]
public async Task GetUserReminders(IUser user = null, string userId = null)
{
await DeferAsync();

bool conversionResult = ulong.TryParse(userId, out ulong parsedId);

if (user == null && userId == null)
{
await FollowupAsync(text: $"❌ You **must** specify a `user` **or** a `userId`.");
return;
}

ulong targetId = user?.Id ?? parsedId;
var reminders = await dbContext.GetScheduledRemindersForUser(targetId);

if (reminders.Count == 0)
{
await FollowupAsync(text: $"📭 No reminders found for user `{targetId}`.");
return;
}

var sb = new StringBuilder();
sb.AppendLine($"⏰ **Reminders for `{targetId}`:**");
foreach (var r in reminders)
sb.AppendLine($"- `{r.Id}` | <t:{new DateTimeOffset(r.TimeToSend, TimeSpan.Zero).ToUnixTimeSeconds()}:F> | {r.Message}");

await FollowupAsync(text: sb.ToString());
}
}
}
}
58 changes: 58 additions & 0 deletions commands/no-group/helpers/help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,64 @@ public static Embed GetCommandEmbed(CommandInfo command)
},
]
},
new() {
Title = "Reminders",
Description = "Commands for setting and managing personal reminders delivered via DM.",
Name = "remind",
Emoji = "⏰",
Url = "https://docs.bobthebot.net/#remind",
Commands =
[
new CommandInfo
{
Name = "set",
InheritGroupName = true,
Description = "Bob will DM you a reminder at a specified date and time.",
Url = "https://docs.bobthebot.net/#remind-set",
Parameters =
[
new ParameterInfo { Name = "message", Description = "What you want to be reminded of." },
new ParameterInfo { Name = "month", Description = "The month for the reminder." },
new ParameterInfo { Name = "day", Description = "The day for the reminder." },
new ParameterInfo { Name = "hour", Description = "The hour for the reminder, in military time (if PM, add 12)." },
new ParameterInfo { Name = "minute", Description = "The minute for the reminder." },
new ParameterInfo { Name = "timezone", Description = "Your timezone." }
]
},
new CommandInfo
{
Name = "in",
InheritGroupName = true,
Description = "Bob will DM you a reminder after a relative amount of time.",
Url = "https://docs.bobthebot.net/#remind-in",
Parameters =
[
new ParameterInfo { Name = "message", Description = "What you want to be reminded of." },
new ParameterInfo { Name = "days", Description = "Number of days from now." },
new ParameterInfo { Name = "hours", Description = "Number of hours from now." },
new ParameterInfo { Name = "minutes", Description = "Number of minutes from now." }
]
},
new CommandInfo
{
Name = "delete",
InheritGroupName = true,
Description = "Delete one of your scheduled reminders.",
Url = "https://docs.bobthebot.net/#remind-delete",
Parameters =
[
new ParameterInfo { Name = "id", Description = "The ID of the reminder to delete." }
]
},
new CommandInfo
{
Name = "list",
InheritGroupName = true,
Description = "List all of your upcoming reminders.",
Url = "https://docs.bobthebot.net/#remind-list",
}
]
},
new() {
Title = "Scheduling",
Description = "A collection of commands for scheduling messages and announcements.",
Expand Down
Loading
Loading