简体   繁体   中英

How can a discord bot exchange data over multiple servers?

For example if I add my bot to server 1 and server 2, how can I do something on server 2 when a certain event happens on server 1? Is that even possible?

I don't have any code yet, I just wanna know if this is even possible with the Discord Java API (JDA).

Yes, it is possible.

  1. When you start your bot with JDA, you'll get a JDA object, let's call it jda ( public JDA jda ).
  2. Next you map the events with a ListenerAdapter. In the ListenerAdapter, you'll specify what you want to do when each event is received. Check what events you can listen to in the Method Summary section at https://ci.dv8tion.net/job/JDA/javadoc/net/dv8tion/jda/api/hooks/ListenerAdapter.html . You just need to override the methods you want.
  3. In your implementation, let's say @Override (...)onEmoteAdded() {(your code goes here)} , you can have a piece of code that manipulates another server such as jda.getGuildById(id).queue()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM