add: fixchat command

This commit is contained in:
Neko Life 2021-06-01 10:44:37 +00:00
parent 648ab8be67
commit 7ad96907a8
2 changed files with 65 additions and 40 deletions

24
cmds/utility/fixchat.js Normal file
View file

@ -0,0 +1,24 @@
'use strict';
const commando = require("@iceprod/discord.js-commando"),
{ fixChat } = require("../../resources/shaChat");
const { trySend } = require("../../resources/functions");
module.exports = class fixchat extends commando.Command {
constructor(client) {
super(client, {
name: "fixchat",
memberName: "fixchat",
group: "utility",
description: "Fix broken chat."
});
}
async run(msg) {
const r;// = await fixChat();
if (r === 3) {
return trySend(this.client, msg, "Fixed!");
} else {
return trySend(this.client, msg, "Oopsie somethin's wrong...");
}
}
};

View file

@ -1,8 +1,7 @@
'use strict';
const puppeteer = require('puppeteer');
const { trySend, ranLog, noPerm } = require('./functions');
const { trySend, noPerm } = require('./functions');
const Commando = require("@iceprod/discord.js-commando");
require("discord.js");
@ -70,45 +69,47 @@ async function fetchAnswer(page, index) {
}
}
let chatIndex = 3;
/**
* @param {Commando.Client} client
* @param {Commando.CommandoMessage} message
* @returns
*/
async function chatAnswer(client, message) {
//console.log(message.content);
//console.log(chatIndex);
if (message.content.trim().length === 0) {
return
} else {
try {
message.channel.startTyping();
await shaChat(client, chatIndex, message).then(async answer => {
chatIndex += 2;
if (message.channel.lastMessage.author === client.user && answer?.trim() === message.channel.lastMessage.content.trim()) {
return trySend(client, message, "Please speak one by one, I'm overwhelmed <:catstareLife:794930503076675584>");
} else {
trySend(client, message, answer.trim()).then(() => {
message.channel.stopTyping();
}).catch(e => {
noPerm(message);
message.channel.stopTyping();
});
}
return ranLog(message, message.content.trim(), answer);
}).catch(e => {
noPerm(message);
message.channel.stopTyping();
});
} catch (e) {
/**
* @param {Commando.Client} client
* @param {Commando.CommandoMessage} message
* @returns
*/
async function chatAnswer(client, message) {
//console.log(message.content);
//console.log(chatIndex);
if (message.content.trim().length === 0) {
return
} else {
try {
message.channel.startTyping();
await shaChat(client, chatIndex, message).then(async answer => {
chatIndex += 2;
if (message.channel.lastMessage.author === client.user && answer?.trim() === message.channel.lastMessage.content.trim()) {
return trySend(client, message, "Please speak one by one, I'm overwhelmed <:catstareLife:794930503076675584>");
} else {
trySend(client, message, answer.trim()).then(() => {
message.channel.stopTyping();
}).catch(e => {
noPerm(message);
message.channel.stopTyping();
});
}
return //ranLog(message, message.content.trim(), answer);
}).catch(e => {
noPerm(message);
message.channel.stopTyping();
}
}
}
message.channel.stopTyping();
});
} catch (e) {
noPerm(message);
message.channel.stopTyping();
}
}
}
module.exports = { chatAnswer }
async function fixChat() {
return page1.then(r => r.reload()).then(() => {return chatIndex = 3}).catch(e => {return console.log(e)});
}
module.exports = { chatAnswer, fixChat }