first commit
This commit is contained in:
commit
16736ec18f
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
node_modules
|
||||||
|
.env
|
||||||
|
package-lock.json
|
35
README.md
Normal file
35
README.md
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# Discord-Linux Discord.JS v14 Base Template
|
||||||
|
|
||||||
|
Only 3 dependencies required to run this bot!
|
||||||
|
|
||||||
|
Message intents are NOT supported in this bot, this is due to the verification that Discord is enabling.
|
||||||
|
|
||||||
|
Structure:
|
||||||
|
|
||||||
|
**commands** - This folder contains commands
|
||||||
|
|
||||||
|
**event** - This folder contains files related to discord.js events. (Like "ready", "interactionCreate")
|
||||||
|
|
||||||
|
**handler** - This folder contains files that read the commands folders contents.
|
||||||
|
|
||||||
|
**index.js** - This is the main file to run the bot.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
1) Use ```npm i ```
|
||||||
|
|
||||||
|
2) Create a .env file ``` touch .env```
|
||||||
|
|
||||||
|
3) Edit .env
|
||||||
|
```
|
||||||
|
TOKEN = token
|
||||||
|
```
|
||||||
|
|
||||||
|
4) Go to Handler -- > index.js and change "GUIDIDHERE" to your Discord Server's Guild ID
|
||||||
|
|
||||||
|
5) Go into https://discord.com/developers/applications and enable Privileged Intents.
|
||||||
|
|
||||||
|
6) Run the bot ```node index.js```
|
||||||
|
|
||||||
|
|
||||||
|
Want to make this better? Issue a pull request!
|
86
commands/Info/ping.js
Normal file
86
commands/Info/ping.js
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
const { EmbedBuilder } = require('discord.js');
|
||||||
|
var unirest = require('unirest');
|
||||||
|
const cmd = require('cmd-promise')
|
||||||
|
const fs = require("fs");
|
||||||
|
let lang
|
||||||
|
module.exports = {
|
||||||
|
name: "send",
|
||||||
|
private: false,
|
||||||
|
description: "send an inquiry to the AI",
|
||||||
|
options: [{
|
||||||
|
"name": "inquiry",
|
||||||
|
"description": "What you would like to send.",
|
||||||
|
"required": true,
|
||||||
|
"type": 3 // 6 is type USER
|
||||||
|
}],
|
||||||
|
run: async (client, interaction) => {
|
||||||
|
let data = interaction.options._hoistedOptions[0].value
|
||||||
|
|
||||||
|
function detectCodingLanguages(str) {
|
||||||
|
const languages = {
|
||||||
|
'javascript': 'js',
|
||||||
|
'nodejs': 'js',
|
||||||
|
'node': 'js',
|
||||||
|
'python': 'py',
|
||||||
|
'ruby': 'rb',
|
||||||
|
'c#': 'csharp',
|
||||||
|
'c++': 'cpp',
|
||||||
|
'php': 'php',
|
||||||
|
'go': 'go',
|
||||||
|
'bash': 'bash'
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
let detectedLanguages = [];
|
||||||
|
|
||||||
|
for (let language in languages) {
|
||||||
|
if (str.includes(language)) {
|
||||||
|
detectedLanguages.push(languages[language]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return detectedLanguages;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(detectCodingLanguages(data)[0])
|
||||||
|
|
||||||
|
if (detectCodingLanguages(data)){
|
||||||
|
lang = detectCodingLanguages(data)[0]
|
||||||
|
} else {
|
||||||
|
lang = "js"
|
||||||
|
}
|
||||||
|
|
||||||
|
unirest
|
||||||
|
.post('https://codex-ai-v9q6.onrender.com/')
|
||||||
|
.headers({'Accept': 'application/json', 'Content-Type': 'application/json'})
|
||||||
|
.send({ "prompt": data })
|
||||||
|
.then((response) => {
|
||||||
|
if (response.body.bot.length > 1980){
|
||||||
|
fs.writeFile('/tmp/paste', response.body.bot, err => {
|
||||||
|
if (err) {
|
||||||
|
console.error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
cmd("sleep 2; cat /tmp/paste | dpaste").then(pasteout => {
|
||||||
|
const mainEmbed = new EmbedBuilder()
|
||||||
|
.setColor('#0099ff')
|
||||||
|
.addFields(
|
||||||
|
{ name: 'Please check the below output log:', value: pasteout.stdout.replace("Pro tip: you can password protect your paste just by typing a username and password after your paste command.", "").replace("Paste Saved: ", "").replace("-------------------------------------------------------", "") },
|
||||||
|
).setTitle("Response too large")
|
||||||
|
.setDescription("Our AI was too Powerful!")
|
||||||
|
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
|
||||||
|
(async () => {
|
||||||
|
return await interaction.editReply({ embeds: [mainEmbed] })
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
|
||||||
|
interaction.editReply("```" + lang + response.body.bot + "```")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
};
|
93
events/interactionCreate.js
Normal file
93
events/interactionCreate.js
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
const client = require("../raven_ai");
|
||||||
|
require("dotenv").config();
|
||||||
|
const { glob } = require("glob");
|
||||||
|
const { promisify } = require("util");
|
||||||
|
const globPromise = promisify(glob);
|
||||||
|
|
||||||
|
client.on("interactionCreate", async (interaction) => {
|
||||||
|
|
||||||
|
// Slash Commands
|
||||||
|
const slashCommands = await globPromise(`${process.cwd()}/commands/*/*.js`);
|
||||||
|
const arrayOfSlashCommands = [];
|
||||||
|
|
||||||
|
// Map the slash commands into data to be processed
|
||||||
|
slashCommands.map((value) => {
|
||||||
|
const file = require(value);
|
||||||
|
const splitted = value.split("/");
|
||||||
|
const directory = splitted[splitted.length - 2];
|
||||||
|
|
||||||
|
if (!file?.name) return;
|
||||||
|
|
||||||
|
const properties = {
|
||||||
|
directory,
|
||||||
|
...file
|
||||||
|
};
|
||||||
|
client.slashCommands.set(file.name, properties);
|
||||||
|
|
||||||
|
if (["MESSAGE", "USER"].includes(file.type)) delete file.description;
|
||||||
|
|
||||||
|
// Push the data
|
||||||
|
arrayOfSlashCommands.push(file);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Slash Command Handling
|
||||||
|
if (interaction.isChatInputCommand()) {
|
||||||
|
|
||||||
|
// Grabbing Command Data for this interaction
|
||||||
|
let commandData = []
|
||||||
|
|
||||||
|
// We use ForEach here to filter our array into the single commands info.
|
||||||
|
await arrayOfSlashCommands.forEach(command => {
|
||||||
|
if (command.name == interaction.commandName) {
|
||||||
|
commandData.push(command)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Process and Parse Data
|
||||||
|
let dataToProcess = JSON.stringify(commandData[0])
|
||||||
|
let parsedData = JSON.parse(dataToProcess)
|
||||||
|
|
||||||
|
// If the command is private, set ephemeral true else, set false
|
||||||
|
if (parsedData.private == true) {
|
||||||
|
await interaction.deferReply({
|
||||||
|
ephemeral: true
|
||||||
|
}).catch(() => {});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
await interaction.deferReply({
|
||||||
|
ephemeral: false
|
||||||
|
}).catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const cmd = client.slashCommands.get(interaction.commandName);
|
||||||
|
if (!cmd)
|
||||||
|
return interaction.followUp({
|
||||||
|
content: "An error has occurred "
|
||||||
|
});
|
||||||
|
|
||||||
|
const args = [];
|
||||||
|
|
||||||
|
for (let option of interaction.options.data) {
|
||||||
|
if (option.type === "SUB_COMMAND") {
|
||||||
|
if (option.name) args.push(option.name);
|
||||||
|
option.options?.forEach((x) => {
|
||||||
|
if (x.value) args.push(x.value);
|
||||||
|
});
|
||||||
|
} else if (option.value) args.push(option.value);
|
||||||
|
}
|
||||||
|
interaction.member = interaction.guild.members.cache.get(interaction.user.id);
|
||||||
|
|
||||||
|
cmd.run(client, interaction, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Context Menu Handling
|
||||||
|
if (interaction.isContextMenuCommand()) {
|
||||||
|
await interaction.deferReply({
|
||||||
|
ephemeral: false
|
||||||
|
});
|
||||||
|
const command = client.slashCommands.get(interaction.commandName);
|
||||||
|
if (command) command.run(client, interaction);
|
||||||
|
}
|
||||||
|
});
|
5
events/ready.js
Normal file
5
events/ready.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
const client = require("../raven_ai");
|
||||||
|
|
||||||
|
client.on("ready", () => {
|
||||||
|
console.log(`${client.user.tag} is up and ready to go!`);
|
||||||
|
});
|
37
handler/index.js
Normal file
37
handler/index.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
require("dotenv").config();
|
||||||
|
const { glob } = require("glob");
|
||||||
|
const { promisify } = require("util");
|
||||||
|
const globPromise = promisify(glob);
|
||||||
|
|
||||||
|
module.exports = async (client) => {
|
||||||
|
// Slash Commands
|
||||||
|
const slashCommands = await globPromise(`${process.cwd()}/commands/*/*.js`);
|
||||||
|
const arrayOfSlashCommands = [];
|
||||||
|
slashCommands.map((value) => {
|
||||||
|
const file = require(value);
|
||||||
|
const splitted = value.split("/");
|
||||||
|
const directory = splitted[splitted.length - 2];
|
||||||
|
|
||||||
|
if (!file?.name) return;
|
||||||
|
|
||||||
|
const properties = { directory, ...file };
|
||||||
|
client.slashCommands.set(file.name, properties);
|
||||||
|
|
||||||
|
if (["MESSAGE", "USER"].includes(file.type)) delete file.description;
|
||||||
|
arrayOfSlashCommands.push(file);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Events
|
||||||
|
const eventFiles = await globPromise(`${process.cwd()}/events/*.js`);
|
||||||
|
eventFiles.map((value) => require(value));
|
||||||
|
|
||||||
|
// Slash Commands Register
|
||||||
|
client.on("ready", async () => {
|
||||||
|
// // Register for a single guild
|
||||||
|
// await client.guilds.cache.get("GUIDIDHERE").commands.set(arrayOfSlashCommands);
|
||||||
|
|
||||||
|
// Register for all the guilds the bot is in
|
||||||
|
await client.application.commands.set(arrayOfSlashCommands);
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
71
output.txt
Normal file
71
output.txt
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
1067 [03/Jan/2023:20
|
||||||
|
1025 [03/Jan/2023:22
|
||||||
|
926 [03/Jan/2023:21
|
||||||
|
807 [04/Jan/2023:00
|
||||||
|
784 [03/Jan/2023:23
|
||||||
|
750 [03/Jan/2023:19
|
||||||
|
568 [02/Jan/2023:08
|
||||||
|
488 [01/Jan/2023:12
|
||||||
|
464 [01/Jan/2023:09
|
||||||
|
461 [03/Jan/2023:05
|
||||||
|
394 [02/Jan/2023:16
|
||||||
|
370 [01/Jan/2023:10
|
||||||
|
360 [01/Jan/2023:22
|
||||||
|
341 [03/Jan/2023:00
|
||||||
|
341 [01/Jan/2023:11
|
||||||
|
306 [03/Jan/2023:16
|
||||||
|
295 [02/Jan/2023:15
|
||||||
|
278 [03/Jan/2023:18
|
||||||
|
277 [03/Jan/2023:12
|
||||||
|
274 [03/Jan/2023:03
|
||||||
|
246 [02/Jan/2023:20
|
||||||
|
240 [01/Jan/2023:13
|
||||||
|
233 [03/Jan/2023:13
|
||||||
|
219 [01/Jan/2023:05
|
||||||
|
193 [03/Jan/2023:02
|
||||||
|
184 [02/Jan/2023:10
|
||||||
|
183 [02/Jan/2023:14
|
||||||
|
182 [02/Jan/2023:19
|
||||||
|
179 [03/Jan/2023:15
|
||||||
|
177 [02/Jan/2023:17
|
||||||
|
177 [01/Jan/2023:08
|
||||||
|
174 [02/Jan/2023:13
|
||||||
|
173 [02/Jan/2023:00
|
||||||
|
172 [03/Jan/2023:14
|
||||||
|
171 [04/Jan/2023:01
|
||||||
|
164 [02/Jan/2023:07
|
||||||
|
163 [03/Jan/2023:11
|
||||||
|
163 [02/Jan/2023:18
|
||||||
|
161 [03/Jan/2023:17
|
||||||
|
158 [01/Jan/2023:23
|
||||||
|
151 [01/Jan/2023:20
|
||||||
|
151 [01/Jan/2023:15
|
||||||
|
141 [03/Jan/2023:10
|
||||||
|
139 [03/Jan/2023:07
|
||||||
|
136 [02/Jan/2023:03
|
||||||
|
133 [01/Jan/2023:14
|
||||||
|
133 [01/Jan/2023:06
|
||||||
|
131 [02/Jan/2023:05
|
||||||
|
128 [03/Jan/2023:04
|
||||||
|
128 [02/Jan/2023:23
|
||||||
|
125 [01/Jan/2023:18
|
||||||
|
122 [01/Jan/2023:04
|
||||||
|
121 [03/Jan/2023:08
|
||||||
|
121 [03/Jan/2023:01
|
||||||
|
121 [02/Jan/2023:11
|
||||||
|
120 [02/Jan/2023:06
|
||||||
|
119 [01/Jan/2023:19
|
||||||
|
116 [02/Jan/2023:09
|
||||||
|
116 [01/Jan/2023:16
|
||||||
|
113 [02/Jan/2023:22
|
||||||
|
112 [02/Jan/2023:12
|
||||||
|
106 [03/Jan/2023:09
|
||||||
|
102 [02/Jan/2023:02
|
||||||
|
100 [02/Jan/2023:01
|
||||||
|
98 [02/Jan/2023:21
|
||||||
|
94 [01/Jan/2023:07
|
||||||
|
87 [03/Jan/2023:06
|
||||||
|
87 [01/Jan/2023:17
|
||||||
|
85 [01/Jan/2023:21
|
||||||
|
79 [02/Jan/2023:04
|
||||||
|
36 [01/Jan/2023:03
|
19
package.json
Normal file
19
package.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "dlinuxtemplatev14",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"cmd-promise": "^1.2.0",
|
||||||
|
"discord.js": "^14.0.3",
|
||||||
|
"dotenv": "^16.0.0",
|
||||||
|
"glob": "^7.2.0",
|
||||||
|
"language-detect": "^1.1.0"
|
||||||
|
}
|
||||||
|
}
|
14
raven_ai.js
Normal file
14
raven_ai.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
require("dotenv").config();
|
||||||
|
const { Client, Collection } = require("discord.js");
|
||||||
|
|
||||||
|
const client = new Client({ intents: 4097 });
|
||||||
|
module.exports = client;
|
||||||
|
|
||||||
|
// Global Variables
|
||||||
|
client.commands = new Collection();
|
||||||
|
client.slashCommands = new Collection();
|
||||||
|
|
||||||
|
// Initializing the project
|
||||||
|
require("./handler")(client);
|
||||||
|
|
||||||
|
client.login(process.env.TOKEN);
|
24
test.sh
Executable file
24
test.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#This script will find the IPs with the most connections and add all of its requests together. It will also show what day and what hours the most requests in high frequency were made.
|
||||||
|
|
||||||
|
#Set variables for log file and output file
|
||||||
|
LOG_FILE="/var/log/httpd/access_log"
|
||||||
|
OUTPUT_FILE="output.txt"
|
||||||
|
|
||||||
|
#Find IPs with most connections and add all of its requests together
|
||||||
|
echo "Finding IPs with most connections..."
|
||||||
|
cat $LOG_FILE | awk '{print $1}' | sort | uniq -c | sort -nr > $OUTPUT_FILE
|
||||||
|
echo "Done!"
|
||||||
|
echo ""
|
||||||
|
echo "The IPs with the most connections are:"
|
||||||
|
cat $OUTPUT_FILE
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
#Find what day and what hours the most requests in high frequency were made
|
||||||
|
echo "Finding what day and what hours the most requests in high frequency were made..."
|
||||||
|
cat $LOG_FILE | awk '{print $4}' | cut -d: -f1,2 | sort | uniq -c | sort -nr > $OUTPUT_FILE
|
||||||
|
echo "Done!"
|
||||||
|
echo ""
|
||||||
|
echo "The day and hour with the highest request frequency is:"
|
||||||
|
cat $OUTPUT_FILE
|
Loading…
Reference in New Issue
Block a user