[英]How to display information from a website on my discord bot?
Im building a discord bot(Javascript, Node.js, Discord.js) which is based on a game (a online multiplayer).So, im pretty much done developing the bot except for one thing which I really wish I could add.我正在构建一个基于游戏(在线多人游戏)的 discord bot(Javascript、Node.js、Discord.js)。所以,除了我真的希望我可以添加的一件事之外,我几乎完成了开发该机器人的工作。 So, this game has some highscores which can be viewed here - https://www.hzgaming.net/high.php .所以,这个游戏有一些高分,可以在这里查看 - https://www.hzgaming.net/high.php 。 So, I want to display those highscores (Highscore money - https://www.hzgaming.net/high.php?scores=money ) (Highscore materials - https://www.hzgaming.net/high.php?scores=materials ) and all those.所以,我想显示那些高分(高分钱 - https://www.hzgaming.net/high.php?scores=money )(高分资料 - https://www.hzgaming.net/high.php?scores=材料)和所有这些。 So, what I would like to have is..when a user types a cmd like '!highscore money', it should show the highscore available on that website link I gave above, and similarly..when they use '!highscore materials' it should show the highscore of materials from that link respectivly.所以,我想要的是..当用户输入像'!highscore money'这样的cmd时,它应该显示我上面给出的那个网站链接上可用的高分,同样......当他们使用'!highscore材料'时它应该分别显示来自该链接的材料的高分。 I want it to be from that link because, it keeps on changing and gets updated.我希望它来自该链接,因为它不断变化并得到更新。 Also, im pretty sure its possible because, there is a similar bot which shows the same thing as I explained.另外,我很确定这是可能的,因为有一个类似的机器人显示与我解释的相同的内容。 I hope you understood what I meant.我希望你明白我的意思。 I would really love to get an answer for this, also it would be great if an example code is provided with the answer so that its easy to understand.我真的很想得到一个答案,如果提供了一个示例代码以使其易于理解,那就太好了。
An example for the cmd is given below -下面给出了 cmd 的示例 -
user - !highscore money BOT - Money High Scores用户 - !highscore money BOT - 金钱高分
user- !highscore materials BOT - 1. Chapo_Diamond - 5,749,300 materials 2. Van_Damme - 4,923,046 materials 3. Brandon_Heath_Tsung - 3,906,395 materials 4. Armando_Domrani - 3,241,925 materials 5. Tazz_Equinox - 3,187,045 materials 6. Danny_Ted - 2,868,088 materials 7. Jack_Paterson - 2,748,249 materials 8. John_Dixon - 2,548,250 materials 9. Gab_Alphonse - 2,252,285 materials 10. Don_Thomax - 2,131,177 materials (( ALL THE REPLY BY THE BOT WILL BE EMBEDS )) (yea, so somehow those values should keep on updating, thats why I gave the link above)用户的高分材料BOT - 1 Chapo_Diamond - 5749300种材料2. Van_Damme - 4923046种材料3. Brandon_Heath_Tsung - 3906395种材料4. Armando_Domrani - 3241925种材料5. Tazz_Equinox - 3187045种材料6. Danny_Ted - 2868088种材料7. Jack_Paterson - 2748249种材料8 . John_Dixon - 2,548,250 材料 9. Gab_Alphonse - 2,252,285 材料 10. Don_Thomax - 2,131,177 材料((机器人的所有回复都将嵌入))(是的,所以不知何故,这些值应该继续更新)
Pls note that the code should be javascript using discord.js and node.js.请注意,代码应该是使用 discord.js 和 node.js 的 javascript。 Thank you <3 :)谢谢<3 :)
I'm not sure if that's possible because of the "Just checking your computer, this will only take a few seconds" page that will always pop up (for DDoS
protection).我不确定这是否可能,因为“只是检查您的计算机,这将只需要几秒钟”页面总是会弹出(用于DDoS
保护)。 For example, this is what I got in my console after requesting some data:例如,这是我在请求一些数据后在我的控制台中得到的:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta http-equiv="refresh" content="12">
<link rel="Shortcut Icon" href="https://www.hzgaming.net/favicon.ico" type="image/x-icon">
<title>Just a moment...</title>
<style>@font-face{font-family:Open Sans;font-style:normal;font-weight:400;font-display:swap;src:local("Open Sans Regular"),local("OpenSans-Regular"),url(data:font/woff2;base64,
d09GMgABAAAAACjgAA4AAAAAUhQAACiIAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGiIbEBwaBmAAZBEQCoGANONLC4
M8AAE2AiQDhnAEIAWDWgeQShv4QBXjmFXAxsEAi709IypHX42iQhIH/39MoGOIFG6KqtsXWLsNGTEJswgLuVELAuzt
6BPcQHcKGcv5HKXdi+eKlYT6O/H7D3cgR+jqXNVLasoPuSn55q2H3pbvh3OAu9IvBQY5QmOf5EL/td9nz5tz7szuhl
FHoURhUQJqVpEko1I+Ki4WZRSx2vo+qLaiHszxbb7Ne0BkhgdhTe1mgqThm6figcxKku0p+W2vqybIl4ofbmvDwzr/
// and so on... for a very long time.
I don't think there's a way to get past this, but in the miraculous chance you find a way, this is how I would get the needed data:我不认为有办法解决这个问题,但是在你找到方法的奇迹般的机会中,这就是我获取所需数据的方式:
// you should use this npm package - https://www.npmjs.com/package/node-fetch
const fetch = require('node-fetch');
fetch('https://www.hzgaming.net/high.php?scores=money')
.then((res) => res.text())
.then((body) => console.log(body));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.