-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathReactionEvent.cs
46 lines (38 loc) · 1.74 KB
/
ReactionEvent.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using static Cliptok.Program;
using static Cliptok.Constants.RegexConstants;
namespace Cliptok.Events
{
public class ReactionEvent
{
public static async Task OnReaction(DiscordClient _, MessageReactionAddedEventArgs e)
{
// Ignore DMs and other servers
if (e.Channel.IsPrivate || e.Guild.Id != cfgjson.ServerID)
return;
DiscordMessage targetMessage = await e.Channel.GetMessageAsync(e.Message.Id);
// Remove reactions from warning/mute/ban messages
if (targetMessage.Author.Id == discord.CurrentUser.Id &&
warn_msg_rx.IsMatch(targetMessage.Content) ||
auto_warn_msg_rx.IsMatch(targetMessage.Content) ||
mute_msg_rx.IsMatch(targetMessage.Content) ||
unmute_msg_rx.IsMatch(targetMessage.Content) ||
ban_msg_rx.IsMatch(targetMessage.Content) ||
unban_msg_rx.IsMatch(targetMessage.Content))
{
await targetMessage.DeleteReactionAsync(e.Emoji, e.User);
var emoji = e.Emoji.Id != 0 ? $"[{e.Emoji.Name}](<{e.Emoji.Url}>)" : e.Emoji.ToString();
await LogChannelHelper.LogMessageAsync("reactions", $"{cfgjson.Emoji.Deleted} Removed reaction {emoji} from [this message]({e.Message.JumpLink}) by {e.User.Mention}");
return;
}
// Remove self-heartosofts
if (e.Emoji.Id != cfgjson.HeartosoftId)
return;
// Avoid starboard race conditions
await Task.Delay(1000);
if (targetMessage.Author.Id == e.User.Id)
{
await targetMessage.DeleteReactionAsync(e.Emoji, e.User);
}
}
}
}