Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2a26d7a
Create Base of the Typescript project
websitedesigner123456-stack Jan 13, 2022
3391d41
Remove node_modules
websitedesigner123456-stack Jan 13, 2022
878f941
Remove Node_Modules
websitedesigner123456-stack Jan 13, 2022
8be5814
Registering Slash commands
websitedesigner123456-stack Jan 13, 2022
05f9dc1
Create CHANGELOG.md
websitedesigner123456-stack Jan 13, 2022
476d3cb
Deleting complete bot and starting from scratch in different language
websitedesigner123456-stack Jan 13, 2022
c0a1710
Set Basic structure of the bot
websitedesigner123456-stack Jan 13, 2022
48d5444
Added Basic Structure for the bot
websitedesigner123456-stack Jan 13, 2022
11302cc
Add /story command
websitedesigner123456-stack Jan 13, 2022
2958eb8
Merge branch 'master' of https://github.com/pgamerx/Hackathon
websitedesigner123456-stack Jan 13, 2022
92ea372
Update event files
websitedesigner123456-stack Jan 13, 2022
b69a36b
Updated AI-Based Generation 'story' command
websitedesigner123456-stack Jan 13, 2022
d7331b1
Changelog
websitedesigner123456-stack Jan 13, 2022
f7c768a
Added/Created command
websitedesigner123456-stack Jan 13, 2022
52d0031
Added command
websitedesigner123456-stack Jan 14, 2022
fd994c5
Added command
websitedesigner123456-stack Jan 14, 2022
dc3cf91
Added command and preseumably the last command to get added
websitedesigner123456-stack Jan 14, 2022
edd6f83
Add chatbot command
websitedesigner123456-stack Jan 14, 2022
635fddd
Added '/highres' command
websitedesigner123456-stack Jan 15, 2022
ee46b35
Fix
websitedesigner123456-stack Jan 15, 2022
2eb2f1b
Unexpected change
websitedesigner123456-stack Jan 15, 2022
0d7269b
Create CHANGELOG.md
websitedesigner123456-stack Jan 19, 2022
13fcb30
Add ReadMe.md
websitedesigner123456-stack Jan 19, 2022
e4e428d
Merge branch 'DocumaticAI:master' into master
websitedesigner123456-stack Jan 19, 2022
7823890
Delete .DS_Store
websitedesigner123456-stack Jan 19, 2022
28af841
Add Help command
websitedesigner123456-stack Jan 19, 2022
7bcd893
Update CHANGELOG.md
websitedesigner123456-stack Jan 19, 2022
6415a2b
Delete .DS_Store
websitedesigner123456-stack Jan 19, 2022
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
49 changes: 49 additions & 0 deletions src/PGamerX/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"extends": "eslint:recommended",
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 2021
},
"rules": {
"arrow-spacing": ["warn", { "before": true, "after": true }],
"brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": "error",
"comma-style": "error",
"curly": ["error", "multi-line", "consistent"],
"dot-location": ["error", "property"],
"handle-callback-err": "off",
"indent": ["error", "tab"],
"keyword-spacing": "error",
"max-nested-callbacks": ["error", { "max": 4 }],
"max-statements-per-line": ["error", { "max": 2 }],
"no-console": "off",
"no-empty-function": "error",
"no-floating-decimal": "error",
"no-inline-comments": "error",
"no-lonely-if": "error",
"no-multi-spaces": "error",
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
"no-shadow": ["error", { "allow": ["err", "resolve", "reject"] }],
"no-trailing-spaces": ["error"],
"no-var": "error",
"object-curly-spacing": ["error", "always"],
"prefer-const": "error",
"quotes": ["error", "single"],
"semi": ["error", "always"],
"space-before-blocks": "error",
"space-before-function-paren": ["error", {
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}],
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
"yoda": "error"
}
}
2 changes: 2 additions & 0 deletions src/PGamerX/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.env
48 changes: 48 additions & 0 deletions src/PGamerX/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Changelog

Based on KeepAChangelog.
Generated by **Documatic.**

## Unreleased

### Added

* /story command
* Command
* Command and preseumably the last command to get added
* Chatbot command
* '/highres' command
* Changelog.md
* Readme.md
* Help command

### Changed

* Event files
* Ai-based generation 'story' command

### Fixed

* Bugs in commands

### Removed

* .ds_store

## 0.1 - 2022-01-13

## delete - 2022-01-13

### Added

