2017-11-11 153 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类。