Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sudhan playz v5 #5

Merged
merged 94 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
82d3f45
Updated choices method (#843)
brianferri May 19, 2022
3fd8a26
fix(deps): update dependency discord-api-types to v0.33.0 (#803)
renovate[bot] May 20, 2022
5f18d94
fix(deps): update dependency discord-api-types to v0.33.1 (#848)
renovate[bot] May 30, 2022
47e1bb6
Change errorEmbed to embed msg to remove double ❌ (#853)
Itsnotaka Jun 2, 2022
20e06aa
fix: DOuble X in lyrics and loop command
DevAmiyo Jun 3, 2022
2794ecb
track duration and author in search cmd [v5] (#863)
LewdHuTao Jun 6, 2022
11011bd
autoplay [v5] (#867)
LewdHuTao Jun 7, 2022
d2f505a
Avoid repeating sequence of tracks (#868)
Neko-Life Jun 9, 2022
a3fc74d
Create ping.js (#860)
brianferri Jun 9, 2022
a587e47
harder, faster, better, stronger (#869)
Neko-Life Jun 9, 2022
5af6a3e
Include tracking on search command (#870)
Neko-Life Jun 9, 2022
7290b25
Bye old docs 👋
DarrenOfficial Jun 9, 2022
36bad65
Update invite.js (#874)
gspxrk Jun 10, 2022
898b44b
Ignore empty folder (#873)
Neko-Life Jun 10, 2022
172750b
feat: Dashboard UI - NextJS
SudhanPlayz Jun 10, 2022
4218fa8
`Shortening` (#871)
brianferri Jun 10, 2022
f440b3f
Update README.md
SudhanPlayz Jun 10, 2022
8d92e49
fix(deps): update dependency discord-api-types to v0.33.5 (#852)
renovate[bot] Jun 10, 2022
37a220a
fix(deps): update dependency @discordjs/builders to ^0.15.0 (#861)
renovate[bot] Jun 10, 2022
a26cf83
fix(deps): update dependency pretty-ms to v8 (#864)
renovate[bot] Jun 10, 2022
ba00fbc
fix(deps): update dependency @discordjs/rest to ^0.5.0 (#862)
renovate[bot] Jun 10, 2022
b2b8397
fix(deps): pin dependencies (#876)
renovate[bot] Jun 10, 2022
39a162b
Create stale.yml
SudhanPlayz Jun 10, 2022
0e35805
Delete prettify.yml.no
SudhanPlayz Jun 10, 2022
90d5394
Missing module.exports
DevAmiyo Jun 10, 2022
f0a5af8
Merge pull request #878 from DevAmiyo/v5
Neko-Life Jun 10, 2022
14573ad
Update package.json (#880)
brianferri Jun 10, 2022
5fea135
fix (#882) (#883)
brianferri Jun 11, 2022
1d644ce
Add Dockerfile
sprucecellodev125 Jun 11, 2022
94359c2
Global .replace() (#889)
DevAmiyo Jun 12, 2022
2f57ee5
fix `client.error` (#885) (#886)
brianferri Jun 12, 2022
f807137
🐷🐝🔪🔪🦧
DarrenOfficial Jun 12, 2022
17bd23a
Fix lyrics.js (#890)
JotaroKujo0525 Jun 12, 2022
b4e0203
Update 247.js (#891)
brianferri Jun 13, 2022
dcb0c88
Use scopes from config.js (#892)
DevAmiyo Jun 13, 2022
3b5b59f
24/7 refactoring; syntax; bugs (#893)
brianferri Jun 13, 2022
b65d83f
chore(deps): update node.js to v18 (#884)
renovate[bot] Jun 13, 2022
35e9d3d
v5 configured
Saud-97 Jun 13, 2022
8cf802b
fixed deployment
Saud-97 Jun 13, 2022
a7307ce
changed ports of website
Saud-97 Jun 13, 2022
bfd1b1f
changed colors of actions
Saud-97 Jun 14, 2022
a63eb0c
a
Saud-97 Jun 14, 2022
e87af67
fixed action
Saud-97 Jun 14, 2022
cdf05a1
add: mui emojis
SudhanPlayz Jun 14, 2022
464c02b
add: routes
SudhanPlayz Jun 14, 2022
5601511
Update README.md
SudhanPlayz Jun 14, 2022
5c31d70
fix: bot disconnecting if the queue is empty and 247 command is run
DevAmiyo Jun 15, 2022
3b5a7d7
Merge pull request #899 from DevAmiyo/patch-1
Neko-Life Jun 16, 2022
a94a995
Update index.js
JotaroKujo0525 Jun 16, 2022
5c96f16
Update index.js (#902)
JotaroKujo0525 Jun 16, 2022
1c5b757
Update package.json (#904)
DevAmiyo Jun 16, 2022
184b05c
Update config.js
Saud-97 Jun 16, 2022
72f7e37
Merge branch 'SudhanPlayz:v5' into v5
Saud-97 Jun 16, 2022
bee04ac
enable 247 by default
Saud-97 Jun 16, 2022
ea4b653
Merge branch 'v5' of https://github.com/Saud-97/Discord-MusicBot into v5
Saud-97 Jun 16, 2022
ee68465
test fix for disconnect terminate player
Saud-97 Jun 16, 2022
f724bfe
fix for player disconnection when 247
Saud-97 Jun 16, 2022
f6447b8
add /stop command
Saud-97 Jun 16, 2022
662cc77
changed player actions to stop and loop
Saud-97 Jun 16, 2022
36a84d1
bug in string fixed
Saud-97 Jun 16, 2022
4209f27
Merge pull request #908 from Saud-97/v5
sprucecellodev125 Jun 17, 2022
aa904f2
Revert "V5"
sprucecellodev125 Jun 17, 2022
56e35b1
Merge pull request #909 from SudhanPlayz/revert-908-v5
sprucecellodev125 Jun 17, 2022
000602a
fix queue.js (#913)
cobianic Jun 18, 2022
9b26327
feat: Flip flop switch for resume/pause events (the continuation) (#917)
brianferri Jun 18, 2022
5cefce8
Updated Dashboard UI (#916)
popQA17 Jun 20, 2022
3a26dbd
chore(deps): update dependency @types/react to v18.0.14 (#901)
renovate[bot] Jun 20, 2022
51d061e
fix(deps): update dependency discord-api-types to v0.34.0 (#894)
renovate[bot] Jun 20, 2022
d8ac8a3
chore(deps): update dependency eslint to v8.18.0 (#915)
renovate[bot] Jun 20, 2022
b54329d
chore(deps): update dependency typescript to v4.7.4 (#914)
renovate[bot] Jun 20, 2022
7065f2b
fix(deps): update react monorepo to v18.2.0 (#896)
renovate[bot] Jun 20, 2022
9054f35
add: types for statsCard
SudhanPlayz Jun 20, 2022
f3a6e51
/api/data
SudhanPlayz Jun 20, 2022
bca7da6
imagine a commit
SudhanPlayz Jun 20, 2022
680cac1
new route
SudhanPlayz Jun 20, 2022
2fb0a85
feat: Dashboard and Auth
SudhanPlayz Jun 20, 2022
2b62197
some bugged code
SudhanPlayz Jun 20, 2022
e25502f
new build
SudhanPlayz Jun 20, 2022
b2bb9c6
fix: deprecated default properties (#927)
brianferri Jun 20, 2022
021ea7a
Update package.json
SudhanPlayz Jun 22, 2022
8e22354
V5 (#929)
brianferri Jun 22, 2022
3e1eeb1
Stateful controller overhaul (#935)
Saud-97 Jun 22, 2022
f5ae5e1
lavalink
DarrenOfficial Jun 24, 2022
083bbe3
fix(deps): update dependency discord-api-types to v0.35.0 (#939)
renovate[bot] Jun 25, 2022
02e17de
Clean command to purge bot messages from channel. (#936)
Saud-97 Jun 25, 2022
4b207b5
Code reformatted, reordered entries, optimized imports (#946)
Saud-97 Jun 26, 2022
d6d7fcb
Rebased
Saud-97 Jun 26, 2022
72bdc55
Merge branch 'SudhanPlayz:v5' into v5
JotaroKujo0525 Jun 29, 2022
adf0d91
Update replit.nix
JotaroKujo0525 Jun 29, 2022
e336dd3
Update .replit
JotaroKujo0525 Jun 29, 2022
765e33d
Update kickstartReplit.sh
JotaroKujo0525 Jun 29, 2022
467166d
Merge pull request #956 from JotaroKujo0525/v5
sprucecellodev125 Jun 29, 2022
1bbef53
Merge pull request #934 from Saud-97/fix_897
Neko-Life Jun 29, 2022
1c3b144
Merge branch 'v5' of https://github.com/SudhanPlayz/Discord-MusicBot …
NonRoute Jun 30, 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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Please move lines that apply to you out of the comment:
- This PR **only** includes non-code changes, like changes to documentation, README, etc.
-->


# Important.

- Write in camelCase, not snake_case.
- Do not push to master/main without testing your changes first, make a branch
if you have to.
6 changes: 4 additions & 2 deletions .github/SUPPORT.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Seeking support?

We only use this issue tracker for bug reports and feature request. We are not able to provide general support or answer questions in the form of GitHub issues.
We only use this issue tracker for bug reports and feature request. We are not able to provide general support or answer
questions in the form of GitHub issues.

For general questions about the Music Bot and use please use the dedicated support channels in our Discord server: https://discord.gg/sbySMS7m3v
For general questions about the Music Bot and use please use the dedicated support channels in our Discord
server: https://discord.gg/sbySMS7m3v

Any issues that don't directly involve a bug or a feature request will likely be closed and redirected.
11 changes: 11 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Configuration for probot-stale - https://github.com/probot/stale
daysUntilStale: 60

daysUntilClose: 5
exemptLabels:
- Soon

markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
51 changes: 0 additions & 51 deletions .github/workflows/prettify.yml.no

This file was deleted.

4 changes: 2 additions & 2 deletions .replit
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
run = "npx node index.js"
language = "NodeJS"
run = "node index.js"
language = "Nix"
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage], versi
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org

[version]: http://contributor-covenant.org/version/1/4/
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:18-alpine

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

CMD [ "npm", "run", "deploy" ]

CMD [ "node", "index.js" ]
3 changes: 2 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
- The bot-code should be used for **private hosting** and **personal usage** only.
- Using the code for public usage is **not allowed**.

> **Note:** if you are found to be violating any of the above stated rule you might be asked to takedown your bot, happy listening!! Incase of any doubts in the license contact owner.
> **Note:** if you are found to be violating any of the above stated rule you might be asked to takedown your bot, happy
> listening!! Incase of any doubts in the license contact owner.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

- [Node.js 16+](https://nodejs.org/en/download/)
- [Lavalink Server](https://code.darrennathanael.com/how-to-lavalink)
- You'll need to run `npm run deploy` or `yarn deploy`. to initialized the slash commands. _You can do this on your pc locally_
- You'll need to run `npm run deploy` or `yarn deploy`. to initialized the slash commands. _You can do this on your pc
locally_

> NOTE: Lavalink is needed for music functionality. You need to have a working Lavalink server to make the bot work.

## 📝 | Important Note if you're Switching from v4 to v5

1. Download and configure v5 in a seperate folder.
2. Kick your bot out of your server.
3. Reinvite the Bot with the right scopes. [Example Invite URL (Change CLIENT_ID)](https://discord.com/oauth2/authorize?client_id=CLIENT_ID&permissions=277083450689&scope=bot%20applications.commands)
3. Reinvite the Bot with the right
scopes. [Example Invite URL (Change CLIENT_ID)](https://discord.com/oauth2/authorize?client_id=CLIENT_ID&permissions=277083450689&scope=bot%20applications.commands)
4. Run `npm run deploy` or `yarn deploy` to initialize the slash commands. _You can do this on your pc locally_

## 📝 | Tutorial
Expand All @@ -32,12 +34,19 @@ Soon
[![Deploy to heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/SudhanPlayz/Discord-MusicBot/tree/v5)
[![Open in Gitpod](https://camo.githubusercontent.com/76e60919474807718793857d8eb615e7a50b18b04050577e5a35c19421f260a3/68747470733a2f2f676974706f642e696f2f627574746f6e2f6f70656e2d696e2d676974706f642e737667)](https://gitpod.io/#https://github.com/SudhanPlayz/Discord-MusicBot/tree/v5)

## ✨ Contributors
## ✨ | Contributors

Contributions are always welcomed :D Make sure to follow [Contributing.md](/CONTRIBUTING.md)

<a href="https://github.com/SudhanPlayz/Discord-MusicBot/graphs/contributors">
<img src="https://contributors-img.web.app/image?repo=SudhanPlayz/Discord-MusicBot" />
</a>

Made with 💖 and JavaScript!
## 🌟 | Made with

- [Discord.js](https://discord.js.org/)
- [Lavalink](https://github.com/freyacodes/Lavalink) with erela.js
- [Express](https://expressjs.com/)
- [Next JS](https://nextjs.org/)
- [Next UI](https://nextui.org)
- [Material UI Icons](https://mui.com/material-ui/material-icons/)
9 changes: 0 additions & 9 deletions api/home/dashboard.js

This file was deleted.

152 changes: 108 additions & 44 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,119 @@ const express = require("express");
const fs = require("fs");
const { EventEmitter } = require("events");
const { join } = require("path");
const session = require("express-session");
const DiscordStrategy = require("passport-discord").Strategy;
const passport = require("passport");
const getConfig = require("../util/getConfig");
const DiscordMusicBot = require("../lib/DiscordMusicBot");
const Auth = require("./middlewares/auth");

class Server extends EventEmitter {
/**
* Create server ;-;
* @param {DiscordMusicBot} client
*/
constructor(client) {
super();
getConfig()
.then((conf) => {
this.config = conf;
this.listen();
})
.catch((err) => {
throw Error(err);
});

this.app = express();
passport.serializeUser(function (user, done) {
done(null, user);
});

//API
fs.readdir(join(__dirname, "routes"), (err, files) => {
if (err) return console.log(err);
files.forEach((file) => {
this.app.use(
"/api/" + file.split(".")[0],
require(join(__dirname, "routes") + "/" + file)
);
});
});
fs.readdir(join(__dirname, "home"), (err, files) => {
if (err) return console.log(err);
files.forEach((file) => {
this.app.use(
"/" + file.split(".")[0],
require(join(__dirname, "home") + "/" + file)
);
});
});
this.app.use(express.static(join(__dirname, "..", "public")));
// this.app.use((req, res) => {
// res.sendFile(join(__dirname, "..", "dashboard", "build", "index.html"));
// });
}
passport.deserializeUser(function (obj, done) {
done(null, obj);
});

listen() {
this.app.listen(this.config.port);
}
class Server extends EventEmitter {
/**
* Create server ;-;
* @param {DiscordMusicBot} client
*/
constructor(client) {
super();
getConfig()
.then((conf) => {
this.config = conf;
this.listen();
})
.catch((err) => {
throw Error(err);
});

this.app = express();

//API
fs.readdir(join(__dirname, "routes"), (err, files) => {
if (err) {
return console.log(err);
}
files.forEach((file) => {
this.app.use(
"/api/" + file.split(".")[0],
require(join(__dirname, "routes") + "/" + file),
);
});
});

this.app.use(express.static(join(__dirname, "..", "public")));

//Static Routes
let dist = join(__dirname, "..", "dashboard", "out")

this.app.use(express.static(dist));
this.app.get("/login", (_req, res) => {
res.sendFile(join(dist, "login.html"));
res.redirect("/api/callback")
});
this.app.get("/logout", (req, res) => {
if (req.user) {
req.logout();
}
res.sendFile(join(dist, "logout.html"));
});
this.app.get("/dashboard", Auth, (_req, res) => {
res.sendFile(join(dist, "dashboard.html"));
});
this.app.get("/servers", Auth, (_req, res) => {
res.sendFile(join(dist, "servers.html"));
});

// Session and Passport
this.app.use(session({
resave: true,
saveUninitialized: true,
secret: client.config.cookieSecret,
cookie: {
secure: client.config.website.startsWith("https://"),
sameSite: true,
},
}));
this.app.use(passport.initialize());
this.app.use(passport.session());

passport.use(
new DiscordStrategy(
{
clientID: client.config.clientId,
clientSecret: client.config.clientSecret,
callbackURL: client.config.website + "/api/callback",
scope: client.config.scopes.filter(a => !a.startsWith("app")).join(" "),
},
function (accessToken, refreshToken, profile, done) {
process.nextTick(function () {
return done(null, profile);
});
},
),
);

this.app.get(
"/api/callback",
passport.authenticate("discord", {
failureRedirect: "/",
session: true,
}),
function (req, res) {
res.redirect("/dashboard");
},
);
}

listen() {
this.app.listen(this.config.port);
}
}

module.exports = Server;
17 changes: 17 additions & 0 deletions api/middlewares/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @param {import("express").Request} req
* @param {import("express").Response} res
* @param {import("express").NextFunction} next
* @returns {Promise<void>}
*/

const Auth = (req, res, next) => {
console.log("Middleware", req.user)
if (!req.user) {
return res.redirect("/login");
} else {
next();
}
};

module.exports = Auth;
16 changes: 16 additions & 0 deletions api/routes/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { Router } = require("express");
const api = Router();
const client = require("../../");
const Auth = require("../middlewares/auth");

api.get("/", Auth, (req, res) => {
let data = {
commandsRan: client.commandsRan,
users: client.users.cache.size,
servers: client.guilds.cache.size,
songsPlayed: client.songsPlayed,
}
res.json(data);
})

module.exports = api
Loading