2017-11-11 150 views
0

我想知道如何從不和諧數據中獲取數據頻道中的人數。例如,#14班有4人中有3人。我想獲取該號碼並將其顯示在網站的某個位置。我會怎麼做?如何從不和諧中獲取數據

問候。

+0

什麼是「不和諧」? – m0skit0

+0

以下是[Discord文檔](https://discordapp.com/developers/docs/intro)到目前爲止您嘗試了什麼? – Enzokie

+0

@ m0skit0 [tag:discord],表示請提供您嘗試過的代碼,您正在使用的庫等。如果您需要幫助開始使用您的庫,我建議查看其文檔。雖然這個問題對於StackOverflow來說太廣泛了,但你應該嘗試在[Discord API,API問題的Discord服務器](https://discord.gg/discord-api)中提問,但他們將能夠在那裏爲你提供幫助。 [來自評論](https://stackoverflow.com/review/first-posts/17912412) – LW001

回答

0

就我所知,Discord並未提供從REST API獲取語音通道中成員的官方方式。爲了達到這個目的,你可能需要運行一個完整的機器人並邀請你的公會。對於Java,我推薦使用JDA庫。

public class ReadyListener implements EventListener 
{ 
    public static void main(String[] args) 
      throws LoginException, RateLimitedException, InterruptedException 
    { 
     // Note: It is important to register your ReadyListener before building 
     JDA jda = new JDABuilder(AccountType.BOT) 
      .setToken("token") 
      .addEventListener(new ReadyListener()) 
      .buildBlocking(); 
    } 

    @Override 
    public void onEvent(Event event) 
    { 
     if (event instanceof ReadyEvent) 
     { 
      System.out.println("API is ready!"); 

      // Get a specific voice channel 
      event.getJda().getVoiceChannelById("12341234"); 
     } 
    } 
} 

推薦閱讀:

https://github.com/DV8FromTheWorld/JDA/wiki/3)-Getting-Started

https://discordapp.com/developers/docs/intro

你可能會想看看的javadoc的VoiceChannel類。