You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add 'channels' option to /tracking add
Allows filtering tracking to specific channels
* Account for threads
* Use regex to match any number of spaces when parsing channel list & trim
* Account for missing "trackingChannels" key in db
* Accept review suggestion
Co-authored-by: Erisa A <[email protected]>
---------
Co-authored-by: Erisa A <[email protected]>
Copy file name to clipboardexpand all lines: Commands/InteractionCommands/TrackingInteractions.cs
+79-1
Original file line number
Diff line number
Diff line change
@@ -7,12 +7,89 @@ internal class TrackingInteractions : ApplicationCommandModule
7
7
publicclassTrackingSlashCommands
8
8
{
9
9
[SlashCommand("add","Track a users messages.")]
10
-
publicasyncTaskTrackingAddSlashCmd(InteractionContextctx,[Option("member","The member to track.")]DiscordUserdiscordUser)
10
+
publicasyncTaskTrackingAddSlashCmd(InteractionContextctx,[Option("member","The member to track.")]DiscordUserdiscordUser,[Option("channels","Optional channels to filter to. Use IDs or mentions, and separate with commas or spaces.")]stringchannels="")
11
11
{
12
12
awaitctx.DeferAsync(ephemeral:false);
13
+
14
+
varchannelsUpdated=false;
15
+
16
+
// Resolve list of filter channels
17
+
List<ulong>filterChannels=new();
18
+
if(!string.IsNullOrEmpty(channels))
19
+
{
20
+
channels=Regex.Replace(channels,", +",",").Trim();// "#general-chat, #lounge" ~> "#general-chat,#lounge" & trim
awaitctx.FollowUpAsync(newDiscordFollowupMessageBuilder().WithContent($"{Program.cfgjson.Emoji.Error} I couldn't parse \"{channel}\" as a channel ID or mention! Please double-check it and try again."));
40
+
return;
41
+
}
42
+
}
43
+
}
44
+
45
+
// If we were passed nothing, filterChannels remains an empty List. Otherwise, it is populated with the parsed channel IDs
46
+
47
+
// Compare to db; if there is a mismatch, replace whatever is already in the db with what was passed to this command
0 commit comments