-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d187eb3
commit 6829452
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
namespace Cliptok.Commands.InteractionCommands | ||
{ | ||
internal class JoinwatchInteractions : ApplicationCommandModule | ||
{ | ||
[SlashCommand("joinwatch", "Watch for joins and leaves of a given user. Output goes to #investigations.", defaultPermission: false)] | ||
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator)] | ||
public async Task JoinwatchSlashCmd(InteractionContext ctx, | ||
[Option("user", "The user to watch for joins and leaves of.")] DiscordUser user, | ||
[Option("note", "An optional note for context.")] string note = "") | ||
{ | ||
var joinWatchlist = await Program.db.ListRangeAsync("joinWatchedUsers"); | ||
|
||
if (joinWatchlist.Contains(user.Id)) | ||
{ | ||
if (note != "") | ||
{ | ||
// User is already joinwatched, just update note | ||
await Program.db.HashSetAsync("joinWatchedUsersNotes", user.Id, note); | ||
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Success} Successfully updated the note for {user.Mention}. Run again with no note to unwatch."); | ||
return; | ||
} | ||
|
||
// User is already joinwatched, unwatch | ||
Program.db.ListRemove("joinWatchedUsers", joinWatchlist.First(x => x == user.Id)); | ||
await Program.db.HashDeleteAsync("joinWatchedUsersNotes", user.Id); | ||
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Success} Successfully unwatched {user.Mention}, since they were already in the list."); | ||
} | ||
else | ||
{ | ||
// User is not joinwatched, watch | ||
await Program.db.ListRightPushAsync("joinWatchedUsers", user.Id); | ||
if (note != "") | ||
await Program.db.HashSetAsync("joinWatchedUsersNotes", user.Id, note); | ||
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Success} Now watching for joins/leaves of {user.Mention} to send to the investigations channel" | ||
+ (note == "" ? "!" : $" with the following note:\n>>> {note}")); | ||
} | ||
} | ||
} | ||
|
||
} |