Class GuildMemberRemoveEvent

  • All Implemented Interfaces:
    GenericEvent

    public class GuildMemberRemoveEvent
    extends GenericGuildEvent
    Indicates that a user was removed from a Guild. This includes kicks, bans, and leaves respectively.
    This can be fired for uncached members and cached members alike. If the member was not cached by JDA, due to the MemberCachePolicy or disabled member chunking, then getMember() will return null.

    Can be used to detect when a member is removed from a guild, either by leaving or being kicked/banned.

    Requirements

    This event requires the GUILD_MEMBERS intent to be enabled.
    createDefault(String) and createLight(String) disable this by default!

    • Constructor Detail

      • GuildMemberRemoveEvent

        public GuildMemberRemoveEvent​(@Nonnull
                                      JDA api,
                                      long responseNumber,
                                      @Nonnull
                                      Guild guild,
                                      @Nonnull
                                      User user,
                                      @Nullable
                                      Member member)
    • Method Detail

      • getUser

        @Nonnull
        public User getUser()
        The corresponding user who was removed from the guild.
        Returns:
        The user who was removed
      • getMember

        @Nullable
        public Member getMember()
        The member instance for this user, if it was cached at the time.
        Discord does not provide the member meta-data when a remove event is dispatched.
        Returns:
        Possibly-null member