Skip to content

Commit

Permalink
prettier formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
saiteja-madha committed Dec 10, 2022
1 parent c7ba2e6 commit d378bd7
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 56 deletions.
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"singleQuote": false,
"printWidth": 120,
"bracketSpacing": true,
"arrowParens": "always"
"arrowParens": "always",
"endOfLine": "crlf"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
},
"scripts": {
"dev": "nodemon .",
"start": "node ."
"start": "node .",
"format": "prettier --write src"
},
"homepage": "https://github.com/saiteja-madha/discord-js-bot#readme",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/information/shared/guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module.exports = async (guild) => {
}
);

if (guild.splashURL()) embed.setImage(guild.splashURL({extension: "png", size: 256}));
if (guild.splashURL()) embed.setImage(guild.splashURL({ extension: "png", size: 256 }));

return { embeds: [embed] };
};
94 changes: 47 additions & 47 deletions src/commands/music/lyric.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,59 @@ const BASE_URL = "https://some-random-api.ml/lyrics";
* @type {import("@structures/Command")}
*/
module.exports = {
name: "lyric",
description: "find lyric of the song",
category: "MUSIC",
botPermissions: ["EmbedLinks"],
command: {
enabled: true,
minArgsCount: 1,
usage: "<Song Title - singer>",
},
slashCommand: {
enabled: true,
options: [
{
name: "query",
type: ApplicationCommandOptionType.String,
description: "find lyric of the song",
required: true,
},
],
},
name: "lyric",
description: "find lyric of the song",
category: "MUSIC",
botPermissions: ["EmbedLinks"],
command: {
enabled: true,
minArgsCount: 1,
usage: "<Song Title - singer>",
},
slashCommand: {
enabled: true,
options: [
{
name: "query",
type: ApplicationCommandOptionType.String,
description: "find lyric of the song",
required: true,
},
],
},

async messageRun(message, args) {
const choise = args.join(" ");
if(!choise) {
return message.safeReply("Invalid Lyric selected.");
};
const response = await getLyric(message.author, choise);
return message.safeReply(response);
},
async messageRun(message, args) {
const choise = args.join(" ");
if (!choise) {
return message.safeReply("Invalid Lyric selected.");
}
const response = await getLyric(message.author, choise);
return message.safeReply(response);
},

async interactionRun(interaction) {
const choise = interaction.options.getString("query");
const response = await getLyric(interaction.user, choise);
await interaction.followUp(response)
},
async interactionRun(interaction) {
const choise = interaction.options.getString("query");
const response = await getLyric(interaction.user, choise);
await interaction.followUp(response);
},
};

async function getLyric(user, choise) {
const lyric = await getJson(`${BASE_URL}?title=${choise}`);
if(!lyric.success) return MESSAGES.API_ERROR;
const lyric = await getJson(`${BASE_URL}?title=${choise}`);
if (!lyric.success) return MESSAGES.API_ERROR;

const thumbnail = lyric.data?.thumbnail.genius;
const author = lyric.data?.author;
const lyrics = lyric.data?.lyrics;
const title = lyric.data?.title;
const thumbnail = lyric.data?.thumbnail.genius;
const author = lyric.data?.author;
const lyrics = lyric.data?.lyrics;
const title = lyric.data?.title;

const embed = new EmbedBuilder();
embed
.setColor(EMBED_COLORS.BOT_EMBED)
.setTitle(`${author} - ${title}`)
.setThumbnail(thumbnail)
.setDescription(lyrics)
.setFooter({ text: `Request By: ${user.tag}` });
const embed = new EmbedBuilder();
embed
.setColor(EMBED_COLORS.BOT_EMBED)
.setTitle(`${author} - ${title}`)
.setThumbnail(thumbnail)
.setDescription(lyrics)
.setFooter({ text: `Request By: ${user.tag}` });

return { embeds: [embed] };
return { embeds: [embed] };
}
2 changes: 1 addition & 1 deletion src/database/mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {

success("Mongoose: Database connection established");

return mongoose.connection
return mongoose.connection;
} catch (err) {
error("Mongoose: Failed to connect to database", err);
process.exit(1);
Expand Down
12 changes: 7 additions & 5 deletions src/helpers/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = class Utils {
*/
static isValidColor(text) {
if (COLORS.indexOf(text) > -1) {
return true
return true;
} else return false;
}

Expand Down Expand Up @@ -83,10 +83,12 @@ module.exports = class Utils {
* @param {string} duration
*/
static durationToMillis(duration) {
return duration
.split(":")
.map(Number)
.reduce((acc, curr) => curr + acc * 60) * 1000;
return (
duration
.split(":")
.map(Number)
.reduce((acc, curr) => curr + acc * 60) * 1000
);
}

/**
Expand Down

0 comments on commit d378bd7

Please sign in to comment.