UNPKG

discord-rb

Version:

Discord.rb is a library for interacting with the Discord API.

47 lines (32 loc) 1.26 kB
const fetch = require("node-fetch") const User = require("./User.js") //represents a discord member in this guild. const Member = async (guildID, userID, token) => { var options = { "method": "GET", "headers": { "Authorization": `Bot ${token}`, "Cookie": "__cfduid=d62bef48329670a370c27df97f1a81eba1587580440; __cfruid=bf4b45e1a6e5ef27d99bc35b0eab7581881c3b8c-1587580440" } } let request = await fetch(`https://discordapp.com/api/guilds/${guildID}/members/${userID}`, options) const member = await request.json() const data = { //the nickname of this user (if theres one set) Nickname: member.nickname, //the roles of this user. (mapped by IDs). Roles: member.roles, //the user object of this member. User: await User(userID, token), //the timestamp when the user joined the guild. JoinedAt: member.joined_at, //wether if the user is muted on voice channels. Muted: member.mute, //wether is the user is deafened on voice channels. Deafened: member.deaf, //the guild ID this member belongs to. GuildID: guildID } return data } module.exports = Member