misc.mcserver: 3 min timeout, why not
This commit is contained in:
parent
2499ce6b36
commit
550ac7c0b3
1 changed files with 50 additions and 41 deletions
|
@ -25,7 +25,8 @@ yt.callback = async function(msg, line) {
|
|||
if (!line) return "Arguments are required.";
|
||||
|
||||
const req = await fetch(
|
||||
`https://www.googleapis.com/youtube/v3/search?key=${hf.apikeys.google
|
||||
`https://www.googleapis.com/youtube/v3/search?key=${
|
||||
hf.apikeys.google
|
||||
}&maxResults=5&part=snippet&type=video&q=${encodeURIComponent(line)}`
|
||||
).then((x) => x.json());
|
||||
|
||||
|
@ -58,7 +59,8 @@ fyt.callback = async function(msg, line) {
|
|||
if (!line) return "Arguments are required.";
|
||||
|
||||
const req = await fetch(
|
||||
`https://www.googleapis.com/youtube/v3/search?key=${hf.apikeys.google
|
||||
`https://www.googleapis.com/youtube/v3/search?key=${
|
||||
hf.apikeys.google
|
||||
}&maxResults=2&part=snippet&type=video&q=${encodeURIComponent(line)}`
|
||||
).then((x) => x.json());
|
||||
|
||||
|
@ -114,7 +116,8 @@ wolfram.callback = async function(msg, line, args, { verbose, v }) {
|
|||
for (const x in extra) {
|
||||
embed.fields.push({
|
||||
name: extra[x].title,
|
||||
value: `[${extra[x].subpods[0].plaintext.length > 0
|
||||
value: `[${
|
||||
extra[x].subpods[0].plaintext.length > 0
|
||||
? extra[x].subpods[0].plaintext
|
||||
: "<click for image>"
|
||||
}](${extra[x].subpods[0].img.src})`,
|
||||
|
@ -182,7 +185,8 @@ gimg.callback = async function(msg, line) {
|
|||
url: image.url,
|
||||
},
|
||||
footer: {
|
||||
text: `Image ${Number(index) + 1}/${images.length
|
||||
text: `Image ${Number(index) + 1}/${
|
||||
images.length
|
||||
}. Rerun to get a different image.`,
|
||||
},
|
||||
},
|
||||
|
@ -259,8 +263,10 @@ vote.callback = async function(msg, line, topic, { maybe }) {
|
|||
topic = topic.join(" ");
|
||||
|
||||
return {
|
||||
content: `**${msg.author.username}#${msg.author.discriminator
|
||||
}** has started a vote:\n## __${topic}__\n<:ms_tick:503341995348066313>: Yes\n<:ms_cross:503341994974773250>: No${maybe ? "\n<:ms_tilda:581268710925271095>: Maybe/Uncertain" : ""
|
||||
content: `**${msg.author.username}#${
|
||||
msg.author.discriminator
|
||||
}** has started a vote:\n## __${topic}__\n<:ms_tick:503341995348066313>: Yes\n<:ms_cross:503341994974773250>: No${
|
||||
maybe ? "\n<:ms_tilda:581268710925271095>: Maybe/Uncertain" : ""
|
||||
}`,
|
||||
addReactions: [
|
||||
":ms_tick:503341995348066313",
|
||||
|
@ -523,7 +529,8 @@ generate.callback = async function(msg, line) {
|
|||
const title = `Responses for "${safeString(line)}"`;
|
||||
|
||||
const out = {
|
||||
content: `Generated in ${formatTime(Date.now() - start)}${retries > 0 ? " with " + retries + " retries" : ""
|
||||
content: `Generated in ${formatTime(Date.now() - start)}${
|
||||
retries > 0 ? " with " + retries + " retries" : ""
|
||||
}`,
|
||||
embeds: [],
|
||||
files: images,
|
||||
|
@ -755,22 +762,24 @@ mcserver.callback = async function(msg, line) {
|
|||
|
||||
const data = await new Promise((resolve, reject) => {
|
||||
logger.verbose("mcserver", "querying", ip, port);
|
||||
const timeout = setTimeout(() => {
|
||||
logger.verbose("mcserver", "timeout");
|
||||
resolve("timeout");
|
||||
}, 60000);
|
||||
|
||||
const client = net.createConnection(
|
||||
{
|
||||
host: ip,
|
||||
port: port,
|
||||
timeout: 60000,
|
||||
timeout: 180000,
|
||||
},
|
||||
function () {
|
||||
logger.verbose("mcserver", "connect");
|
||||
client.write(HANDSHAKE_PACKET);
|
||||
}
|
||||
);
|
||||
const timeout = setTimeout(() => {
|
||||
logger.verbose("mcserver", "timeout");
|
||||
client.destroy();
|
||||
resolve("timeout");
|
||||
}, 180000);
|
||||
|
||||
let totalData = Buffer.alloc(0);
|
||||
client.on("data", function (data) {
|
||||
totalData = Buffer.concat([totalData, data]);
|
||||
|
|
Loading…
Reference in a new issue