【问题标题】:How to fetch data from discord如何从不和谐中获取数据
【发布时间】:2018-04-24 14:26:12
【问题描述】:

我想知道如何从不和谐中获取数据,特别是频道中的人数。例如,第 14 班的 4 人中有 3 人。我想获取该号码并将其显示在站点的某个位置。我该怎么做?

问候。

【问题讨论】:

标签: java fetch discord


【解决方案1】:

如果你熟悉javascript,我推荐discord.js

这个库可以通过javascript运行,也可以通过node.js运行。

【讨论】:

    【解决方案2】:

    据我所知,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

    您可能想查看 javadocs 中的 VoiceChannel 类。

    【讨论】:

      猜你喜欢
      • 2021-10-19
      • 2020-12-17
      • 2019-05-31
      • 2022-01-26
      • 2022-09-29
      • 2020-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多