Skip to content

Commit eae528f

Browse files
committed
fix: misc enhancements, preload french
1 parent fb611bc commit eae528f

File tree

15 files changed

+622
-310
lines changed

15 files changed

+622
-310
lines changed

assets/locales/en/commands.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,7 @@
115115
"error": "🤔 Sorry, an error occurred while trying to love this track. Please try again.",
116116
"notPlaying": "🤨 You need to be listening to a track to interact with it."
117117
},
118-
"assembledLyrics": [
119-
"🎶 **{{artist}} - {{track}}**",
120-
"{{lyrics}}"
121-
],
118+
"assembledLyrics": ["🎶 **{{artist}} - {{track}}**", "{{lyrics}}"],
122119
"lyrics": {
123120
"noResult": "🤔 Sorry, I couldn't find the lyrics for this track.",
124121
"noArgs": "🤔 You need to provide a track name to get its lyrics."
@@ -128,6 +125,7 @@
128125
"crown_other": "👑 {{position}}. **{{artistName}}** - *{{playCount}} scrobbles* ({{count}} roubos)",
129126
"list": [
130127
"**{{displayName}}**'s crowns on **{{groupName}}**",
128+
"🎖️ **Total crowns:** {{crownCount}}\n",
131129
"{{- crownsText}}"
132130
],
133131
"noCrowns": "You don't have any crowns in this group yet!"
@@ -137,7 +135,7 @@
137135
"claimCount_ordinal_two": "👑 You are the **{{count}}nd** to claim the crown for that artist here.",
138136
"claimCount_ordinal_few": "👑 You are the **{{count}}rd** to claim the crown for that artist here.",
139137
"claimCount_ordinal_other": "👑 You are the **{{count}}th** to claim the crown for that artist here.",
140-
"success": [
138+
"success": [
141139
"{{- pretext}}🎉 You're now the holder of the crown for **{{artistName}}** here!",
142140
"$t(commands:whoknows.claimCount, {\"count\": {{position}}, \"artistName\": \"{{artistName}}\", \"ordinal\": true})"
143141
],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { Context } from "../../../multiplatformEngine/common/context.js";
2+
import { getUserCrowns } from "../../../graphEngine/operations/crowns.js";
3+
import { getArtistDataByMbid } from "../../../graphEngine/operations.js";
4+
5+
export default async (ctx: Context) => {
6+
const username =
7+
ctx.targetedUserData?.fmUsername ?? ctx.registeredUserData!.fmUsername;
8+
const displayName = ctx.targetedUser?.name ?? ctx.registeredUser!.name;
9+
10+
const crowns = await getUserCrowns(ctx.channel.id, username).then((r) => {
11+
if (!r?.length) return undefined;
12+
return r.sort((a: any, b: any) => b.createdat - a.createdat);
13+
});
14+
const crownCount = crowns?.length || 0;
15+
16+
if (crownCount === 0) {
17+
return ctx.reply("commands:crowns.noCrowns", { displayName });
18+
}
19+
20+
// sort by createdAt
21+
const artistNames = await Promise.all(
22+
crowns.map((c: any) =>
23+
getArtistDataByMbid(c.artistmbid).then((a) => a.name),
24+
),
25+
);
26+
let crownsText = "";
27+
for (let i = 0; i < crownCount; i++) {
28+
const crown = crowns[i];
29+
crownsText +=
30+
ctx.t("commands:crowns.crown", {
31+
position: i + 1,
32+
artistName: artistNames[i],
33+
playCount: crown.playcount,
34+
count: crown.switchedtimes,
35+
}) + "\n";
36+
}
37+
38+
if (crownsText.length > 3800) {
39+
crownsText = crownsText.slice(0, 3800) + "...";
40+
}
41+
42+
return ctx.reply("commands:crowns.list", {
43+
displayName,
44+
groupName: ctx.channel.name,
45+
crownCount,
46+
crownsText,
47+
joinArrays: "\n",
48+
});
49+
};
50+
51+
export const info = {
52+
aliases: ["crws", "coroas"],
53+
};

src/commandEngine/commands/noDMs+registered/crowns.ts

-42
This file was deleted.
+31-20
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
1-
import { Context } from '../../../multiplatformEngine/common/context.js'
2-
import { getNowPlaying } from '../../../fmEngine/completeNowPlaying.js'
3-
import { checkIfUserHasCrown } from '../../../graphEngine/operations/crowns.js'
1+
import { Context } from "../../../multiplatformEngine/common/context.js";
2+
import { getNowPlaying } from "../../../fmEngine/completeNowPlaying.js";
3+
import { checkIfUserHasCrown } from "../../../graphEngine/operations/crowns.js";
44

55
export default async (ctx: Context) => {
6-
const data = await getNowPlaying(ctx, 'album')
7-
const user = ctx.targetedUser ?? ctx.registeredUser
8-
const userData = ctx.targetedUserData ?? ctx.registeredUserData
6+
const data = await getNowPlaying(ctx, "album");
7+
const user = ctx.targetedUser ?? ctx.registeredUser;
8+
const userData = ctx.targetedUserData ?? ctx.registeredUserData;
99

10-
const hasCrown = await checkIfUserHasCrown(ctx.channel.id, userData.fmUsername, data.artistMbid)
10+
const hasCrown = await checkIfUserHasCrown(
11+
ctx.channel.id,
12+
userData.fmUsername,
13+
data.artistMbid,
14+
);
1115

12-
ctx.reply(`commands:album`, {
13-
user: user.name,
14-
artistCrown: hasCrown ? '👑' : '🧑‍🎤',
15-
isListening: data.isNowPlaying ? 'isPlaying' : 'wasPlaying',
16-
artist: data.artist,
17-
album: data.album,
18-
playCount: data.playCount,
19-
joinArrays: '\n',
20-
tags: userData.sendTags ? `\n*${data.tags.map(a => `#${a}`).join(' ')}*` : '',
21-
}, { imageURL: data.imageURL, sendImageAsPhoto: !userData.sendPhotosAsLink })
22-
}
16+
ctx.reply(
17+
`commands:album`,
18+
{
19+
user: user.name,
20+
artistCrown: hasCrown ? "👑" : "🧑‍🎤",
21+
isListening: data.isNowPlaying ? "isPlaying" : "wasPlaying",
22+
artist: data.artist,
23+
album: data.album,
24+
playCount: data.playCount,
25+
joinArrays: "\n",
26+
tags:
27+
userData.sendTags && data.tags.length > 0
28+
? `\n*${data.tags.map((a) => `#${a}`).join(" ")}*`
29+
: "",
30+
},
31+
{ imageURL: data.imageURL, sendImageAsPhoto: !userData.sendPhotosAsLink },
32+
);
33+
};
2334

2435
export const info = {
25-
aliases: ['alb']
26-
}
36+
aliases: ["alb"],
37+
};
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,39 @@
1-
import { Context } from '../../../multiplatformEngine/common/context.js'
2-
import { getNowPlaying } from '../../../fmEngine/completeNowPlaying.js'
3-
import { warn } from '../../../loggingEngine/logging.js'
4-
import { checkIfUserHasCrown } from '../../../graphEngine/operations/crowns.js'
1+
import { Context } from "../../../multiplatformEngine/common/context.js";
2+
import { getNowPlaying } from "../../../fmEngine/completeNowPlaying.js";
3+
import { warn } from "../../../loggingEngine/logging.js";
4+
import { checkIfUserHasCrown } from "../../../graphEngine/operations/crowns.js";
55

