Coder Social home page Coder Social logo

Comments (6)

Andre601 avatar Andre601 commented on May 27, 2024

By the looks of it did you not add the RoleEventListener class to your JDABuilder as a new event listener.

from jda.

RedPanda4552 avatar RedPanda4552 commented on May 27, 2024

I don't include my event listeners in the initial method chain off of the constructor. I register them individually later.

Message events seem to work just fine, these events are the only ones which seem to exhibit this behavior. Should I register them in the method chain instead?

from jda.

Andre601 avatar Andre601 commented on May 27, 2024

Well, a first step would be to share where and how you register them.

Next also make sure you actually have enabled the member priviledge on the Discord dev portal for your bot. Tho JDA would've given a warning on startup (and iirc not started) should it be missing.

from jda.

RedPanda4552 avatar RedPanda4552 commented on May 27, 2024

I register them shortly after I read in config, to prevent a race between an event firing and my config data not yet being present to guide how those events are handled:

try {
	jda = JDABuilder.createDefault(discordBotToken)
			.enableIntents(GatewayIntent.GUILD_MEMBERS, GatewayIntent.MESSAGE_CONTENT)
			.setMemberCachePolicy(MemberCachePolicy.ALL)
			.setAutoReconnect(true)
			.build().awaitReady();
} catch (Exception e) {
	Messaging.logException(e);
}
		
updateStatus("Starting...");

ConfigManager.createConfigIfNotExists(ConfigType.CORE);
config = (Config) ConfigManager.read(ConfigType.CORE);
// Write back the config so that if any new fields were added after an
// update, they are written to disk
ConfigManager.write(config);

ConfigManager.createConfigIfNotExists(ConfigType.DYNCMD);
dynCmdConfig = (DynCmdConfig) ConfigManager.read(ConfigType.DYNCMD);
ConfigManager.write(dynCmdConfig);

// some additional classes are instanced here but have no interaction with the event listeners

jda.addEventListener(roleEventListener = new RoleEventListener());
jda.addEventListener(messageEventListener = new MessageEventListener());
jda.addEventListener(memberEventListener = new MemberEventListener());
jda.addEventListener(slashCommandListener = new SlashCommandListener());
jda.addEventListener(messageCommandListener = new MessageContextCommandListener());

It is worth noting I am waiting until after this entire initialization process has finished before testing this behavior (my bot changes its presence status to indicate this entire init sequence has completed, plus I can see it clearly in the debug console).

I took care of the privileged gateway intents a long time ago for both my production and debug bot applications, else many features would stop working entirely:
image

from jda.

MinnDevelopment avatar MinnDevelopment commented on May 27, 2024

This event only fires once a member has been loaded into cache. Just because you set the cache policy to ALL does not mean the member is cached right away, it is only cached once JDA sees any activity from them.

You can use GuildMemberUpdateEvent if you want to avoid relying on cache. Otherwise you have to explicitly load all members on startup into cache, using chunking filter.

from jda.

RedPanda4552 avatar RedPanda4552 commented on May 27, 2024

I see, I am a fool for not putting two and two together on the javadoc. I will work out what I need to do from here, thanks.

from jda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.