cleaned up anagram.js, combined module exports.

This commit is contained in:
2019-03-18 06:23:27 +11:00
parent 7d11f13e30
commit 467dc136ff
22 changed files with 513 additions and 496 deletions

View File

@@ -1,31 +1,32 @@
const fs = require('fs')
const Discord = require('discord.js')
var request = require('request');
const request = require('request');
module.exports = {
name = "Anagram Finder",
alias =['anagram', 'nagaram'],
helptext = "finds anagrams up to 9 letters",
permissions =['VIEW_CHANNEL'],
args =['letters'],
command = (client, msg) => {
exports.name = "Anagram Finder"
exports.alias = ['anagram', 'nagaram']
exports.helptext = "finds anagrams up to 9 letters"
exports.permissions = ['VIEW_CHANNEL']
exports.args = ['letters']
exports.command = (client, msg) => {
var url = "http://www.anagramica.com/best/:";
var url = "http://www.anagramica.com/best/:"
if (msg.suffix.length > 9){
msg.reply("That anagram is too long. Max 9 Letters.");
return;
}
request({
url: url + msg.suffix,
json: true
}, function (error, response, body) {
if (!error && response.statusCode === 200) {
var replystring = "";
for (i = 0; i < body.best.length; i++)
replystring += body.best[i] + ', ';
msg.reply(replystring.substr(0, replystring.length - 2)); // Print the json response
if (msg.suffix.length > 9) {
msg.reply("That anagram is too long. Max 9 Letters.")
return;
}
});
request({
url: url + msg.suffix,
json: true
}, (error, response, body) => {
if (!error && response.statusCode === 200) {
var replystring = ""
for (i = 0; i < body.best.length; i++)
replystring += body.best[i] + ', '
msg.reply(replystring.substr(0, replystring.length - 2))
}
});
}
}