66
export default async (ctx: Context) => {
7-
const data = await getNowPlaying(ctx, 'artist')
8-
const user = ctx.targetedUser ?? ctx.registeredUser
9-
const userData = ctx.targetedUserData ?? ctx.registeredUserData
7+
const data = await getNowPlaying(ctx, "artist");
8+
const user = ctx.targetedUser ?? ctx.registeredUser;
9+
const userData = ctx.targetedUserData ?? ctx.registeredUserData;
1010

11-
const hasCrown = await checkIfUserHasCrown(ctx.channel.id, userData.fmUsername, data.artistMbid)
11+
const hasCrown = await checkIfUserHasCrown(
12+
ctx.channel.id,
13+
userData.fmUsername,
14+
data.artistMbid,
15+
);
1216

13-
if (!data.mbid) warn('commands.artist', `no mbid found for ${data.artist}`)
17+
if (!data.mbid) warn("commands.artist", `no mbid found for ${data.artist}`);
1418

15-
ctx.reply(`commands:artist`, {
16-
user: user.name,
17-
artistCrown: hasCrown ? '👑' : '🧑‍🎤',
18-
isListening: data.isNowPlaying ? 'isPlaying' : 'wasPlaying',
19-
artist: data.artist,
20-
playCount: data.playCount,
21-
joinArrays: '\n',
22-
tags: userData.sendTags ? `\n*${data.tags.map(a => `#${a}`).join(' ')}*` : '',
23-
}, { imageURL: data.imageURL, sendImageAsPhoto: !userData.sendPhotosAsLink })
24-
}
19+
ctx.reply(
20+
`commands:artist`,
21+
{
22+
user: user.name,
23+
artistCrown: hasCrown ? "👑" : "🧑‍🎤",
24+
isListening: data.isNowPlaying ? "isPlaying" : "wasPlaying",
25+
artist: data.artist,
26+
playCount: data.playCount,
27+
joinArrays: "\n",
28+
tags:
29+
userData.sendTags && data.tags.length > 0
30+
? `\n*${data.tags.map((a) => `#${a}`).join(" ")}*`
31+
: "",
32+
},
33+
{ imageURL: data.imageURL, sendImageAsPhoto: !userData.sendPhotosAsLink },
34+
);
35+
};
2536

