Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.

Commit b777369

Browse files
authored
Merge pull request #5 from Progressbar-Discord-Server/dev
Dev
2 parents c46d90a + 3e505f6 commit b777369

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+5191
-2839
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
config.json
22
node_modules/
3-
jsconfig.json
3+
jsconfig.json
4+
database.sqlite

.vscode/javascript.code-snippets

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"Discord Slash Commands": {
3+
"body": [
4+
"const { SlashCommandBuilder } = require('discord.js')",
5+
"",
6+
"module.exports = {",
7+
" data: new SlashCommandBuilder()",
8+
" .setName('$0')",
9+
" .setDescription(\"\"),",
10+
" async execute(interaction) {",
11+
" ",
12+
" }",
13+
"}"
14+
]
15+
},
16+
"Discord User Context Menu": {
17+
"body": [
18+
"const { ContextMenuCommandBuilder } = require('discord.js');",
19+
"",
20+
"module.exports = {",
21+
" data: new ContextMenuCommandBuilder()",
22+
" .setName('$0')",
23+
" .setType(2),",
24+
" async execute(interaction) {",
25+
" ",
26+
" }",
27+
"}"
28+
]
29+
},
30+
"Discord Message Context Menu": {
31+
"body": [
32+
"const { ContextMenuCommandBuilder } = require('discord.js');",
33+
"",
34+
"module.exports = {",
35+
" data: new ContextMenuCommandBuilder()",
36+
" .setName('$0')",
37+
" .setType(3),",
38+
" async execute(interaction) {",
39+
" ",
40+
" }",
41+
"}"
42+
]
43+
}
44+
}

.vscode/settings.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"autoSnippet.snippets": [
3+
{
4+
"pattern": "**/context menu/User/*.js",
5+
"snippet": "Discord User Context Menu"
6+
},
7+
{
8+
"pattern": "**/context menu/Messages/*.js",
9+
"snippet": "Discord Message Context Menu"
10+
},
11+
{
12+
"pattern": "**/commands/*.js",
13+
"snippet": "Discord Slash Commands"
14+
}
15+
]
16+
}

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# Progressbar Ruler Discord Bot
1+
# Processes Discord Bot
22

