forked from Anuken/Egg
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEgg.java
More file actions
22 lines (17 loc) · 1007 Bytes
/
Egg.java
File metadata and controls
22 lines (17 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import discord4j.core.*;
import discord4j.core.event.domain.message.*;
import discord4j.core.object.entity.*;
import discord4j.core.object.reaction.*;
import java.text.*;
public class Egg{
public static void main(String[] args){
final DiscordClient client = new DiscordClientBuilder(System.getProperty("token")).build();
client.getEventDispatcher().on(MessageCreateEvent.class).map(MessageCreateEvent::getMessage)
.filter(msg -> msg.getContent().map(s -> Normalizer.normalize(s.toLowerCase(), Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "").contains("egg")).orElse(false))
.flatMap(m -> m.addReaction(ReactionEmoji.unicode("\uD83E\uDD5A")))
.subscribe();
client.getEventDispatcher().on(MessageCreateEvent.class).map(MessageCreateEvent::getMessage).filter(m -> Math.random() < 1.0 / 700.0)
.flatMap(Message::getChannel).flatMap(channel -> channel.createMessage("egg")).subscribe();
client.login().block();
}
}