2637
export const info = {
27-
aliases: ['art']
28-
}
38+
aliases: ["art"],
39+
};
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,39 @@
1-
import { Context } from '../../../multiplatformEngine/common/context.js'
2-
import { getNowPlaying } from '../../../fmEngine/completeNowPlaying.js'
3-
import { checkIfUserHasCrown } from '../../../graphEngine/operations/crowns.js'
1+
import { Context } from "../../../multiplatformEngine/common/context.js";
2+
import { getNowPlaying } from "../../../fmEngine/completeNowPlaying.js";
3+
import { checkIfUserHasCrown } from "../../../graphEngine/operations/crowns.js";
44

55
export default async (ctx: Context) => {
6-
const data = await getNowPlaying(ctx, 'track')
7-
const user = ctx.targetedUser ?? ctx.registeredUser
8-
const userData = ctx.targetedUserData ?? ctx.registeredUserData
6+
const data = await getNowPlaying(ctx, "track");
7+
const user = ctx.targetedUser ?? ctx.registeredUser;
8+
const userData = ctx.targetedUserData ?? ctx.registeredUserData;
99

10-
const hasCrown = await checkIfUserHasCrown(ctx.channel.id, userData.fmUsername, data.artistMbid)
10+
const hasCrown = await checkIfUserHasCrown(
11+
ctx.channel.id,
12+
userData.fmUsername,
13+
data.artistMbid,
14+
);
1115

12-
ctx.reply(`commands:listening`, {
13-
user: user.name,
14-
artistCrown: hasCrown ? '👑' : '🧑‍🎤',
15-
isListening: data.isNowPlaying ? 'isPlaying' : 'wasPlaying',
16-
track: data.name,
17-
artist: data.artist,
18-
album: data.album,
19-
playCount: data.playCount,
20-
emoji: data.loved ? userData.likedEmoji : '🎵',
21-
tags: userData.sendTags ? `\n*${data.tags.map(a => `#${a}`).join(' ')}*` : '',
22-
joinArrays: '\n'
23-
}, { imageURL: data.imageURL, sendImageAsPhoto: !userData.sendPhotosAsLink })
24-
}
16+
ctx.reply(
17+
`commands:listening`,
18+
{
19+
user: user.name,
20+
artistCrown: hasCrown ? "👑" : "🧑‍🎤",
21+
isListening: data.isNowPlaying ? "isPlaying" : "wasPlaying",
22+
track: data.name,
23+
artist: data.artist,
24+
album: data.album,
25+
playCount: data.playCount,
26+
emoji: data.loved ? userData.likedEmoji : "🎵",
27+
tags:
28+
userData.sendTags && data.tags.length > 0
29+
? `\n*${data.tags.map((a) => `#${a}`).join(" ")}*`
30+
: "",
31+
joinArrays: "\n",
32+
},
33+
{ imageURL: data.imageURL, sendImageAsPhoto: !userData.sendPhotosAsLink },
34+
);
35+
};
2536

