Add timeouts to many projectlounge requests, fixed command bug
This commit is contained in:
parent
4684db06e8
commit
516570efe4
6 changed files with 60 additions and 22 deletions
|
@ -15,6 +15,7 @@ class CommandCommand extends Command {
|
|||
if (this.args[0].toLowerCase() === "disable") {
|
||||
if (!collections.commands.has(this.args[1].toLowerCase()) && !collections.aliases.has(this.args[1].toLowerCase())) return "That isn't a command!";
|
||||
const command = collections.aliases.has(this.args[1].toLowerCase()) ? collections.aliases.get(this.args[1].toLowerCase()) : this.args[1].toLowerCase();
|
||||
if (command === "command") return "You can't disable that command!";
|
||||
if (disabled && disabled.includes(command)) return "That command is already disabled!";
|
||||
|
||||
await db.disableCommand(this.message.channel.guild.id, command);
|
||||
|
|
|
@ -3,13 +3,23 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class DonateCommand extends Command {
|
||||
async run() {
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
let prefix = "";
|
||||
const patrons = await fetch("https://projectlounge.pw/patrons").then(data => data.json());
|
||||
prefix = "Thanks to the following patrons for their support:\n";
|
||||
for (const patron of patrons) {
|
||||
prefix += `**- ${patron}**\n`;
|
||||
const controller = new AbortController(); // eslint-disable-line no-undef
|
||||
const timeout = setTimeout(() => {
|
||||
controller.abort();
|
||||
}, 5000);
|
||||
try {
|
||||
const patrons = await fetch("https://projectlounge.pw/patrons", { signal: controller.signal }).then(data => data.json());
|
||||
clearTimeout(timeout);
|
||||
prefix = "Thanks to the following patrons for their support:\n";
|
||||
for (const patron of patrons) {
|
||||
prefix += `**- ${patron}**\n`;
|
||||
}
|
||||
prefix += "\n";
|
||||
} catch (e) {
|
||||
// no-op
|
||||
}
|
||||
prefix += "\n";
|
||||
return `${prefix}Like esmBot? Consider supporting the developer on Patreon to help keep it running! https://patreon.com/TheEssem`;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class InfoCommand extends Command {
|
|||
},
|
||||
{
|
||||
"name": "💬 Total Servers:",
|
||||
"value": stats.guilds ? stats.guilds : `${this.client.guilds.size} (for this cluster only)`
|
||||
"value": stats && stats.guilds ? stats.guilds : `${this.client.guilds.size} (for this cluster only)`
|
||||
},
|
||||
{
|
||||
"name": "✅ Official Server:",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue