discord-rb
Version:
Discord.rb is a library for interacting with the Discord API.
63 lines (43 loc) • 1.73 kB
JavaScript
const fetch = require("node-fetch")
const Guild = async (guildID, token) => {
var options = {
"method": "GET",
"headers": {
"Authorization": `Bot ${token}`,
"Cookie": "__cfduid=d62bef48329670a370c27df97f1a81eba1587580440; __cfruid=bf4b45e1a6e5ef27d99bc35b0eab7581881c3b8c-1587580440"
}
}
const request = await fetch(`https://discordapp.com/api/guilds/${guildID}`, options)
const guild = await request.json()
if (!guild.id) return undefined
const data = {
//the id of this guild.
ID: guild.id,
//the name of this guild.
Name: guild.name,
//returns the icon of this guild.
Icon: guild.icon,
//the id of the guild owner.
OwnerID: guild.owner_id,
//the verification level of this guild.
VerificationLevel: guild.verification_level,
//the roles of this guild (mapped by their IDs)
Roles: guild.roles.map(role => role.id),
//the emojis of this guild (mapped by their IDs)
Emojis: guild.emojis.map(emoji => emoji.id),
//the system channel ID of this guild
SystemChannelID: guild.system_channel_id,
//the date when this guild was created.
CreatedAt: guild.joined_at,
//wether the guild is considered large.
Large: guild.large,
//wether if the guild is unavailable.
Unavailable: guild.unavailable,
//the amount of members in this guild.
MemberCount: guild.member_count,
//the channels of this guild (mapped by their IDs)
Channels: guild.channels ? guild.channels.map(ch => ch.id) : undefined,
}
return data
}
module.exports = Guild