Skip to content

Commit

Permalink
✨ startup issue checking
Browse files Browse the repository at this point in the history
  • Loading branch information
ImDarkTom committed Jun 16, 2023
1 parent 9a2ccb4 commit bebb89c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require('dotenv').config();
const { Client, IntentsBitField } = require('discord.js');
const eventHandler = require('./handlers/eventHandler');
const checkForIssues = require('./utils/checkForIssues');

const client = new Client({
intents: [
Expand All @@ -11,6 +12,10 @@ const client = new Client({
],
});

(async () => {
await checkForIssues();
})();

eventHandler(client);

client.login(process.env.TOKEN);
34 changes: 34 additions & 0 deletions src/utils/checkForIssues.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { baseUrl, port } = require('../../sdConfig.json');
const axios = require("axios");
const sendRequest = require('./SD/sendRequest');

module.exports = async () => {
//SD
await axios.get(`${baseUrl}:${port}/internal/ping`)
.then(response => {
console.log(`✅ ${response.status}: Stable Diffusion is running.`);
})
.catch(error => {
console.error(`❌ ${error.code}: Stable Diffusion was not found. Please verify that you are using the correct url and port in the sdConfig.json file.`)
process.exit([1])
})

//SD Api
await axios.get(`${baseUrl}:${port}/docs`)
.then(response => {
console.log(`✅ ${response.status}: Stable Diffusion API is running.`);
})
.catch(error => {
console.error(`❌ ${error.response.status}: Stable Diffusion API was not found. Make sure you are using the '--api' argument in the COMMANDLINE_ARGS of the webui-user file.`)
process.exit([1])
})

//Check for Lyco extension, it breaks changing models
try {
await sendRequest('sdapi/v1/options', {}, "get");
} catch (error) {
if (error.response.data.error === "ValidationError") {
console.warn("⚠ LyCORIS has been detected as an extension. This means that switching checkpoints will not work. Disabling the extension via the GUI will restore the ability to change checkpoints.")
}
}
};

0 comments on commit bebb89c

Please sign in to comment.