1.1.4 • Published 5 years ago
fcapi.js v1.1.4
FarmCrafts Development API Wrapper
An API Wrapper for FarmCrafts Development API(s)
Documentation
WIP :P
How to Install
npm i fcapi.js --save
Examples
With async/await
const Discord = require('discord.js'),
PREFIX = "!";
FarmCraftsDev = require('fcapi.js');
var bot = new Discord.Client(),
FarmCrafts = new FarmCraftsDev(
"Your Bot User IDs",
"Your IDs"
);
bot.on('ready', () => console.log("Ready!"));
bot.on('message', async message => {
if (message.author.bot || !message.guild || message.content.startsWith(PREFIX)) return;
let args = message.content.slice(PREFIX.length).trim().split(" "),
commands = args.shift().toLowerCase();
if (commands === "farmcrafts") {
let id = args[0],
botData = FarmCrafts.getBot(id);
if (!id)
return message.channel.send("Please provide bot ID.");
if (id !== true)
return message.channel.send("Please provide only bot ID.");
if (!botData || botData === undefined)
return message.reply("Sorry, you're but that Bot was not registered yet on **__FarmCrafts__**.");
message.channel.send(`${botData.botName} by ${botData.developerTag} with Prefix ${botData.prefix}`);
}
});
bot.login("Paste you'r Token(s)");
With .then Promises
const Discord = require('discord.js'),
PREFIX = "!";
FarmCraftsDev = require('fcapi.js');
var bot = new Discord.Client(),
FarmCrafts = new FarmCraftsDev(
"Your Bot User IDs",
"Your IDs"
);
bot.on('ready', () => console.log("Ready!"));
bot.on('message', async message => {
if (message.author.bot || !message.guild || message.content.startsWith(PREFIX)) return;
let args = message.content.slice(PREFIX.length).trim().split(" "),
commands = args.shift().toLowerCase();
if (commands === "farmcrafts") {
let id = args[0];
if (!id)
return message.channel.send("Please provide bot ID.");
if (id !== true)
return message.channel.send("Please provide only bot ID.");
FarmCrafts.getBot(id).then(botData => {
if (!botData || botData === undefined)
return message.reply("Sorry, you're but that Bot was not registered yet on **__FarmCrafts__**.");
message.channel.send(`${botData.botName} by ${botData.developerTag} with Prefix ${botData.prefix}`);
});
}
});
bot.login("Paste you'r Token(s)");