Local hangman file

This commit is contained in:
Daniel Odendahl Jr
2018-08-26 23:23:37 +00:00
parent e10235ea6c
commit 9aa97d394e
3 changed files with 50943 additions and 11 deletions
File diff suppressed because it is too large Load Diff
+6 -10
View File
@@ -1,7 +1,6 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const { stripIndents } = require('common-tags');
const { WORDNIK_KEY } = process.env;
const words = require('../../assets/json/hangman');
module.exports = class HangmanCommand extends Command {
constructor(client) {
@@ -19,10 +18,7 @@ module.exports = class HangmanCommand extends Command {
if (this.playing.has(msg.channel.id)) return msg.reply('Only one game may be occurring per channel.');
this.playing.add(msg.channel.id);
try {
const { body } = await request
.get('http://api.wordnik.com/v4/words.json/randomWord')
.query({ api_key: WORDNIK_KEY });
const word = body.word.toLowerCase().replace(/ /g, '-');
const word = words[Math.floor(Math.random() * words.length)].toLowerCase();
let points = 0;
let displayText = null;
let guessed = false;
@@ -57,15 +53,15 @@ module.exports = class HangmanCommand extends Command {
}
const choice = guess.first().content.toLowerCase();
if (choice === 'end') break;
if (choice.length > 1 && (choice === word || choice === body.word.toLowerCase())) {
if (choice.length > 1 && choice === word) {
guessed = true;
break;
} else if (word.includes(choice)) {
displayText = true;
for (let i = 0; i < word.length; i++) {
if (word[i] !== choice) continue; // eslint-disable-line max-depth
confirmation.push(word[i]);
display[i] = word[i];
if (word.charAt(i) !== choice) continue; // eslint-disable-line max-depth
confirmation.push(word.charAt(i));
display[i] = word.charAt(i);
}
} else {
displayText = false;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "87.4.0",
"version": "87.4.1",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {