Skip to content

Commit

Permalink
Added proper useragents
Browse files Browse the repository at this point in the history
  • Loading branch information
coopw1 committed Jan 10, 2024
1 parent ee9bd23 commit f997d52
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/commands/general/brainz.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const {
ComponentType,
} = require("discord.js");
const axios = require("axios").default;
require("dotenv").config();

const getCurrentlyPlaying = require("./util/getCurrentlyPlaying");
const getRecentlyPlayed = require("./util/getRecentlyPlayed");
Expand Down Expand Up @@ -68,6 +67,7 @@ async function checkIfLoved(
const BASE_URL = `https://api.listenbrainz.org/1/feedback/user/${brainzUsername}/get-feedback-for-recordings`;
const AUTH_HEADER = {
Authorization: `Token ${listenBrainzToken}`,
"User-Agent": "DiscordBrainzBot/1.0.0 (coopwd@skiff.com)",
};
const PARAMS = {
params: {
Expand Down Expand Up @@ -165,6 +165,7 @@ async function sendFeedback(feedback, listenBrainzToken, MBID, MSID) {
const BASE_URL = `https://api.listenbrainz.org/1/feedback/recording-feedback`;
const AUTH_HEADER = {
Authorization: `Token ${listenBrainzToken}`,
"User-Agent": "DiscordBrainzBot/1.0.0 (coopwd@skiff.com)",
};
const PARAMS = {
recording_mbid: MBID,
Expand Down
3 changes: 3 additions & 0 deletions src/commands/general/util/getAlbumCover.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ module.exports = async (MBID) => {
try {
const BASE_URL = "http://musicbrainz.org/ws/2/recording/";
const PARAMS = {
headers: {
"User-Agent": "DiscordBrainzBot/1.0.0 (coopwd@skiff.com)",
},
params: {
query: `rid:${MBID}`,
},
Expand Down
1 change: 1 addition & 0 deletions src/commands/general/util/getCurrentlyPlaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = async (listenBrainzToken, brainzUsername) => {
const BASE_URL = `https://api.listenbrainz.org/1/user/${brainzUsername}/playing-now`;
const AUTH_HEADER = {
Authorization: `Token ${listenBrainzToken}`,
"User-Agent": "DiscordBrainzBot/1.0.0 (coopwd@skiff.com)",
};

// Make request to ListenBrainz
Expand Down
3 changes: 3 additions & 0 deletions src/commands/general/util/getMBID.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ module.exports = async (
params: {
query: ``,
},
headers: {
"User-Agent": "DiscordBrainzBot/1.0.0 (coopwd@skiff.com)",
},
};
if (artistName) {
PARAMS.params.query = PARAMS.params.query + `artist:${artistName}`;
Expand Down
1 change: 1 addition & 0 deletions src/commands/general/util/getRecentlyPlayed.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = async (listenBrainzToken, brainzUsername) => {
const BASE_URL = `https://api.listenbrainz.org/1/user/${brainzUsername}/listens`;
const AUTH_HEADER = {
Authorization: `Token ${listenBrainzToken}`,
"User-Agent": "DiscordBrainzBot/1.0.0 (coopwd@skiff.com)",
};

// Make request to ListenBrainz
Expand Down
1 change: 1 addition & 0 deletions src/commands/general/util/getSongInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = async (
const BASE_URL = `https://api.listenbrainz.org/1/metadata/lookup/`;
const AUTH_HEADER = {
Authorization: `Token ${listenBrainzToken}`,
"User-Agent": "DiscordBrainzBot/1.0.0 (coopwd@skiff.com)",
};
const PARAMS = {
params: {
Expand Down
1 change: 1 addition & 0 deletions src/commands/general/util/getTopStatistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = async (
try {
const AUTH_HEADER = {
Authorization: `Token ${listenBrainzToken}`,
"User-Agent": "DiscordBrainzBot/1.0.0 (coopwd@skiff.com)",
};

let BASE_URL;
Expand Down
1 change: 1 addition & 0 deletions src/commands/general/util/getTotalScrobbles.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = async (listenBrainzToken, brainzUsername) => {
const BASE_URL = `https://api.listenbrainz.org/1/user/${brainzUsername}/listen-count`;
const AUTH_HEADER = {
Authorization: `Token ${listenBrainzToken}`,
"User-Agent": "DiscordBrainzBot/1.0.0 (coopwd@skiff.com)",
};

// Make request to ListenBrainz
Expand Down
2 changes: 2 additions & 0 deletions src/commands/userSettings/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ module.exports = {
"https://api.listenbrainz.org/1/validate-token";
const AUTH_HEADER = {
Authorization: `Token ${token}`,
"User-Agent": "DiscordBrainzBot/1.0.0 (coopwd@skiff.com)",
};

// Make request to ListenBrainz
Expand Down Expand Up @@ -224,6 +225,7 @@ module.exports = {
const BASE_URL = "https://api.listenbrainz.org/1/validate-token";
const AUTH_HEADER = {
Authorization: `Token ${token}`,
"User-Agent": "DiscordBrainzBot/1.0.0 (coopwd@skiff.com)",
};

// Make request to ListenBrainz
Expand Down
1 change: 1 addition & 0 deletions src/commands/userSettings/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module.exports = {
const BASE_URL = `https://api.listenbrainz.org/1/search/users/`;
const AUTH_HEADER = {
Authorization: `Token ${process.env.LISTENBRAINZ_TOKEN}`,
"User-Agent": "DiscordBrainzBot/1.0.0 (coopwd@skiff.com)",
};

const PARAMS = {
Expand Down
4 changes: 3 additions & 1 deletion src/commands/util/convertSvgToPng.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const preset = presets.node({
* @return {promise<Buffer>} - The converted PNG image.
*/
module.exports = async (link) => {
const response = await axios.get(link);
const response = await axios.get(link, {
headers: { "User-Agent": "DiscordBrainzBot/1.0.0 (coopwd@skiff.com)" },
});
const svg = response.data;
const canvas = preset.createCanvas(800, 600);
const ctx = canvas.getContext("2d");
Expand Down
1 change: 1 addition & 0 deletions src/commands/util/getAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module.exports = async (interaction, noAuthNeeded) => {
const BASE_URL = `https://api.listenbrainz.org/1/search/users/`;
const AUTH_HEADER = {
Authorization: `Token ${process.env.LISTENBRAINZ_TOKEN}`,
"User-Agent": "DiscordBrainzBot/1.0.0 (coopwd@skiff.com)",
};

const PARAMS = {
Expand Down

0 comments on commit f997d52

Please sign in to comment.