3-
This is a moderation bot for the Progressbar95 Fan Discord Server.
3+
This is a moderation bot for the [Progressbar95 Fan Server](https://discord.gg/HWFYmwsFX9).
44

55
## Setting up
66

77
This bot is made with the Node.js runtime.
88

9-
1. Install Node.js 17 and Git.
10-
2. Run `git clone https://github.com/5jiji/Progressbar-Ruler`.
9+
1. Install Node.js 17.
10+
2. Download the latest release [here](https://github.com/Progressbar-Discord-Server/Processes/releases)
1111
3. Copy `config.json.template` to `config.json` and fill in the variables.
1212
4. Run `npm i` to install the required modules.
13-
5. Invite the bot with this link: `https://discord.com/oauth2/authorize?client_id=[ClientID]&permissions=8&scope=bot%20applications.commands` (replace `[ClientID]` with the bot's ID)
14-
6. Register the slash commands with `node deploy-commands.js`.
15-
7. Start the bot with `node .`. The database will automatically be created for you.
13+
5. Register the slash commands with `node deploy-commands.js`.
14+
6. Start the bot with `node .`. The database will automatically be created for you.
15+
7. Invite the bot with the link the console send (Only if "showLink" variable in config.json is true)

Util/Dos.js

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
const fs = require('node:fs');
2+
const readline = require('readline');
3+
4+
async function ProcessDOS(client) {
5+
const cmd = readline.createInterface(process.stdin, process.stdout);
6+
7+
let drive = "S"
8+
let dir = ["\\"]
9+
let drvlabel = "SERVERS"
10+
let depth = 0
11+
let curServer = null
12+
let curC = null
13+
let drvS = {}
14+
let drvC = {}
15+
let inRepl = false
16+
let object = {}
17+
let pm2 = false
18+
if (process.env.PM2_USAGE) pm2 = true
19+
console.log("The object 'object' is used for setting a variable inside for use later with the eval command")
20+
drvS.rootdirs = client.guilds.cache
21+
drvS.subdirs = null
22+
drvC.rootdirs = fs.readdirSync(`${__dirname}/../commands`);
23+
drvC.subdirs = null
24+
//console.log(paths)
25+
cmd.setPrompt(`${drive}:${dir.join("")}>`)
26+
cmd.prompt();
27+
28+
cmd.on('line', async line => {
29+
if (inRepl) return
30+
switch (line.trim().split(" ")[0]) {
31+
case 'exit': {
32+
if (!pm2) {
33+
cmd.close()
34+
await client.destroy()
35+
process.exit(0)
36+
}
37+
else if (pm2) console.log("You are using pm2, to exit the command line, use Ctrl+C.\nIf you want to reload command file, use reload in the C: drive")
38+
break
39+
}
40+
case 'eval': {
41+
try {
42+
console.log(eval(line.substring(4)))
43+
} catch (error) {
44+
console.error(error)
45+
}
46+
break
47+
}
48+
case 'help': case 'man': {
49+
const log = console.log
50+
log("Process DOS help")
51+
log("Commands:\n")
52+
log("eval <code> Evaluates code")
53+
log("status <status> <activity> <description> Changes the status of the bot")
54+
log("send <channel-id> <message> Sends a message on the specified channel")
55+
log("dir Lists the current directory")
56+
log("tail <channel-id> [Amount-of-messages] Lists message in the channel given")
57+
log("type <file> Show the contents of a file")
58+
log("cd [directory] Change directory")
59+
log("cls Clears the screen")
60+
log("echo <text> Displays text on the screen")
61+
log("help Displays this help")
62+
log("exit Terminates the bot and console")
63+
log("reload Reload Command or server, depending on the drive in which executed")
64+
log("deploy Deploy slash (/) commands")
65+
break
66+
}
67+
case 'status': {
68+
if (line.trim() == "status") { client.user.setActivity() }
69+
try {
70+
let status = line.split(" ")[1]
71+
let activity = line.split(" ")[2].toUpperCase()
72+
let description = line.split(" ").slice(3).join(" ")
73+
client.user.setActivity(description, { type: activity });
74+
client.user.setStatus(status);
75+
} catch (error) {
76+
console.log("Invalid status")
77+
console.error(error)
78+
}
79+
break
80+
}
81+
case 'dir': case 'ls': {
82+
console.log(`\n Volume in drive ${drive} is ${drvlabel}`)
83+
console.log(` Volume Serial Number is 298A-E8CC`)
84+
console.log(` Directory of ${drive}:${dir.join("")}\n`)
85+
switch (drive) {
86+
case 'S': {
87+
if (depth == 0) {
88+
drvS.rootdirs.forEach(async i => {
89+
if (i.name == undefined) await i.fetch()
90+
console.log(i.name.padEnd(20) + ` (${i.id})`.padEnd(23) + "<DIR> ")
91+
})
92+
} else {
93+
drvS.subdirs = client.guilds.cache.get(`${curServer}`)
94+
drvS.subdirs.channels.cache.forEach(c => console.log(`${c.id.padEnd(19)} ${c.name.substring(0, 15).padEnd(16)} CHN`))
95+
}
96+
}
97+
break
98+
case 'C': {
99+
if (depth == 0) {
100+
drvC.rootdirs.forEach(i => {
101+
console.log(i.padEnd(20) + "<DIR> ")
102+
})
103+
} else {
104+
drvC.subdirs = fs.readdirSync(`${__dirname}/../commands/${curC}`);
105+
drvC.subdirs.forEach(c => console.log(`${c.substring(0, 15).padEnd(16)} FILE`))
106+
}
107+
}
108+
}
109+
break
110+
}
111+
case 'cd': case 'cd..': {
112+
let newDir = line.split(" ").slice(1).join(" ")
113+
if (newDir === ".." || line.split(" ")[0] === "cd..") {
114+
if (depth == 0) break
115+
depth--
116+
dir.pop()
117+
curServer = null
118+
curC = null
119+
break
120+
}
121+
switch (drive) {
122+
case 'S': {
123+
if (drvS.rootdirs.find(i => i.name === newDir) || drvS.rootdirs.find(i => i.id === newDir)) {
124+
depth++
125+
if (!isNaN(+newDir)) {
126+
let server = client.guilds.cache.find(g => g.id === newDir)
127+
curServer = server.id
128+
dir.push(server.name)
129+
}
130+
else if (isNaN(+newDir)) {
131+
let server = client.guilds.cache.find(g => g.name === newDir)
132+
curServer = server.id
133+
dir.push(server.name)
134+
}
135+
} else {
136+
console.log("Invalid directory")
137+
}
138+
break
139+
}
140+
case 'C': {
141+
if (drvC.rootdirs.find(i => i === newDir)) {
142+
dir.push(newDir)
143+
depth++
144+
curC = newDir
145+
} else {
146+
console.log("Invalid directory")
147+
}
148+
}
149+
}
150+
break
151+
}
152+
case 'cls': case 'clear': {
153+
console.clear();
154+
break
155+
}
156+
case 'send': {
157+
client.channels.cache.get(line.split(" ")[1]).send(line.split(" ").slice(2).join(" "))
158+
break
159+
}
160+
case 'echo': {
161+
console.log(line.split(" ").slice(1).join(""))
162+
break
163+
}
164+
case 'tail': {
165+
if (drive === "C" || curServer == null) { console.log("Please, enter a server in the 'S' drive"); break }
166+
let channel = line.split(" ")[1]
167+
if (!channel) { console.log('A channel id is required'); break }
168+
let MessageAmount = line.split(" ")[2] || 10
169+
let Messages = await client.guilds.cache.get(curServer).channels.cache.get(channel).messages.fetch({ limit: MessageAmount })
170+
Messages.forEach(e => {
171+
console.log(`${e.id.padEnd(20)}${e.author.tag.padEnd(13)}${e.content}`)
172+
})
173+
break
174+
}
175+
case 'type': case 'cat': {
176+
let file = line.split(" ").slice(1).join(" ")
177+
if (!file) { console.log('Required parameter missing'); break }
178+
cmd.setPrompt(" ")
179+
switch (drive) {
180+
case 'S': {
181+
console.log('General failure reading drive S:')
182+
console.log('Abort, Retry, Fail?a')
183+
break
184+
}
185+
case 'C':
186+
fs.readFile(`${__dirname}/../commands/${curC}/${file.toLowerCase()}`, 'utf8', (err, data) => {
187+
if (err) { console.log(`File not found - ${file.toLowerCase()}`); return }
188+
console.log(data)
189+
})
190+
}
191+
console.log()
192+
break
193+
}
194+
case "reload": {
195+
switch (drive) {
196+
case "S": {
197+
console.log("Reloading servers, Please wait...")
198+
await client.guilds.fetch()
199+
drvS.rootdirs = client.guilds.cache
200+
console.log("Reload finished")
201+
break
202+
}
203+
case "C": {
204+
const { ReloadJsFile } = require('./GetJSFile.js');
205+
console.log("Reloading commands, Please wait...");
206+
await ReloadJsFile(client);
207+
console.log("Reload finished.");
208+
break
209+
}
210+
};
211+
break
212+
}
213+
case "deploy": {
214+
const { send } = require("../deploy-commands.js");
215+
const { beta } = require("../config.json");
216+
217+
let all = []
218+
client.commands.forEach(e => { if (!beta && e.name !== "test" || beta) all.push(e.data.toJSON()) })
219+
client.contextMenu.forEach(e => all.push(e.data.toJSON()))
220+
221+
send(all, client.token, client.user.id);
222+
break;
223+
}
224+
case 'c:': case 'C:': {
225+
drive = 'C'
226+
drvlabel = 'COMMANDS'
227+
depth = 0
228+
dir = ["\\"]
229+
break
230+
}
231+
case 'S:': case 's:': {
232+
drive = 'S'
233+
drvlabel = 'SERVERS'
234+
depth = 0
235+
dir = ["\\"]
236+
break
237+
}
238+
case '': break
239+
default: console.log("Bad command or file name")
240+
};
241+
cmd.setPrompt(`${drive}:${dir.join("")}>`)
242+
cmd.prompt();
243+
})
244+
cmd.on("SIGINT", () => {
245+
cmd.prompt()
246+
});
247+
};
248+
249+
module.exports = { ProcessDOS }

0 commit comments

Comments
 (0)