[英]how to grab the name and picture of a discord server in discord.js
如果您使用 discord.js 您可以简单地使用<Client>.fetchInvite()
:
const client = <Client>
client.fetchInvite(invite_url)
.then(console.log);
这将返回一个 Invite 实例:
https://discord.js.org/#/docs/main/stable/class/Invite
之后只需通过.guild
访问公会:
const client = <Client>
client.fetchInvite(invite_url)
.then(inv => {
console.log(inv.guild);
console.log(inv.guild.name, inv.guild.iconURL());
});
If you want to use https://discordapp.com/api/v6/invites/H4ySkbn
just fetch the link with axios or node-fetch resolve it in JSON and then access the properties there, but in that case the icon url will be一个 hash
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.