2637
export const info = {
27-
aliases: ['lt', 'ln', 'lp', 'pl', 'pt', 'listening', 'listen']
28-
}
38+
aliases: ["lt", "ln", "lp", "pl", "pt", "listening", "listen"],
39+
};
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
1-
import { Context } from '../../../multiplatformEngine/common/context.js'
2-
import { getNowPlaying } from '../../../fmEngine/completeNowPlaying.js'
1+
import { Context } from "../../../multiplatformEngine/common/context.js";
2+
import { getNowPlaying } from "../../../fmEngine/completeNowPlaying.js";
33

44
export default async (ctx: Context) => {
5-
const data = await getNowPlaying(ctx, 'album', false, true)
5+
const data = await getNowPlaying(ctx, "album", false, true);
66

7-
ctx.reply(`commands:mealbum`, {
8-
user: ctx.registeredUser?.name,
9-
artist: data.artist,
10-
album: data.album,
11-
playCount: data.playCount,
12-
tags: ctx.registeredUserData.sendTags ? `\n*${data.tags.map(a => `#${a}`).join(' ')}*` : '',
13-
joinArrays: '\n'
14-
}, { imageURL: data.imageURL, sendImageAsPhoto: !ctx.registeredUserData?.sendPhotosAsLink })
15-
}
7+
ctx.reply(
8+
`commands:mealbum`,
9+
{
10+
user: ctx.registeredUser?.name,
11+
artist: data.artist,
12+
album: data.album,
13+
playCount: data.playCount,
14+
tags:
15+
ctx.registeredUserData.sendTags && data.tags.length > 0
16+
? `\n*${data.tags.map((a) => `#${a}`).join(" ")}*`
17+
: "",
18+
joinArrays: "\n",
19+
},
20+
{
21+
imageURL: data.imageURL,
22+
sendImageAsPhoto: !ctx.registeredUserData?.sendPhotosAsLink,
23+
},
24+
);
25+
};
1626

1727
export const info = {
18-
aliases: ['mealb', 'eualb']
19-
}
28+
aliases: ["mealb", "eualb"],
29+
};
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
1-
import { Context } from '../../../multiplatformEngine/common/context.js'
2-
import { getNowPlaying } from '../../../fmEngine/completeNowPlaying.js'
1+
import { Context } from "../../../multiplatformEngine/common/context.js";
2+
import { getNowPlaying } from "../../../fmEngine/completeNowPlaying.js";
33

44
export default async (ctx: Context) => {
5-
const data = await getNowPlaying(ctx, 'artist', false, true)
5+
const data = await getNowPlaying(ctx, "artist", false, true);
66

7-
ctx.reply(`commands:meartist`, {
8-
user: ctx.registeredUser?.name,
9-
artist: data.artist,
10-
playCount: data.playCount,
11-
tags: ctx.registeredUserData.sendTags ? `\n*${data.tags.map(a => `#${a}`).join(' ')}*` : '',
12-
joinArrays: '\n'
13-
}, { imageURL: data.imageURL, sendImageAsPhoto: !ctx.registeredUserData?.sendPhotosAsLink })
14-
}
7+
ctx.reply(
8+
`commands:meartist`,
9+
{
10+
user: ctx.registeredUser?.name,
11+
artist: data.artist,
12+
playCount: data.playCount,
13+
tags:
14+
ctx.registeredUserData.sendTags && data.tags.length > 0
15+
? `\n*${data.tags.map((a) => `#${a}`).join(" ")}*`
16+
: "",
17+
joinArrays: "\n",
18+
},
19+
{
20+
imageURL: data.imageURL,
21+
sendImageAsPhoto: !ctx.registeredUserData?.sendPhotosAsLink,
22+
},
23+
);
24+
};
1525

1626
export const info = {
17-
aliases: ['meart', 'euart']
18-
}
27+
aliases: ["meart", "euart"],
28+
};

0 commit comments

Comments
 (0)