Skip to content

Commit 94fef8e

Browse files
authored
Merge pull request #22 from Kkkermit/testing-branch
Testing branch
2 parents 8538940 + 3d5bee6 commit 94fef8e

File tree

23 files changed

+781
-337
lines changed

23 files changed

+781
-337
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.development.example.env

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ mongodb=
66
movietrackerapi=
77
rapidapikey=
88

9-
webhookSlashLogging="",
10-
webhookPrefixLogging="",
11-
webhookBugLogging="",
12-
webhookSuggestionLogging=""
9+
SPOTIFY_CLIENT_ID=your_client_id_here
10+
SPOTIFY_CLIENT_SECRET=your_client_secret_here
11+
SPOTIFY_REDIRECT_URI=http://localhost:3000/callback
12+
13+
PORT=3000

.example.env

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ mongodb=
66
movietrackerapi=
77
rapidapikey=
88

9-
webhookSlashLogging="",
10-
webhookPrefixLogging="",
11-
webhookBugLogging="",
12-
webhookSuggestionLogging=""
9+
SPOTIFY_CLIENT_ID=your_client_id_here
10+
SPOTIFY_CLIENT_SECRET=your_client_secret_here
11+
SPOTIFY_REDIRECT_URI=http://localhost:3000/callback
12+
13+
PORT=3000

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18.13.0
1+
21.7.1

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,11 @@ With over 100 slash command and over 50 prefix commands, Testify is an open sour
106106
6. Paste your client ID into the `clientid` variable inside the `.env` file.
107107
7. Navigate to your discord server, enable developer mode and right click the dropdown beside the server name.
108108
8. Click `Copy Server ID` and paste it into the `guildid` variable inside the `.env` file.
109-
9. Navigate to the `package.json` file and pay attention to the runnable commands listed under `scripts`.
110-
10. Open the terminal in [Visual Studio Code](https://code.visualstudio.com/download) and install all necessary packages using `npm run setup`. This will install the dependencies and give you a brief install guide
111-
11. Open a new terminal and type `npm run prod` to run the file without using **nodemon** or `npm run prod:nodemon` to run the bot with nodemon.
112-
12. The bot should then turn online, you should be able to see this by the console logs that is setup upon start up
109+
9. Visit the [Spotify web API docs](https://developer.spotify.com/documentation/web-api) and sign in. Once signed in, navigate to dashboard. Once on here, you'll need to create an app. Fill out the steps on the site to create your app. Once created, you'll need to copy your clientid and client secret into the `SPOTIFY_CLIENT_ID` & `SPOTIFY_CLIENT_SECRET` fields in the `.env` file. You can leave the `SPOTIFY_REDIRECT_URI` as it is. Only change this if you're updating the port of the Spotify server.
110+
10. Navigate to the `package.json` file and pay attention to the runnable commands listed under `scripts`.
111+
11. Open the terminal in [Visual Studio Code](https://code.visualstudio.com/download) and install all necessary packages using `npm run setup`. This will install the dependencies and give you a brief install guide
112+
12. Open a new terminal and type `npm run prod` to run the file without using **nodemon** or `npm run prod:nodemon` to run the bot with nodemon.
113+
13. The bot should then turn online, you should be able to see this by the console logs that is setup upon start up
113114

114115
- **Runnable commands (scripts)**
115116

@@ -128,6 +129,9 @@ With over 100 slash command and over 50 prefix commands, Testify is an open sour
128129
**setup-env:dev** - <br>
129130
To run the setup of the `.env.development` file you can run the command `npm run setup-env:dev`, this generates a script in the console that generates a `.env.development` file and where you fill out the fields with whats required for the `.env.development` file and it writes it in the file.
130131

132+
**log-setup** - <br>
133+
To run the setup of the colored logs in the `discord-logs` module. This saves you from manually doing the below method [Setting-up-audit-logs](#setting-up-audit-logs)
134+
131135
## Setting-up-audit-logs
132136

133137
To set the advanced logs registry for the Testify audit-logs ( the event handler registers ) than follow this!

package-lock.json

Lines changed: 0 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"@distube/ytdl-core": "4.14.4",
3333
"@distube/ytsr": "2.0.4",
3434
"@napi-rs/canvas": "^0.1.52",
35-
"@napi-rs/canvas-darwin-arm64": "0.1.66",
3635
"apexify.js": "4.5.43",
3736
"ascii-table": "^0.0.9",
3837
"axios": "^1.6.8",

src/api/spotifyTrackerApi.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const axios = require('axios');
2+
3+
async function getTopItems(accessToken, type, timeRange = 'long_term') {
4+
try {
5+
if (type === 'albums') {
6+
const tracksResponse = await axios.get('https://api.spotify.com/v1/me/top/tracks', {
7+
headers: {
8+
'Authorization': `Bearer ${accessToken}`
9+
},
10+
params: {
11+
limit: 50,
12+
time_range: timeRange
13+
}
14+
});
15+
16+
const albumMap = new Map();
17+
tracksResponse.data.items.forEach(track => {
18+
const album = track.album;
19+
if (album && album.total_tracks > 3) {
20+
const count = albumMap.get(album.id)?.count || 0;
21+
albumMap.set(album.id, {
22+
id: album.id,
23+
name: album.name,
24+
artists: album.artists,
25+
images: album.images,
26+
release_date: album.release_date,
27+
count: count + 1
28+
});
29+
}
30+
});
31+
32+
const topAlbums = Array.from(albumMap.values())
33+
.sort((a, b) => b.count - a.count)
34+
.slice(0, 10);
35+
36+
return topAlbums;
37+
}
38+
39+
const response = await axios.get(`https://api.spotify.com/v1/me/top/${type}`, {
40+
headers: {
41+
'Authorization': `Bearer ${accessToken}`
42+
},
43+
params: {
44+
limit: 10,
45+
time_range: timeRange
46+
}
47+
});
48+
49+
return response.data.items;
50+
} catch (error) {}
51+
}
52+
53+
module.exports = { getTopItems };

src/commands/Community/spotify.js

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/commands/HardModeration/userSchemaClear.js

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)