Skip to content
This repository was archived by the owner on May 31, 2021. It is now read-only.

Commit e333bf9

Browse files
committed
this makes me wanna cry
1 parent 7d2d8c0 commit e333bf9

25 files changed

+601
-53
lines changed

Diff for: README.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
![GitHub](https://img.shields.io/github/license/andyiscool5463/ricebot)
44
![David](https://img.shields.io/david/andyiscool5463/ricebot)
5+
[![Build Status](https://travis-ci.com/AndyIsCool5463/rice-bot.svg?token=Syh8JoqVaQwAWirquxET&branch=master)](https://travis-ci.com/AndyIsCool5463/rice-bot)
6+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/7371b0fbdaea484aa52dbf8d9caa470c)](https://www.codacy.com?utm_source=github.com&utm_medium=referral&utm_content=AndyIsCool5463/rice-bot&utm_campaign=Badge_Grade)
7+
![Discord](https://img.shields.io/discord/285078632794161153)
8+
![Uptime Robot status](https://img.shields.io/uptimerobot/status/m784818736-b5ee05189c50f2f367cebf78)
9+
![Uptime Robot ratio (30 days)](https://img.shields.io/uptimerobot/ratio/m784818736-b5ee05189c50f2f367cebf78)
510

6-
Fast, clean, countless features your server made in [discord.js](DiscordJSLink) and [Typescript](typescriptlink).
11+
Fast, clean, countless features your server made in [discord.js](https://discord.js.org/) and [Typescript](https://www.typescriptlang.org/).
712
Invite me _T.B.A_.
813

914
# Features
@@ -30,13 +35,7 @@ T.B.A
3035

3136
I would like to thank these people for creating these awesome libaries / sites. I wouldn't have been able to make this bot if it wern't for these good folks.
3237

33-
- Hydrabolt - Creator of [Discord.JS](discordjslink) - [Github](hydraboltgithub)
34-
- People at Dirigeants - Creators of [Klasa](klasa) - [Github](dirigeantsgithub) (Huge inspiration)
38+
- Hydrabolt - Creator of [Discord.JS](https://discord.js.org/) - [Github](https://github.com/hydrabolt)
39+
- People at Dirigeants - Creators of [Klasa](https://github.com/dirigeants/klasa) - [Github](https://github.com/dirigeants) (Huge inspiration)
3540
- IRL Friends
3641
- You, for reading this :)
37-
38-
[discordjslink]: https://discord.js.org/
39-
[typescriptlink]: https://www.typescriptlang.org/
40-
[klasa]: https://github.com/dirigeants/klasa
41-
[hydraboltgithub]: https://github.com/hydrabolt
42-
[dirigeantsgithub]: https://github.com/dirigeants

Diff for: modules.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ declare namespace NodeJS {
44
MONGO_URL: string;
55
}
66
}
7+
declare module "simple-youtube-api";

Diff for: package.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@
99
"test": "jest",
1010
"start": "env NODE_ENV=production nodemon index.ts"
1111
},
12+
"engines": {
13+
"node": "13.10.1"
14+
},
1215
"dependencies": {
1316
"@babel/preset-typescript": "^7.9.0",
1417
"@types/dotenv": "^8.2.0",
1518
"@types/mongodb": "^3.5.8",
1619
"@types/mongoose": "^5.7.12",
1720
"@types/node": "^13.11.1",
21+
"cachegoose": "^8.0.0",
1822
"chalk": "^4.0.0",
1923
"discord.js": "^12.1.1",
2024
"dotenv": "^8.2.0",
@@ -25,8 +29,10 @@
2529
"mongoose": "^5.9.10",
2630
"nodemon": "^2.0.3",
2731
"promise-each": "^2.2.0",
32+
"simple-youtube-api": "^5.2.1",
2833
"ts-node": "^8.8.2",
29-
"typescript": "^3.8.3"
34+
"typescript": "^3.8.3",
35+
"ytdl-core-discord": "^1.2.0"
3036
},
3137
"devDependencies": {
3238
"@babel/core": "^7.9.0",

Diff for: src/Monitors/CommandMonitor.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ class CommandMonitor extends Monitor {
3636
const GS = await GSController.ensureGuild(msg.guild);
3737
let prefix: string | undefined;
3838
// i dont know how resource intensive this shit is but ye better than regex 🙃
39-
for (const thisPrefix of GS.config.prefix) {
40-
if (msg.content.startsWith(<string>thisPrefix))
41-
prefix = <string>thisPrefix;
39+
for (const thisPrefix of <string[]>GS.config.prefix) {
40+
if (msg.content.startsWith(thisPrefix)) prefix = thisPrefix;
4241
}
4342

4443
if (!prefix) return;
@@ -49,11 +48,10 @@ class CommandMonitor extends Monitor {
4948
args.reverse();
5049
// HACK: Change this shit asap
5150
const cmd =
52-
client.CommandStore.get(command[0].toLowerCase()) ||
53-
client.CommandStore.storeAlias.get(command[0].toLowerCase());
51+
client.CommandStore.storeAlias.get(command[0].toLowerCase()) ||
52+
client.CommandStore.get(command[0].toLowerCase());
5453
if (!cmd) return;
5554
const bruh = checkArgs(msg, cmd, args);
56-
console.log(cmd.usage.length);
5755
if (isEmpty(bruh) && cmd.usage.length >= 1) return;
5856
/**
5957
* <> | required argument
@@ -75,7 +73,11 @@ class CommandMonitor extends Monitor {
7573
return;
7674
}
7775
if (!cmd.runIn.includes(msg.channel.type)) return;
78-
cmd.run(msg, [bruh], client);
76+
cmd.run(msg, [bruh], client).catch((e: Error) => {
77+
msg.channel.send(
78+
`There was an error executing your command. \n \`\`\`${e.message}\`\`\``
79+
);
80+
});
7981
return;
8082
}
8183
}

Diff for: src/Monitors/GuildMemberJoin.ts

Whitespace-only changes.

Diff for: src/Music/IDEA.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
- File: IDEA.md
2+
- Project: ricebot
3+
- File Created: Sunday, 26th April 2020 4:15:14 pm
4+
- Author: andyl5463 ([email protected])
5+
- ***
6+
- Last Modified: Sunday, 26th April 2020 4:15:17 pm
7+
- Modified By: andyl5463 ([email protected]>)
8+
- ***
9+
- Copyright 2020 - 2020 Longshot Development, Longshot Development
10+
11+
# IDEA Music
12+
13+
> Permission Level 4 (T.B.A).
14+
15+
## Rule Set
16+
17+
1. Max 10 in queue for memory reasons. might experiement with higher ups.
18+
2. Queue is in memory
19+
3. Queue will have a store with `<guildID, Metadata>`
20+
21+
## MetaData
22+
23+
```
24+
{
25+
song: <Song Metadata>,
26+
requestedBy: <User Snowflake>,
27+
timeRequested: <Date>
28+
}
29+
```
30+
31+
## Commands
32+
33+
- `play <URL | big string (max 100 chars)>` - Gets Video via `URL` or `Search`.
34+
35+
- `pause` - Pauses playback.
36+
37+
- `resume` - Resumes playback.
38+
39+
- `stop` - Stops Playback.
40+
41+
- `queue` - Displays Queue with Embed.
42+
43+
- `np | nowplaying` - Displays Now Playing in Native Embed (No Pagination)
44+
45+
## Backend
46+
47+
i have no fuckign clue

Diff for: src/Rice.ts

+26-8
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,23 @@ import mongoose from "mongoose";
2020
import EventStore from "./core/EventStore";
2121
import * as fsn from "fs-nextra";
2222
import Event from "./core/Event";
23+
import MusicStore from "./core/MusicStore";
24+
import InhibitorStore from "./core/InhibitorStore";
25+
/**
26+
* My Ideas Upcoming After #3 Commit.
27+
*
28+
* Fuck all the methods in this class.
29+
* just do everything in the constructor.
30+
*
31+
*
32+
*/
2333
class Rice extends Client {
2434
public MonitorStore: MonitorStore = new MonitorStore(this);
2535
public CommandStore: CommandStore = new CommandStore();
2636
public EventStore: EventStore = new EventStore(this);
37+
public MusicStore: MusicStore = new MusicStore();
38+
public InhibitorStore: InhibitorStore = new InhibitorStore();
39+
2740
public constructor() {
2841
super();
2942
// Enmap
@@ -42,6 +55,9 @@ class Rice extends Client {
4255
this.on("guildDelete", (guild) =>
4356
this.EventStore.get("guildDelete")!.run(this, [guild])
4457
);
58+
this.on("guildMemberAdd", (guildMember) =>
59+
this.EventStore.get("guildMemberAdd")!.run(this, [guildMember])
60+
);
4561
this.on("warn", (warn) => console.log(warn));
4662

4763
// Setup Commands
@@ -57,8 +73,7 @@ class Rice extends Client {
5773
}
5874
public async connectToMongo(): Promise<void> {
5975
mongoose
60-
// @ts-ignore
61-
.connect(process.env.MONGO_URL, {
76+
.connect(<string>process.env.MONGO_URL, {
6277
useUnifiedTopology: true,
6378
useNewUrlParser: true,
6479
})
@@ -124,9 +139,12 @@ class Rice extends Client {
124139
}
125140
}
126141
export default Rice;
127-
// process.on("uncaughtException", (error?: Error) => {
128-
// const errorMsg = error.stack.replace(new RegExp(`${__dirname}/`, "g"), "./");
129-
// console.log("Uncaught Exception: " + errorMsg);
130-
// console.log(error);
131-
// process.exit(1);
132-
// });
142+
process.on("uncaughtException", (error?: Error) => {
143+
const errorMsg = error!.stack!.replace(
144+
new RegExp(`${__dirname}/`, "g"),
145+
"./"
146+
);
147+
console.log("Uncaught Exception: " + errorMsg);
148+
console.log(error);
149+
process.exit(1);
150+
});

Diff for: src/commands/Misc/HelloWorld.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
import { Message } from "discord.js";
1414
import Command from "../../core/Command";
1515
import Rice from "../../Rice";
16+
import playMusic from "../../util/Music/playMusic";
1617
module.exports = class extends Command {
1718
constructor() {
1819
super({
1920
name: "true",
20-
enable: false,
21+
enable: true,
2122
cooldown: 0,
2223
runIn: ["text"],
2324
permLevel: 0,
@@ -27,6 +28,6 @@ module.exports = class extends Command {
2728
});
2829
}
2930
public async run(msg: Message, [..._args], _client: Rice): Promise<void> {
30-
msg.channel.send(`Hello World ${_args.map((c) => c)}`);
31+
playMusic(_client, msg);
3132
}
3233
};

Diff for: src/commands/System/config.ts

+33-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Command from "../../core/Command";
22
import { Message } from "discord.js";
3-
3+
import GSController from "../../core/api/GuildSettings.controller";
4+
//import { IGuildSettings } from "../../core/api/IGuildSettings";
45
/*
56
* File: config.ts
67
* Project: ricebot
@@ -17,16 +18,43 @@ module.exports = class extends Command {
1718
super({
1819
name: "config",
1920
enable: true,
20-
aliases: [""],
21+
aliases: ["conf", "cfg"],
2122
cooldown: 0,
2223
permLevel: 6,
2324
runIn: ["text"],
2425
usage: "<set|get|reset|list|remove> [key:string] [value:string]",
2526
usageDelimiter: " ",
2627
});
2728
}
28-
async run(msg: Message, [{ ...required }]): Promise<void> {
29-
msg.channel.send("im alive");
30-
console.log(required);
29+
async run(msg: Message, [{ ...args }]): Promise<Message> {
30+
const { required, key, value } = args;
31+
GSController.testo(msg.guild!.id).then(() => {
32+
console.log("did iut");
33+
});
34+
if (!key || !value) return msg.channel.send("No Key / Value Input.");
35+
36+
switch (key) {
37+
case "prefix":
38+
// GSController.changeConfig(msg.guild!, required, key, value)
39+
// .then((cfg: IGuildSettings) => {
40+
// msg.channel.send(`Changed prefix to: ${cfg.config.prefix}`);
41+
// })
42+
// .catch((e) => {
43+
// console.log(e);
44+
// });
45+
46+
break;
47+
case "xp":
48+
break;
49+
case "nsfw":
50+
break;
51+
case "joinRole":
52+
break;
53+
case "EventJoin":
54+
break;
55+
default:
56+
return msg.channel.send("wtf");
57+
}
58+
return msg.channel.send(`${required}-${key}-${value}`);
3159
}
3260
};

Diff for: src/core/Command.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ class Command {
5151
this.usageDelimiter = usageDelimiter;
5252
}
5353

54-
public run(_message: Message, [..._args], _client: Rice): void {}
54+
public async run(
55+
_message: Message,
56+
[..._args],
57+
_client: Rice
58+
): Promise<Message | void> {}
5559
get getRunIn() {
5660
return this.runIn;
5761
}

Diff for: src/core/IQueue.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Snowflake } from "discord.js";
2+
3+
/*
4+
* File: IQueue.ts
5+
* Project: ricebot
6+
* File Created: Sunday, 26th April 2020 4:30:12 pm
7+
* Author: andyl5463 ([email protected])
8+
* -----
9+
* Last Modified: Sunday, 26th April 2020 4:30:12 pm
10+
* Modified By: andyl5463 ([email protected]>)
11+
* -----
12+
* Copyright 2020 - 2020 Longshot Development, Longshot Development
13+
*/
14+
export default interface Queue {
15+
song: any;
16+
requestedBy: Snowflake;
17+
timeRequested: Date;
18+
}

Diff for: src/core/Inhibitor.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* File: Inhibitor.ts
3+
* Project: ricebot
4+
* File Created: Tuesday, 28th April 2020 3:51:09 pm
5+
* Author: AndyIsCool5463 ([email protected])
6+
* -----
7+
* Last Modified: Tuesday, 28th April 2020 3:51:09 pm
8+
* Modified By: AndyIsCool5463 ([email protected]>)
9+
* -----
10+
* Copyright 2020 - 2020 Longshot Development, Longshot Development
11+
*/
12+
export default class Inhibitor {}

Diff for: src/core/InhibitorStore.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* File: InhibitorStore.ts
3+
* Project: ricebot
4+
* File Created: Tuesday, 28th April 2020 3:49:56 pm
5+
* Author: AndyIsCool5463 ([email protected])
6+
* -----
7+
* Last Modified: Tuesday, 28th April 2020 3:49:56 pm
8+
* Modified By: AndyIsCool5463 ([email protected]>)
9+
* -----
10+
* Copyright 2020 - 2020 Longshot Development, Longshot Development
11+
*/
12+
13+
import Store from "./Store";
14+
import Inhibitor from "./Inhibitor";
15+
import { Collection } from "discord.js";
16+
17+
export default class InhibitorStore extends Store<string, Inhibitor> {
18+
public store: Collection<string, Inhibitor> = super.getStore;
19+
constructor() {
20+
super();
21+
}
22+
}

Diff for: src/core/Monitor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ class Monitor {
3131
this.ignoreOthers = ignoreOthers;
3232
this.ignoreSelf = ignoreSelf;
3333
}
34-
public run(_msg: Message, _client: Rice): void {}
34+
public async run(_msg: Message, _client: Rice): Promise<Message | void> {}
3535
}
3636
export default Monitor;

Diff for: src/core/MonitorStore.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import Monitor from "./Monitor";
1414
import Store from "./Store";
15+
import { Message } from "discord.js";
1516
/**
1617
* This class handles all the monitors which are functions that only execute on `Discord.Client#onMessage`
1718
*/
@@ -23,15 +24,19 @@ class MonitorStore extends Store<string, Monitor> {
2324
super();
2425
this.client = client;
2526
}
26-
run(msg: any) {
27+
run(msg: Message) {
2728
for (const monit of super.getStore.values()) {
2829
if (
2930
monit.enabled &&
3031
!(monit.ignoreBots && msg.author.bot) &&
3132
!(monit.ignoreSelf && this.client.user === msg.author) &&
3233
!(monit.ignoreOthers && this.client.user !== msg.author)
3334
) {
34-
monit.run(msg, this.client);
35+
monit.run(msg, this.client).catch((Exception: Error) => {
36+
msg.channel.send(
37+
`There was an error executing your command. \n \`\`\`${Exception.message}\`\`\``
38+
);
39+
});
3540
}
3641
}
3742
}

0 commit comments

Comments
 (0)