Search in sources :

Example 1 with DiscordUserTag

use of com.denizenscript.ddiscordbot.objects.DiscordUserTag in project dDiscordBot by DenizenScript.

the class DiscordMessageModifiedScriptEvent method getContext.

@Override
public ObjectTag getContext(String name) {
    switch(name) {
        case "channel":
            return new DiscordChannelTag(botID, getEvent().getChannel());
        case "group":
            if (getEvent().isFromGuild()) {
                return new DiscordGroupTag(botID, getEvent().getGuild());
            }
            break;
        case "new_message":
            return new DiscordMessageTag(botID, getEvent().getMessage());
        case "old_message_valid":
            return new ElementTag(oldMessage != null);
        case "old_message":
            return oldMessage == null ? null : new DiscordMessageTag(botID, oldMessage);
        case "old_no_mention_message":
        case "old_formatted_message":
            DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
            return null;
        case "message":
            DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
            return new ElementTag(getEvent().getMessage().getContentRaw());
        case "message_id":
            DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
            return new ElementTag(getEvent().getMessage().getId());
        case "no_mention_message":
            DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
            return new ElementTag(DiscordMessageTag.stripMentions(getEvent().getMessage().getContentRaw()));
        case "formatted_message":
            DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
            return new ElementTag(getEvent().getMessage().getContentDisplay());
        case "author":
            DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
            return new DiscordUserTag(botID, getEvent().getMessage().getAuthor());
        case "mentions":
            DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
            ListTag list = new ListTag();
            for (User user : getEvent().getMessage().getMentionedUsers()) {
                list.addObject(new DiscordUserTag(botID, user));
            }
            return list;
        case "is_direct":
            DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
            return new ElementTag(getEvent().getChannel() instanceof PrivateChannel);
    }
    return super.getContext(name);
}
Also used : PrivateChannel(net.dv8tion.jda.api.entities.PrivateChannel) DiscordUserTag(com.denizenscript.ddiscordbot.objects.DiscordUserTag) User(net.dv8tion.jda.api.entities.User) DiscordChannelTag(com.denizenscript.ddiscordbot.objects.DiscordChannelTag) DiscordGroupTag(com.denizenscript.ddiscordbot.objects.DiscordGroupTag) DiscordMessageTag(com.denizenscript.ddiscordbot.objects.DiscordMessageTag) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) ListTag(com.denizenscript.denizencore.objects.core.ListTag)

Example 2 with DiscordUserTag

use of com.denizenscript.ddiscordbot.objects.DiscordUserTag in project dDiscordBot by DenizenScript.

the class DiscordMessageReceivedScriptEvent method getContext.

@Override
public ObjectTag getContext(String name) {
    switch(name) {
        case "channel":
            return new DiscordChannelTag(botID, getEvent().getChannel());
        case "group":
            if (getEvent().isFromGuild()) {
                return new DiscordGroupTag(botID, getEvent().getGuild());
            }
            break;
        case "new_message":
            return new DiscordMessageTag(botID, getEvent().getMessage());
        case "message":
            DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
            return new ElementTag(getEvent().getMessage().getContentRaw());
        case "message_id":
            DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
            return new ElementTag(getEvent().getMessage().getId());
        case "no_mention_message":
            DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
            return new ElementTag(DiscordMessageTag.stripMentions(getEvent().getMessage().getContentRaw()));
        case "formatted_message":
            DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
            return new ElementTag(getEvent().getMessage().getContentDisplay());
        case "author":
            DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
            return new DiscordUserTag(botID, getEvent().getMessage().getAuthor());
        case "mentions":
            DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
            ListTag list = new ListTag();
            for (User user : getEvent().getMessage().getMentionedUsers()) {
                list.addObject(new DiscordUserTag(botID, user));
            }
            return list;
        case "is_direct":
            DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
            return new ElementTag(getEvent().getChannel() instanceof PrivateChannel);
    }
    return super.getContext(name);
}
Also used : PrivateChannel(net.dv8tion.jda.api.entities.PrivateChannel) DiscordUserTag(com.denizenscript.ddiscordbot.objects.DiscordUserTag) User(net.dv8tion.jda.api.entities.User) DiscordChannelTag(com.denizenscript.ddiscordbot.objects.DiscordChannelTag) DiscordGroupTag(com.denizenscript.ddiscordbot.objects.DiscordGroupTag) DiscordMessageTag(com.denizenscript.ddiscordbot.objects.DiscordMessageTag) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) ListTag(com.denizenscript.denizencore.objects.core.ListTag)

Aggregations

DiscordChannelTag (com.denizenscript.ddiscordbot.objects.DiscordChannelTag)2 DiscordGroupTag (com.denizenscript.ddiscordbot.objects.DiscordGroupTag)2 DiscordMessageTag (com.denizenscript.ddiscordbot.objects.DiscordMessageTag)2 DiscordUserTag (com.denizenscript.ddiscordbot.objects.DiscordUserTag)2 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)2 ListTag (com.denizenscript.denizencore.objects.core.ListTag)2 PrivateChannel (net.dv8tion.jda.api.entities.PrivateChannel)2 User (net.dv8tion.jda.api.entities.User)2