我正在尝试制作一个不和谐的roblox验证机器人,但它总是说它未经验证。我正在使用请求获取数据:
const Discord = require("discord.js");
const request = require("request-promise");
const rolename = "EC | Economy Class";
let verifiedrole = call.message.guild.roles.cache.find(role => role.name === `${rolename}`);
let userid = call.message.author.id;
let wow = `https://verify.eryn.io/api/user/${userid}`;
let responce = request(wow, {json: true});
if(responce.status == "ok")
{
const embed = new Discord.MessageEmbed()
.setTitle("SeaLink Verification")
.setDescription("You have been verified sucessfully under user: **" + responce.robloxUsername + "**.")
.setColor("#1f75ff")
.setFooter("SeaLink V2 | Dizzy Tech");
call.message.channel.send(embed);
}
else
{
const embed = new Discord.MessageEmbed()
.setTitle("SeaLink Verification")
.setDescription("Your not linked with our API! please visit [this](https://discord.com/oauth2/authorize?client_id=240413107850182656&scope=identify+guilds&response_type=code&redirect_uri=https%3A%2F%2Fverify.eryn.io) website to link yourself and then try again.")
.setColor("#1f75ff")
.setFooter("SeaLink V2 | Dizzy Tech");
call.message.channel.send(embed);
}
console.log(request + "\n\n\n\n\n" + wow);
}
答案 0 :(得分:0)
const fetch = require("node-fetch");
fetch(`https://verify.eryn.io/api/user/${message.author.id}`).then(response => response.json()).then(response => { // Fetching the API and transforming the response into JSON if not already.
if (response.status == "ok") { // Checking if the request's status is okay
const embed = new discord.MessageEmbed()
.setTitle("SeaLink Verification")
.setDescription("You have been verified sucessfully under user: **" + response.robloxUsername + "**.")
.setColor("#1f75ff")
.setFooter("SeaLink V2 | Dizzy Tech");
message.channel.send(embed)
} else {
const embed = new discord.MessageEmbed()
.setTitle("SeaLink Verification")
.setDescription("Your not linked with our API! please visit [this](https://discord.com/oauth2/authorize?client_id=240413107850182656&scope=identify+guilds&response_type=code&redirect_uri=https%3A%2F%2Fverify.eryn.io) website to link yourself and then try again.")
.setColor("#1f75ff")
.setFooter("SeaLink V2 | Dizzy Tech");
message.channel.send(embed);
}
});