This repository has been archived by the owner on Mar 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
59 lines (55 loc) · 1.77 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const { Plugin } = require("powercord/entities");
const { get } = require("powercord/http");
module.exports = class Osu extends Plugin {
startPlugin() {
powercord.api.commands.registerCommand({
command: "osu",
description: "Get a user STATs from OSU",
usage: "{c} [username]",
executor: async (args) => {
// get the user stats
try {
const { body } = await get(
`https://api.obamabot.cf/v2/text/osu?user=${args.join(" ")}`
);
console.log(body)
if (body.length === 0) {
return {
result: "No user found",
username: "Pippi",
avatar_url: "https://i.imgur.com/eRTuzdt.png"
}
}
// string the stats
const string = [
`__${body.username}'s Stats__`,
`Global Rank: **${
body.custom[0].pp_rank
}** (:flag_${body.custom[0].country_code}: #${
body.custom[0].pp_country_rank
})`,
`PP: **${body.custom[0].pp_raw}**`,
`Play Count: **${body.custom[0].playcount}**`,
`Accuracy: **${body.custom[0].hit_accuracy}%**`,
`Time Played: **${body.custom[0].time_played}**`,
].join("\n");
// send the user a message with the user stats
return {
send: false,
result: string,
username: "Pippi",
avatar_url: "https://i.imgur.com/eRTuzdt.png"
};
} catch (e) {
console.log(e)
return {
result: `${e}`,
username: "Pippi",
avatar_url: "https://i.imgur.com/eRTuzdt.png",
};
}
},
});
}
pluginWillUnload() {powercord.api.commands.unregisterCommand("osu");}
};