* Base of the typescript project
* Changelog.md
* Basic structure for the bot

### Changed

* Readme.md

### Removed

* Node_modules
17 changes: 17 additions & 0 deletions src/PGamerX/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# LeBot
A powerful discord bot that uses Random Stuff Api and DeepAi to perform various tasks, like detecting nudity in an image, add colors to a black and white image, detect sentiment and much more.

## Demo
If you cannot host the project yourself, you can test the bot out by inviting [LeBot](https://discord.com/oauth2/authorize?client_id=931064679625809921&scope=+applications.commands+bot&permissions=412317240384) in your server.

## Self Hosting
* Clone the project
You will have to first clone the project in order to self host it.
* Add Credentials
Add your credentials in `example.env` file and rename it to `.env`
* Add the bot to your server
You should add the bot to your server.
* Installing Dependencies
You should install the dependencies by running `npm install` command in the terminal.
* Running the bot
Then you should run the bot by running `node .` command in the terminal.
46 changes: 46 additions & 0 deletions src/PGamerX/commands/slash/chatbot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const RsaKey = process.env.RSAKEY;
const RapidApiKey = process.env.RAPIDAPIKEY;
const axios = require("axios").default;

module.exports = {
data: new SlashCommandBuilder()
.setName("chatbot")
.setDescription("Talk to an AI-powered chatbot")
.addStringOption((option) =>
option
.setName("message")
.setDescription("What do you want to say?")
.setRequired(true)
),
async execute(interaction) {
const message = interaction.options.getString("message");
var options = {
method: "GET",
url: "https://random-stuff-api.p.rapidapi.com/ai",
params: {
msg: message,
id: interaction.user.id,
},
headers: {
Authorization: RsaKey,
"x-rapidapi-host": "random-stuff-api.p.rapidapi.com",
"x-rapidapi-key": RapidApiKey,
},
};

axios
.request(options)
.then(async function (response) {
await interaction.editReply({
content: response.data["AIResponse"]
});
})
.catch(async function (error) {
console.log(error)
await interaction.editReply({
content: `An Error occured: ${error}`,
});
});
},
};
52 changes: 52 additions & 0 deletions src/PGamerX/commands/slash/colorize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const {
MessageActionRow,
MessageButton,
MessageEmbed,
Message,
} = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("colorize")
.setDescription("Turn any black & white image into a colored one!"),
async execute(interaction) {
const filter = (m) => m.attachments.size > 0;
await interaction.editReply({
content:
"Kindly send a black and white image in this channel within 15 seconds.",
});
const collector = interaction.channel.createMessageCollector({
filter,
time: 15000,
});

collector.on("collect", async (m) => {


const attachment_url = [...m.attachments.values()][0].url;
if (!attachment_url) {
return m.channel.send(`Please send a valid black and white image`)
}
const sent = await m.channel.send(`Image Recieved, Processing :gear:`)
const resp = await interaction.client.deepai.callStandardApi(
"colorizer",
{
image: attachment_url,
}
);
const embed = new MessageEmbed()
.setTitle("Colored Image")
.setImage(resp["output_url"])
.setColor("GREEN")
.setAuthor({
name: interaction.user.username,
iconURL: interaction.user.avatarURL(),
})
.setFooter({ text: `Generated by ${interaction.user.username}` });
await sent.edit({ content: "Processing Completed, here is the result",embeds: [embed] });
});
collector.on("end", (collected) => {
console.log(`Collected ${collected.size} items`);
});
},
};
32 changes: 32 additions & 0 deletions src/PGamerX/commands/slash/help.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const {MessageEmbed} = require('discord.js');

require('dotenv').config();

