-
Notifications
You must be signed in to change notification settings - Fork 13
/
DiscordChannelCreateScriptEvent.java
69 lines (60 loc) · 2.19 KB
/
DiscordChannelCreateScriptEvent.java
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.denizenscript.ddiscordbot.events;
import com.denizenscript.ddiscordbot.DiscordScriptEvent;
import com.denizenscript.ddiscordbot.objects.DiscordChannelTag;
import com.denizenscript.ddiscordbot.objects.DiscordGroupTag;
import com.denizenscript.denizencore.objects.ObjectTag;
import net.dv8tion.jda.api.events.channel.ChannelCreateEvent;
public class DiscordChannelCreateScriptEvent extends DiscordScriptEvent {
// <--[event]
// @Events
// discord channel created
//
// @Switch for:<bot> to only process the event for a specified Discord bot.
// @Switch group:<group_id> to only process the event for a specified Discord group.
// @Switch type:<type> to only process the event if the channel is a specific channel_type.
//
// @Triggers when a Discord channel is created.
//
// @Plugin dDiscordBot
//
// @Group Discord
//
// @Context
// <context.bot> returns the relevant DiscordBotTag.
// <context.group> returns the DiscordGroupTag.
// <context.channel> returns the new DiscordChannelTag.
// -->
public static DiscordChannelCreateScriptEvent instance;
public DiscordChannelCreateScriptEvent() {
instance = this;
registerCouldMatcher("discord channel created");
registerSwitches("group", "type");
}
public ChannelCreateEvent getEvent() {
return (ChannelCreateEvent) event;
}
@Override
public boolean matches(ScriptPath path) {
if (!tryGuild(path, getEvent().getGuild())) {
return false;
}
if (!runGenericSwitchCheck(path, "type", getEvent().getChannelType().name())) {
return false;
}
return super.matches(path);
}
@Override
public ObjectTag getContext(String name) {
switch (name) {
case "group":
return new DiscordGroupTag(botID, getEvent().getGuild());
case "channel":
return new DiscordChannelTag(botID, getEvent().getChannel());
}
return super.getContext(name);
}
@Override
public String getName() {
return "DiscordChannelCreated";
}
}