Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚒️ Fix Image Modal Issues, Stop Console notification about NSFWJS #4

Merged
merged 2 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion functions/logConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ module.exports = (client) => {

function customLogger(type, ...messages) {
const combinedMessage = messages.map(m => (typeof m === 'object' ? JSON.stringify(m, null, 2) : m)).join(' ');


if (combinedMessage === "By passing no model path, you're using the model hosted by Infinite.red - Please download and host the model before releasing this in production. See NSFWJS docs for instructions.") {
return;
}

let messageToSend = combinedMessage;
if (combinedMessage.length > 4083) {
messageToSend = `${combinedMessage.slice(0, 4080)}...`;
Expand Down
12 changes: 6 additions & 6 deletions interactions/slash/misc/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ module.exports = {

sdk.auth(XProdiaKey);

let choices = []
sdk.listModels()
.then(({ data }) => {
choices = JSON.parse(data);
})
.catch(err => console.error(err));
try{
const {data} = await sdk.listModels();
choices = JSON.parse(data);
} catch (e) {
return interaction.followUp({embeds: [error]});
}

if (model && !choices.includes(model)) {
const no_model = new EmbedBuilder()
Expand Down
31 changes: 17 additions & 14 deletions interactions/slash/misc/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,24 @@ module.exports = {

sdk.auth(XProdiaKey);

let choices = []
sdk.listModels()
.then(({ data }) => {
choices = JSON.parse(data);
try{
const {data} = await sdk.listModels();
choices = JSON.parse(data);
} catch (e) {
return interaction.followUp({embeds: [error]});
}


const choices_string = "```\n- " + choices.join("\n- ") + "\n```";
const choices_string = "```\n- " + choices.join("\n- ") + "\n```";

const models = new EmbedBuilder()
.setTitle('🖼️ Available Models')
.setDescription(choices_string)
.setColor('Random')

return interaction.followUp({embeds: [models]});
})
.catch(err => interaction.followUp({embeds: [error]}));
}
const models = new EmbedBuilder()
.setTitle('🖼️ Available Models')
.setDescription(choices_string)
.setColor('Random')

return interaction.followUp({embeds: [models]});


},
};