From 911218cdafcb818e676b63688d6352b0e286a547 Mon Sep 17 00:00:00 2001 From: Bsian Date: Sun, 3 May 2020 23:47:44 +0100 Subject: [PATCH 1/2] Set disable notif value to 0 --- src/commands/limits_setramnotification.ts | 4 ++-- src/intervals/memory.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commands/limits_setramnotification.ts b/src/commands/limits_setramnotification.ts index 11ecf9c..aa60271 100644 --- a/src/commands/limits_setramnotification.ts +++ b/src/commands/limits_setramnotification.ts @@ -17,8 +17,8 @@ export default class Limits_SetRAMNotification extends Command { if (!account) return message.channel.createMessage(`***${this.client.stores.emojis.error} You do not have a Cloud Account.***`); const tier = await this.client.db.Tier.findOne({ id: account.tier }); if (Number(args[0]) >= tier.resourceLimits.ram) return message.channel.createMessage(`***${this.client.stores.emojis.error} You cannot set your notification limit to be set to or above your hard limit.***`); - if ((Number(args[0]) < 1) && (Number(args[0]) !== -1)) return message.channel.createMessage(`***${this.client.stores.emojis.error} You cannot set your notification limit to a negative number.***`); - if (Number(args[0]) === -1) { + if (Number(args[0]) < 0) return message.channel.createMessage(`***${this.client.stores.emojis.error} You cannot set your notification limit to a negative number.***`); + if (Number(args[0]) === 0) { await account.updateOne({ $set: { ramLimitNotification: -1 } }); return message.channel.createMessage(`***${this.client.stores.emojis.success} You have disabled notifications.***`); } diff --git a/src/intervals/memory.ts b/src/intervals/memory.ts index c3390c9..81702fd 100644 --- a/src/intervals/memory.ts +++ b/src/intervals/memory.ts @@ -77,7 +77,7 @@ export default function memory(client: Client) { embed.setTimestamp(); await client.createMessage(channelID, { embed }); if (memoryConversion >= acc.ramLimitNotification) { - if (acc.ramLimitNotification === -1) return; + if (acc.ramLimitNotification === 0) return; const notifyEmbed = new RichEmbed() .setTitle('Cloud Account | Notification') .setDescription(`You are about to reach your RAM resource limits, you are currently using '${String(memoryConversion)} MB' and your limit is '${String(userLimits.hard - 10)} MB'. Please correct your usage to avoid further action.\nYou can set your notification preferences by running \`=limits set-ram-notification \`, you can disable these notifications by running \`=limits set-ram-notification -1\`.`) From 2a6af24499f9420d00b03be3e5ab65219383d691 Mon Sep 17 00:00:00 2001 From: Bsian Date: Sun, 3 May 2020 23:55:57 +0100 Subject: [PATCH 2/2] Only show command line output on error --- src/commands/pull.ts | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/src/commands/pull.ts b/src/commands/pull.ts index cc21674..8ab1183 100644 --- a/src/commands/pull.ts +++ b/src/commands/pull.ts @@ -16,31 +16,28 @@ export default class Pull extends Command { try { if (this.client.updating) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Update in progress***`); this.client.updating = true; - const updateMessage = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Fetching latest commit...***\n\`\`\`sh\n$ git pull\n\`\`\``); + const updateMessage = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Fetching latest commit...***`); let pull: string; try { pull = await this.client.util.exec('git pull', { cwd: '/opt/CloudServices' }); } catch (error) { - const updatedMessage = updateMessage.content.replace(`${this.client.stores.emojis.loading} ***Fetching latest commit...***`, `${this.client.stores.emojis.error} ***Could not fetch latest commit***`) - .replace(/```$/, `${error.message}\n\`\`\``); + const updatedMessage = updateMessage.content.replace(`${this.client.stores.emojis.loading} ***Fetching latest commit...***`, `${this.client.stores.emojis.error} ***Could not fetch latest commit***\n` + + `\`\`\`\n${error.message}\n\`\`\``); this.client.updating = false; return updateMessage.edit(updatedMessage); } if (pull.includes('Already up to date')) { - const updatedMessage = updateMessage.content.replace(`${this.client.stores.emojis.loading} ***Fetching latest commit...***`, `${this.client.stores.emojis.success} ***No updates available***`) - .replace(/```$/, `${pull}\n\`\`\``); + const updatedMessage = updateMessage.content.replace(`${this.client.stores.emojis.loading} ***Fetching latest commit...***`, `${this.client.stores.emojis.success} ***No updates available***`); this.client.updating = false; return updateMessage.edit(updatedMessage); } if (!pull.includes('origin/master') && !pull.includes(' changed, ')) { - const updatedMessage = updateMessage.content.replace(`${this.client.stores.emojis.loading} ***Fetching latest commit...***`, `${this.client.stores.emojis.error} ***Unexpected git output***`) - .replace(/```$/, `${pull}\n\`\`\``); + const updatedMessage = updateMessage.content.replace(`${this.client.stores.emojis.loading} ***Fetching latest commit...***`, `${this.client.stores.emojis.error} ***Unexpected git output***`); this.client.updating = false; return updateMessage.edit(updatedMessage); } - const continueMessage = updateMessage.content.replace(`${this.client.stores.emojis.loading} ***Fetching latest commit...***`, `${this.client.stores.emojis.success} ***Pulled latest commit***\n${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`) - .replace(/```$/, `${pull}\n$ yarn install\n\`\`\``); + const continueMessage = updateMessage.content.replace(`${this.client.stores.emojis.loading} ***Fetching latest commit...***`, `${this.client.stores.emojis.success} ***Pulled latest commit***\n${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`); const passedPull = await updateMessage.edit(continueMessage); @@ -49,22 +46,20 @@ export default class Pull extends Command { install = await this.client.util.exec('yarn install', { cwd: '/opt/CloudServices' }); } catch (error) { this.client.updating = false; - const updatedMessage = passedPull.content.replace(`${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`, `${this.client.stores.emojis.error} ***Failed to reinstall dependencies***`) - .replace(/```$/, `${error.message}\n\`\`\``); + const updatedMessage = passedPull.content.replace(`${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`, `${this.client.stores.emojis.error} ***Failed to reinstall dependencies***\n` + + `\`\`\`\n${error.message}\n\`\`\``); return updateMessage.edit(updatedMessage); } let updatedPackages: Message; if (install.includes('Already up-to-date')) { - const updatedMessage = passedPull.content.replace(`${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`, `${this.client.stores.emojis.success} ***No dependency updates available***\n${this.client.stores.emojis.loading} ***Rebuilding files...***`) - .replace(/```$/, `${install}\n$ yarn run build\n\`\`\``); + const updatedMessage = passedPull.content.replace(`${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`, `${this.client.stores.emojis.success} ***No dependency updates available***\n${this.client.stores.emojis.loading} ***Rebuilding files...***`); updatedPackages = await updateMessage.edit(updatedMessage); } else if (install.includes('success Saved lockfile.')) { - const updatedMessage = passedPull.content.replace(`${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`, `${this.client.stores.emojis.success} ***Updated dependencies***\n${this.client.stores.emojis.loading} ***Rebuilding files...***`) - .replace(/```$/, `${install}\n$ yarn run build\n\`\`\``); + const updatedMessage = passedPull.content.replace(`${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`, `${this.client.stores.emojis.success} ***Updated dependencies***\n${this.client.stores.emojis.loading} ***Rebuilding files...***`); updatedPackages = await updateMessage.edit(updatedMessage); } else { - const updatedMessage = passedPull.content.replace(`${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`, `${this.client.stores.emojis.error} ***Unexpected yarn install output***`) - .replace(/```$/, `${pull}\n\`\`\``); + const updatedMessage = passedPull.content.replace(`${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`, `${this.client.stores.emojis.error} ***Unexpected yarn install output***\n` + + `\`\`\`\n${pull}\n\`\`\``); this.client.updating = false; return updateMessage.edit(updatedMessage); } @@ -73,14 +68,13 @@ export default class Pull extends Command { try { build = await this.client.util.exec('yarn run build', { cwd: '/opt/CloudServices' }); } catch (error) { - const updatedMessage = updatedPackages.content.replace(`${this.client.stores.emojis.loading} ***Rebuilding files...***`, `${this.client.stores.emojis.error} ***Failed to rebuild files***`) - .replace(/```$/, `${error.message}\n\`\`\``); + const updatedMessage = updatedPackages.content.replace(`${this.client.stores.emojis.loading} ***Rebuilding files...***`, `${this.client.stores.emojis.error} ***Failed to rebuild files***\n` + + `\`\`\`\n${error.message}\n\`\`\``); this.client.buildError = true; this.client.updating = false; return updateMessage.edit(updatedMessage); } - const finalMessage = updatedPackages.content.replace(`${this.client.stores.emojis.loading} ***Rebuilding files...***`, `${this.client.stores.emojis.success} ***Files rebuilt***`) - .replace(/```$/, `${build}\n\`\`\``); + const finalMessage = updatedPackages.content.replace(`${this.client.stores.emojis.loading} ***Rebuilding files...***`, `${this.client.stores.emojis.success} ***Files rebuilt***`); this.client.updating = false; this.client.buildError = false; return updateMessage.edit(finalMessage);