How to get the pciture in process by JDA? #2596
-
First of all, thank you to everyone who saw this post. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I try to add all intents, it also can't acheve my goal. |
Beta Was this translation helpful? Give feedback.
-
If you're interested, you can copy it locally and try running it. import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.requests.GatewayIntent;
public class MessageListener extends ListenerAdapter {
public static void main(String[] args) {
JDA jda = JDABuilder.createDefault("xxxxxxxxx")
.enableIntents(GatewayIntent.MESSAGE_CONTENT,
GatewayIntent.GUILD_MESSAGES,
GatewayIntent.GUILD_MEMBERS,
GatewayIntent.GUILD_MODERATION,
GatewayIntent.GUILD_EMOJIS_AND_STICKERS,
GatewayIntent.GUILD_WEBHOOKS ,
GatewayIntent.GUILD_INVITES ,
GatewayIntent.GUILD_VOICE_STATES
//GatewayIntent.GUILD_PRESENCES can't be enabled
,GatewayIntent.GUILD_MESSAGE_REACTIONS
,GatewayIntent.GUILD_MESSAGE_TYPING
,GatewayIntent.DIRECT_MESSAGES
,GatewayIntent.DIRECT_MESSAGE_REACTIONS
,GatewayIntent.DIRECT_MESSAGE_TYPING
,GatewayIntent.SCHEDULED_EVENTS
,GatewayIntent.AUTO_MODERATION_CONFIGURATION
,GatewayIntent.AUTO_MODERATION_EXECUTION
)
.build();
jda.addEventListener(new MessageListener());
System.out.println("success");
}
@Override
public void onMessageReceived(MessageReceivedEvent event) {
System.out.println("messageId = "+ event.getMessageId());
if (event.getMessage().getAttachments() != null && event.getMessage().getAttachments().size() > 0) {
Message.Attachment attachment = event.getMessage().getAttachments().get(0);
System.out.println(String.format("filename=%s content_type=%s proxy_url=%s url=%s", attachment.getFileName(), attachment.getContentType(),
attachment.getProxyUrl(), attachment.getUrl()));
}
if (event.isFromType(ChannelType.PRIVATE)) {
System.out.printf("[PM] %s: %s\n", event.getAuthor().getName(),
event.getMessage().getContentDisplay());
} else {
System.out.printf("[%s][%s] %s: %s\n", event.getGuild().getName(),
event.getChannelType().name(), event.getMember().getEffectiveName(),
event.getMessage().getContentDisplay());
}
}
} |
Beta Was this translation helpful? Give feedback.
same message update, override public void onMessageUpdate(MessageUpdateEvent event)。