Skip to content

Instantly share code, notes, and snippets.

@Snow-Pyon
Created January 28, 2018 18:45
Show Gist options
  • Save Snow-Pyon/9dcc284f5adb4b1d537bcd2ff8c337a1 to your computer and use it in GitHub Desktop.
Save Snow-Pyon/9dcc284f5adb4b1d537bcd2ff8c337a1 to your computer and use it in GitHub Desktop.
package me.iblitzkriegi.vixio.events.base;
import ch.njol.skript.lang.Literal;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.registrations.EventValues;
import ch.njol.skript.util.Getter;
import me.iblitzkriegi.vixio.Vixio;
import me.iblitzkriegi.vixio.util.wrapper.Bot;
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.core.entities.Channel;
import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.User;
import org.bukkit.event.Event;
public class EvtMessageReceive extends VixioEvent<GuildMessageReceivedEvent> {
static {
Vixio.getInstance().registerEvent("Guild Message Receive", EvtMessageReceive.class, BaseEvent.class, "(guild|server) message [received]")
.setName("Guild Message Received")
.setDesc("Fired when a message is sent in a Text Channel that the bot can read.")
.setExample("on server message received");
EventValues.registerEventValue(BaseEvent.class, Channel.class, new Getter<Channel, BaseEvent>() {
@Override
public Channel get(BaseEvent event) {
return ((GuildMessageReceivedEvent) event.getEvent()).getChannel();
}},0);
EventValues.registerEventValue(BaseEvent.class, User.class, new Getter<User, BaseEvent>() {
@Override
public User get(BaseEvent event) {
return ((GuildMessageReceivedEvent) event.getEvent()).getAuthor();
}},0);
EventValues.registerEventValue(BaseEvent.class, Member.class, new Getter<Member, BaseEvent>() {
@Override
public Member get(BaseEvent event) {
return ((GuildMessageReceivedEvent) event.getEvent()).getMember();
}},0);
EventValues.registerEventValue(BaseEvent.class, Message.class, new Getter<Message, BaseEvent>() {
@Override
public Message get(BaseEvent event) {
return ((GuildMessageReceivedEvent) event.getEvent()).getMessage();
}},0);
EventValues.registerEventValue(BaseEvent.class, Guild.class, new Getter<Guild, BaseEvent>() {
@Override
public Guild get(BaseEvent event) {
return ((GuildMessageReceivedEvent) event.getEvent()).getGuild();
}},0);
EventValues.registerEventValue(BaseEvent.class, Bot.class, new Getter<Bot, BaseEvent>() {
@Override
public Bot get(BaseEvent event) {
return event.getBot();
}},0);
EventValues.registerEventValue(BaseEvent.class, String.class, new Getter<String, BaseEvent>() {
@Override
public String get(BaseEvent event) {
return ((GuildMessageReceivedEvent) event.getEvent()).getMessage().getContentDisplay();
}},0);
}
@Override
public boolean init(Literal<?>[] args, int matchedPattern, SkriptParser.ParseResult parseResult) {
return true;
}
@Override
public String toString(Event e, boolean debug) {
return "guild message receive";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment