-
Notifications
You must be signed in to change notification settings - Fork 14
DiscordInviteCreateScriptEvent #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
c9d57e8
59ac4b2
12c58c6
b64107d
f6c86b8
5343955
c7a0bcd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| 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.ddiscordbot.objects.DiscordUserTag; | ||
| import com.denizenscript.denizencore.objects.ObjectTag; | ||
| import com.denizenscript.denizencore.objects.core.ElementTag; | ||
| import net.dv8tion.jda.api.events.guild.invite.GuildInviteCreateEvent; | ||
|
|
||
| public class DiscordInviteCreateScriptEvent extends DiscordScriptEvent { | ||
|
|
||
| // <--[event] | ||
| // @Events | ||
| // discord invitation 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. | ||
mcmonkey4eva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // | ||
| // @Triggers when a Discord user creates an invitation. | ||
| // | ||
| // @Plugin dDiscordBot | ||
| // | ||
| // @Group Discord | ||
| // | ||
| // @Context | ||
| // <context.bot> returns the relevant DiscordBotTag. | ||
| // <context.group> returns the DiscordGroupTag. | ||
| // <context.channel> returns the DiscordChannelTag. | ||
|
||
| // <context.user> returns the DiscordUserTag of the invitation creator. | ||
| // <context.code> returns the ElementTag of the invitation code (after the "/" in the URL. | ||
|
||
| // <context.url> returns the ElementTag of the invitation URL | ||
|
||
| // --> | ||
|
|
||
| public static DiscordInviteCreateScriptEvent instance; | ||
|
|
||
| public DiscordInviteCreateScriptEvent() { | ||
| instance = this; | ||
| registerCouldMatcher("discord invitation created"); | ||
| registerSwitches("channel", "group"); | ||
| } | ||
|
|
||
| public GuildInviteCreateEvent getEvent() { | ||
| return (GuildInviteCreateEvent) event; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean matches(ScriptPath path) { | ||
| if (!tryChannel(path, getEvent().getChannel())) { | ||
| return false; | ||
| } | ||
| if (!tryGuild(path, getEvent().getGuild())) { | ||
| return false; | ||
| } | ||
| return super.matches(path); | ||
| } | ||
|
|
||
| @Override | ||
| public ObjectTag getContext(String name) { | ||
| switch (name) { | ||
| case "channel": | ||
| return new DiscordChannelTag(botID, getEvent().getChannel()); | ||
| case "group": | ||
| return new DiscordGroupTag(botID, getEvent().getGuild()); | ||
| case "user": | ||
| return new DiscordUserTag(botID, getEvent().getInvite().getInviter()); | ||
| case "code": | ||
| return new ElementTag(getEvent().getInvite().getCode()); | ||
|
||
| case "url": | ||
| return new ElementTag(getEvent().getInvite().getUrl()); | ||
| } | ||
| return super.getContext(name); | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the registration list is in alphabetical order (ie the order that your intellij file list should have them in anyway)