Skip to content

Commit cf10d7f

Browse files
Updated to latest features and added new commands.
1 parent ceb9be4 commit cf10d7f

File tree

24 files changed

+609
-790
lines changed

24 files changed

+609
-790
lines changed

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
package-lock.json
2+
package-lock.json
3+
configuration/config.json

Diff for: LICENSE

-21
This file was deleted.

Diff for: README.md

+17-23
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
1-
# __AI Image Discord Bot__
2-
![](https://media.discordapp.net/attachments/1140901235545874472/1157330835826028564/image.png?ex=651837d5&is=6516e655&hm=9fb3269a30abcf3d73e731c8783f48a5daf1caad382caa570518e961dd71d414&=&width=568&height=360)
1+
# Installation
32

4-
## __Features__
5-
- Generate upto 4 images (as much you want)
6-
- Autocomplete models
7-
8-
## __Installation__
9-
#### __1. Clone the repository__
10-
```bash
11-
git clone https://github.com/flameface/ai-image-bot.git
3+
Install all packages required to run the bot.
124
```
13-
14-
#### __2. Install the dependencies__
15-
```bash
165
npm install
176
```
187

19-
#### __3. Configure the bot__
20-
In [config](./structures/configuration/index.js) file, fill in the required fields, get your prodia key from [here](https://prodia.com/)
21-
22-
#### __4. Run the bot__
23-
```bash
24-
npm start
8+
Go to configuration folder and fill the require values and also rename **config.json.example** -> **config.json**, get the prodia key from their [official](https://prodia.com/) site.
9+
```json
10+
{
11+
"ClientToken": "",
12+
"ClientID": "",
13+
"ClientPrefix": ".",
14+
"DeveloperIds": [""],
15+
"ProdiaKey": ""
16+
}
2517
```
2618

27-
## __Contact__
28-
If you have any questions or suggestions, then you can join our [support server](https://discord.gg/TvjrWtEuyP) and ask there.
19+
To run the bot run the following command.
20+
```
21+
node index.js
22+
```
2923

30-
## __License__
31-
This project is licensed under the [MIT License](./LICENSE).
24+
# Label
25+
This project belongs to **[Unburn](https://github.com/unburn)**, and you have full rights to modify or contribute.

Diff for: commands/information/ping.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const { Message, Client } = require("discord.js");
2+
3+
const data = {
4+
name: "ping",
5+
aliases: ["ms", "ws"],
6+
}
7+
8+
const perms = {
9+
BotPermissions: ["SendMessages"], UserPermissions: ["SendMessages"], devOnly: false
10+
}
11+
12+
/**
13+
* @param {Client} client;
14+
* @param {Message} message;
15+
* @param {*} args;
16+
* @returns;
17+
*
18+
*/
19+
20+
async function callback(client, message, args) {
21+
return message.reply({ content: `Ping: ${client.ws.ping}ms` });
22+
}
23+
24+
module.exports = { data, perms, callback }

Diff for: configuration/choices.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
const styles = [
2+
{ name: "3d-model", value: "3d-model" },
3+
{ name: "analog-film", value: "analog-film" },
4+
{ name: "anime", value: "anime" },
5+
{ name: "cinematic", value: "cinematic" },
6+
{ name: "comic-book", value: "comic-book" },
7+
{ name: "digital-art", value: "digital-art" },
8+
{ name: "enhance", value: "enhance" },
9+
{ name: "fantasty-art", value: "fantasty-art" },
10+
{ name: "isometric", value: "isometric" },
11+
{ name: "line-art", value: "line-art" },
12+
{ name: "low-poly", value: "low-poly" },
13+
{ name: "neon-punk", value: "neon-punk" },
14+
{ name: "origami", value: "origami" },
15+
{ name: "photographic", value: "photographic" },
16+
{ name: "pixel-art", value: "pixel-art" },
17+
{ name: "texture", value: "texture" },
18+
{ name: "craft-clay", value: "craft-clay" }
19+
]
20+
21+
const samplers = [
22+
{ name: "Euler", value: "Euler" },
23+
{ name: "Euler a", value: "Euler a" },
24+
{ name: "LMS", value: "LMS" },
25+
{ name: "Heun", value: "Heun" },
26+
{ name: "DPM2", value: "DPM2" },
27+
{ name: "DPM2 a", value: "DPM2 a" },
28+
{ name: "DPM++ 2S a", value: "DPM++ 2S a" },
29+
{ name: "DPM++ 2M", value: "DPM++ 2M" },
30+
{ name: "DPM++ SDE", value: "DPM++ SDE" },
31+
{ name: "DPM fast", value: "DPM fast" },
32+
{ name: "DPM adaptive", value: "DPM adaptive" },
33+
{ name: "LMS Karras", value: "LMS Karras" },
34+
{ name: "DPM2 Karras", value: "DPM2 Karras" },
35+
{ name: "DPM2 a Karras", value: "DPM2 a Karras" },
36+
{ name: "DPM++ 2S a Karras", value: "DPM++ 2S a Karras" },
37+
{ name: "DPM++ 2M Karras", value: "DPM++ 2M Karras" },
38+
{ name: "DPM++ SDE Karras", value: "DPM++ SDE Karras" },
39+
{ name: "DDIM", value: "DDIM" },
40+
{ name: "PLMS", value: "PLMS" }
41+
]
42+
43+
const aspectRatio = [
44+
{ name: "landscape", value: "landscape" },
45+
{ name: "portrait", value: "portrait" },
46+
{ name: "square", value: "square" }
47+
]
48+
49+
module.exports = { styles, samplers, aspectRatio }

Diff for: configuration/common.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const resetColor = "\x1b[0m";
2+
3+
const print = {
4+
reset: (text) => `${text}${resetColor}`,
5+
bright: (text) => `\x1b[1m${text}${resetColor}`,
6+
dim: (text) => `\x1b[2m${text}${resetColor}`,
7+
underscore: (text) => `\x1b[4m${text}${resetColor}`,
8+
blink: (text) => `\x1b[5m${text}${resetColor}`,
9+
reverse: (text) => `\x1b[7m${text}${resetColor}`,
10+
hidden: (text) => `\x1b[8m${text}${resetColor}`,
11+
12+
black: (text) => `\x1b[30m${text}${resetColor}`,
13+
red: (text) => `\x1b[31m${text}${resetColor}`,
14+
green: (text) => `\x1b[32m${text}${resetColor}`,
15+
oysterpink: (text) => `\x1b[38;2;213;180;180m${text}${resetColor}`,
16+
gray: (text) => `\x1b[38;5;8m${text}${resetColor}`,
17+
yellow: (text) => `\x1b[33m${text}${resetColor}`,
18+
blue: (text) => `\x1b[34m${text}${resetColor}`,
19+
magenta: (text) => `\x1b[35m${text}${resetColor}`,
20+
cyan: (text) => `\x1b[36m${text}${resetColor}`,
21+
white: (text) => `\x1b[37m${text}${resetColor}`,
22+
23+
bgBlack: (text) => `\x1b[40m${text}${resetColor}`,
24+
bgRed: (text) => `\x1b[41m${text}${resetColor}`,
25+
bgGreen: (text) => `\x1b[42m${text}${resetColor}`,
26+
bgYellow: (text) => `\x1b[43m${text}${resetColor}`,
27+
bgBlue: (text) => `\x1b[44m${text}${resetColor}`,
28+
bgMagenta: (text) => `\x1b[45m${text}${resetColor}`,
29+
bgCyan: (text) => `\x1b[46m${text}${resetColor}`,
30+
bgWhite: (text) => `\x1b[47m${text}${resetColor}`,
31+
};
32+
33+
function dateTime(d) {
34+
let offsetIST = 330;
35+
d.setMinutes(d.getMinutes() + d.getTimezoneOffset() + offsetIST);
36+
37+
const year = String(d.getFullYear()), time = String(d.toLocaleTimeString());
38+
let month = String(d.getMonth() + 1), day = String(d.getDate());
39+
40+
if (month.length < 2) month = "0" + month;
41+
if (day.length < 2) day = "0" + day;
42+
return `${year}-${month}-${day} ${time}`;
43+
}
44+
45+
46+
function logger(type, name, description) {
47+
let info, dis;
48+
if (type == "INFO") { info = "green"; dis = "oysterpink" } else if (type == "WARN") { info = "yellow"; dis = "red" }
49+
console.log(print.gray(`[x] ${dateTime(new Date())}`), print[`${info}`](` ${type}`), ` ${print.cyan(`${name}`.padEnd(20))} : ${print[`${dis}`](`${description}`)}`)
50+
}
51+
52+
53+
module.exports = { logger };

Diff for: configuration/config.json.example

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"ClientToken": "",
3+
"ClientID": "",
4+
"ClientPrefix": ".",
5+
"DeveloperIds": [
6+
""
7+
]
8+
"ProdiaKey": "",
9+
}

Diff for: events/client/interactionCreate.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const { ChatInputCommandInteraction } = require("discord.js");
2+
const client = require("../../index");
3+
4+
module.exports = {
5+
name: "interactionCreate",
6+
7+
/**
8+
* @param {ChatInputCommandInteraction} interaction;
9+
* @returns;
10+
*
11+
*/
12+
13+
callback: async (interaction) => {
14+
15+
if (!interaction.isChatInputCommand() && !interaction.isContextMenuCommand()) return;
16+
const { user, guild, commandName, member } = interaction;
17+
18+
if (!guild) return;
19+
20+
const command = client.slashCommands.get(commandName);
21+
22+
if (!command) {
23+
return interaction.reply({ content: `This commands doest't exist!`, ephemeral: true }) && client.slashCommands.delete(commandName);
24+
}
25+
26+
if (command.perms.UserPermissions && command.perms.UserPermissions.length !== 0) {
27+
if (!member.permissions.has(command.perms.UserPermissions)) return interaction.reply({ content: `You need \`${command.perms.UserPermissions.join(", ")}\` permission(s) to execute this command!`, ephemeral: true });
28+
}
29+
30+
31+
if (command.perms.BotPermissions && command.perms.BotPermissions.length !== 0) {
32+
if (!guild.members.me.permissions.has(command.perms.BotPermissions)) return interaction.reply({ content: `I need \`${command.perms.BotPermissions.join(", ")}\` permission(s) to execute this command!`, ephemeral: true });
33+
}
34+
35+
36+
if (command.perms.devOnly && !client.Developer.includes(user.id)) return interaction.reply({ content: `This command is devOnly!`, ephemeral: true });
37+
38+
command.callback(client, interaction);
39+
}
40+
}

Diff for: events/client/messageCreate.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const { Message, ChannelType } = require("discord.js");
2+
const { ClientPrefix } = require("../../configuration/config.json");
3+
const client = require("../../index");
4+
5+
module.exports = {
6+
name: "messageCreate",
7+
8+
/**
9+
* @param {Message} message;
10+
* @returns;
11+
*
12+
*/
13+
14+
callback: async (message) => {
15+
16+
if (message.channel.type !== ChannelType.GuildText) return;
17+
const { author, guild, member } = message;
18+
19+
if (author.bot || !message.guild || !message.content.toLowerCase().startsWith(ClientPrefix)) return;
20+
const [cmd, ...args] = message.content.slice(ClientPrefix.length).trim().split(/ +/g);
21+
22+
const command = client.commands.get(cmd.toLowerCase()) || client.commands.find(c => c.data.aliases?.includes(cmd.toLowerCase()));
23+
24+
if (!command) return;
25+
26+
if (command.perms.UserPermissions && command.perms.UserPermissions.length !== 0) {
27+
if (!member.permissions.has(command.perms.UserPermissions)) return message.reply({ content: `You need \`${command.perms.UserPermissions.join(", ")}\` permission(s) to execute this command!` });
28+
}
29+
30+
if (command.perms.BotPermissions && command.perms.BotPermissions.length !== 0) {
31+
if (!guild.members.me.permissions.has(command.perms.BotPermissions)) return message.reply({ content: `I need \`${command.perms.BotPermissions.join(", ")}\` permission(s) to execute this command!` });
32+
}
33+
34+
if (command.perms.devOnly && !client.Developer.includes(author.id)) return message.reply({ content: `This command is devOnly!` });
35+
36+
command.callback(client, message, args);
37+
}
38+
}

Diff for: events/client/ready.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const { ActivityType } = require("discord.js");
2+
const { logger } = require("../../configuration/common.js");
3+
const client = require("../../index");
4+
5+
module.exports = {
6+
name: "ready",
7+
once: true,
8+
9+
/**
10+
* @param {Client} client
11+
* @returns;
12+
*
13+
*/
14+
15+
callback: async () => {
16+
console.log("\n")
17+
logger("INFO", "Client", `${client.user.tag} Is Online!`)
18+
19+
let i = 0;
20+
let statuses = ["Images"];
21+
22+
23+
setInterval(() => {
24+
let status = statuses[i];
25+
client.user.setActivity({ name: status, type: ActivityType.Playing });
26+
i = (i + 1) % statuses.length;
27+
}, 5000);
28+
}
29+
}

0 commit comments

Comments
 (0)