module.exports = {
data: new SlashCommandBuilder()
.setName('help')
.setDescription('Help menu of the bot'),
async execute(interaction) {
const embed = new MessageEmbed()
.setTitle("LeBot's Help Menu")
.setDescription(`LeBot is a bot that can be used to generate AI-based stories and other fun stuff like nudity detecton, tone detection, analysis and more!`)
.setColor('GREEN')
.setAuthor({name: interaction.user.username, iconURL: interaction.user.avatarURL()})
.addField(`Important Links`, `[Invite Bot](https://discord.com/oauth2/authorize?client_id=${process.env.BOT_CLIENT_ID}&scope=+applications.commands+bot&permissions=412317240384)`)
.addField(`Commands`, `You can use the following commands to interact with the bot:`)
.addField(`/story`, `Generate a story.`)
.addField(`/isnsfw`, `Know if an image contains nudity or not.`)
.addField(`/beta`, `Hop into Beta mode. (This will allow you to use the bot while in beta.)`)
.addField(`/chatbot`, `Chat with an AI-based chatbot.`)
.addField(`/colorize`, `Turn any black and white image into a colored one!`)
.addField(`/highres`, `Turn any low-res image into a high-res one!`)
.addField(`/sentiment`, `Analyze the sentiment of a text.`)
.addField(`/help`, `This menu.`)
.setFooter({text: "LeBot v1"})

return await interaction.editReply({
embeds: [embed]
});
},
};
44 changes: 44 additions & 0 deletions src/PGamerX/commands/slash/highres.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageEmbed, Message } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("highres")
.setDescription("Turn any low-res image into a high-res one!"),
async execute(interaction) {
const filter = (m) => m.attachments.size > 0;
await interaction.editReply({
content: "Kindly send an image in this channel within 15 seconds.",
});
const collector = interaction.channel.createMessageCollector({
filter,
time: 15000,
});

collector.on("collect", async (m) => {
const attachment_url = [...m.attachments.values()][0].url;
if (!attachment_url) {
return m.channel.send(`Please send a valid image`);
}
const sent = await m.channel.send(`Image Recieved, Processing :gear:`);
var resp = await interaction.client.deepai.callStandardApi("torch-srgan", {
image: attachment_url,
});
const embed = new MessageEmbed()
.setTitle("High-Resolution Image")
.setImage(resp["output_url"])
.setColor("GREEN")
.setAuthor({
name: interaction.user.username,
iconURL: interaction.user.avatarURL(),
})
.setFooter({ text: `Generated by ${interaction.user.username}` });
await sent.edit({
content: "Processing Completed, here is the result",
embeds: [embed],
});
});
collector.on("end", (collected) => {
console.log(`Collected ${collected.size} items`);
});
},
};
74 changes: 74 additions & 0 deletions src/PGamerX/commands/slash/isnsfw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageEmbed } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("isnsfw")
.setDescription("Know if an image contains nudity or not."),
async execute(interaction) {
// Check if channel is NSFW
if (!interaction.channel.nsfw) {
return await interaction.editReply({
content: "This command is only available in NSFW channels.",
ephemeral: true,
});
}
const filter = (m) => m.attachments.size > 0;
await interaction.editReply({
content: "Kindly send an image in this channel within 15 seconds.",
});
const collector = interaction.channel.createMessageCollector({
filter,
time: 15000,
});

collector.on("collect", async (m) => {
const attachment_url = [...m.attachments.values()][0].url;
if (!attachment_url) {
return m.channel.send(`Please send a valid image`);
}
const sent = await m.channel.send(`Image Recieved, Processing :gear:`);
const resp = await interaction.client.deepai.callStandardApi(
"nsfw-detector",
{
image: attachment_url,
}
);
let color;
if (resp["output"]["nsfw_score"] < 0.5) {
color = "GREEN";
} else if (resp["output"]["nsfw_score"] >= 0.5) {
color = "RED";
}
const embed = new MessageEmbed()
.setTitle("Nudity Detection")
.setImage(attachment_url)
.setColor(color)
.setAuthor({
name: interaction.user.username,
iconURL: interaction.user.avatarURL(),
})
.addField(
"Probability of image being NSFW:",
`${parseInt(parseFloat(resp["output"]["nsfw_score"]) * 100)}%`
)
.setFooter({ text: `Check ran by ${interaction.user.username}` });

let i;
for (i = 0; i < resp["output"]["detections"].length; i++) {
embed.addField(
`Detection ${i + 1}`,
`${resp["output"]["detections"][i]["name"]}: ${
parseFloat(resp["output"]["detections"][i]["confidence"]) * 100
}%`
);
}
await sent.edit({
content: "Processing Completed, here is the result",
embeds: [embed],
});
});
collector.on("end", (collected) => {
console.log(`Collected ${collected.size} items`);
});
},
};
10 changes: 10 additions & 0 deletions src/PGamerX/commands/slash/ping.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { SlashCommandBuilder } = require('@discordjs/builders');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with current latency of API'),
async execute(interaction) {
return interaction.editReply(':ping_pong: API Latency: ' + Math.round(interaction.client.ws.ping) + 'ms');
},
};
Loading