有没有办法在网站上显示自定义的Discord内容?

huangapple go评论66阅读模式
英文:

Is there a way to display custom discord stuff on a website?

问题

我最近开始学习前端网页开发(html、css、js),作为一个学习项目,我开始用 React 制作一个为我们的朋友群 Discord 服务器做的网站。我想要从我们的服务器中获取以下三个内容:

  1. 我想要显示在服务器上在语音频道中花费最多时间的用户。

  2. 我想要显示在服务器上在任何频道中发送最多消息的用户。

  3. 我想要显示所有具有特定角色的在线成员。

我应该如何去做这些?这是否可行?

我稍微了解了一下什么是API,但不太确定如何实现这样的功能。我尝试查看了Discord的开发者文档,但感觉有点压倒性。

YouTube和Google没有提供太多帮助,或者可能是因为我不确定应该搜索什么。

另外,他们自己的Discord小部件是否可以替代我想要的第3项,这个小部件是否可定制?

任何帮助,尤其是以“像我5岁的孩子一样解释”的方式,都将不胜感激。
谢谢!

英文:

I've recently started learning front-end web development (html, css, js) and as a learning project I started making a website for our friends group discord server using React. I wanted to have 3 things from our server.

  1. I wanted to display the user with most minutes spent in a voice channel on the server

  2. I wanted to display the user with most messages sent in any channel on the server

  3. I wanted to display all online members with a particular role from the server

How would I go about this? Could it be done?

I've lightly touched what APIs are and am not really sure how I would implement something like this. I've tried looking at Discords developer documentation and its rather overwhelming.

Youtube and Google weren't much help or maybe I'm not sure what I should be looking for.

Also their own discord widget could maybe replace what I want with number 3, is the widget maybe customizable?

Any help, especially in a 'explain it to me like I'm 5' manner, is much appreciated.
Cheers!

答案1

得分: 0

以下是翻译好的内容:

1:
我不认为 Discord 会保存用户在语音频道中的使用时间日志。要监控这个信息,你可能需要设置一个机器人,并让它一直运行。

2: 再次强调,没有一个 API 端点可以监控这个信息。你可以逐个从每个频道获取消息,但这会对 API 造成很大的负担(而且很可能会受到某种速率限制的影响)。

3: 太好了!终于有点可以用的了!使用 HTTP 端点列出公会成员,其中包含了服务器中的人员数组。每个成员都有一个角色对象,你可以通过遍历它来获取角色。你需要在 https://discord.com/developers/applications 上注册一个应用程序,并按照入门教程准备好使用 API。祝你好运!

英文:

For the specific statistics you need, there aren’t actually endpoints that provide this info! It is possible to get all the info you need, but it’ll be a long process to get it.

1:
I don’t believe discord keeps logs of how much time a user has spent in a voice channel. To monitor this, you would probably need to set up a bot and have it constantly run.

2: Again, there isn’t an API endpoint that monitors this. You could fetch messages individually from each channel, but this is very API intensive (and will probably get stopped by a rate limit of some sort).

3: Hooray! Finally something we can use! Using the HTTP endpoint List Guild Members which contains an array of people in your server. Each member has a roles object, which you can interate through to get the role. You’ll need to register an application at https://discord.com/developers/applications and follow the Getting Started docs tutorial to get ready for using the API. Best of luck!

huangapple
  • 本文由 发表于 2023年6月11日 21:44:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76450758.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定