-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReplyQuoteListener.cs
39 lines (32 loc) · 1.19 KB
/
ReplyQuoteListener.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
using Discord;
using Discord.WebSocket;
using SimpleDiscordNet.MessageReceived;
namespace QuoteBot;
public class ReplyQuoteListener {
[MessageListener]
public async Task MessageListen(SocketMessage msg, DiscordSocketClient client) {
if (msg.Channel is not IGuildChannel channel) {
return;
}
if (msg.MentionedUsers.All(u => u.Id != client.CurrentUser.Id)) {
return;
}
if (msg.Reference == null || !msg.Reference.MessageId.IsSpecified) {
await msg.Channel.SendMessageAsync("Reply to a message and ping me to quote it.",
messageReference: msg.ToReference());
return;
}
IMessage quotedMsg = await msg.Channel.GetMessageAsync(msg.Reference.MessageId.Value);
await Quoting.QuoteMessage(client,
channel.GuildId,
quotedMsg.Author.Username,
msg.Author.Username,
msg.Author.Id,
quotedMsg.Author.Id.ToString(),
quotedMsg.Content,
quotedMsg.Author,
quotedMsg.Channel.Id,
quotedMsg.Id);
await msg.AddReactionAsync(Emoji.Parse(":white_check_mark:"));
}
}