profile.js
· 3.6 KiB · JavaScript
Raw
module.exports = {
name: 'profile',
category: 'Sharex',
description: 'View your cordx profile/information',
userPerms: [''],
basePerms: [''],
options: [
{
name: 'user',
description: 'Leave empty to fetch your own profile.',
required: false,
type: 6
}
],
run: async (client) => {
let member = await client.interaction.options.getMember('user') || client.interaction.user;
await fetch(`${client.config.Cordx.Domains.beta}api/user/stats?userId=${member.id}`)
.then(res => res.json())
.then(data => {
let remains = 2000 - data.used;
let images = data.images;
let downloads = data.downloads;
let videos = data.videos;
return client.interaction.reply({
embeds: [
new client.Gateway.EmbedBuilder()
.setTitle(`Profile for: ${member.globalName ? member.globalName : member.user.globalName}`)
.setColor(client.colors.base)
.setThumbnail(member.displayAvatarURL({ dynamic: true }))
.setDescription(`You can view the profile [here](https://dev.cordx.lol/${member.id})`)
.addFields({
name: 'Stored Images',
value: `${images ? images : 0} total`,
inline: true
},{
name: 'Stored Downloads',
value: `${downloads ? downloads : 0} total`,
inline: true
},{
name: 'Stored Videos',
value: `${videos ? videos : 0} total`,
inline: true
},{
name: 'Storage Limit',
value: `2,000MB`,
inline: true
},{
name: 'Storage Used',
value: `${data.used.toLocaleString()}MB`,
inline: true
}, {
name: 'Storage Available',
value: `${remains.toLocaleString()}MB`,
inline: true
})
.setTimestamp()
.setFooter({
text: client.footer,
iconURL: client.logo
})
]
})
})
.catch((e) => {
return client.interaction.reply({
embeds: [
new client.Gateway.EmbedBuilder()
.setTitle('Error: api unavailable')
.setColor(client.colors.error)
.setThumbnail(client.logo)
.setDescription('Hold up, either i was unable to locate your data or our API is down. Have you logged in or created an account? If you have you can check our status below')
.addFields({
name: 'Error',
value: `${e.message}`,
inline: true,
},{
name: 'View Our Status',
value: `[click me](https://beta.cordx.lol/status) or run the "/status" command.`
})
.setTimestamp()
.setFooter({
text: client.footer,
iconURL: client.logo
})
]
})
})
}
}
1 | module.exports = { |
2 | name: 'profile', |
3 | category: 'Sharex', |
4 | description: 'View your cordx profile/information', |
5 | userPerms: [''], |
6 | basePerms: [''], |
7 | options: [ |
8 | { |
9 | name: 'user', |
10 | description: 'Leave empty to fetch your own profile.', |
11 | required: false, |
12 | type: 6 |
13 | } |
14 | ], |
15 | |
16 | run: async (client) => { |
17 | |
18 | let member = await client.interaction.options.getMember('user') || client.interaction.user; |
19 | |
20 | await fetch(`${client.config.Cordx.Domains.beta}api/user/stats?userId=${member.id}`) |
21 | .then(res => res.json()) |
22 | .then(data => { |
23 | |
24 | let remains = 2000 - data.used; |
25 | let images = data.images; |
26 | let downloads = data.downloads; |
27 | let videos = data.videos; |
28 | |
29 | return client.interaction.reply({ |
30 | embeds: [ |
31 | new client.Gateway.EmbedBuilder() |
32 | .setTitle(`Profile for: ${member.globalName ? member.globalName : member.user.globalName}`) |
33 | .setColor(client.colors.base) |
34 | .setThumbnail(member.displayAvatarURL({ dynamic: true })) |
35 | .setDescription(`You can view the profile [here](https://dev.cordx.lol/${member.id})`) |
36 | .addFields({ |
37 | name: 'Stored Images', |
38 | value: `${images ? images : 0} total`, |
39 | inline: true |
40 | },{ |
41 | name: 'Stored Downloads', |
42 | value: `${downloads ? downloads : 0} total`, |
43 | inline: true |
44 | },{ |
45 | name: 'Stored Videos', |
46 | value: `${videos ? videos : 0} total`, |
47 | inline: true |
48 | },{ |
49 | name: 'Storage Limit', |
50 | value: `2,000MB`, |
51 | inline: true |
52 | },{ |
53 | name: 'Storage Used', |
54 | value: `${data.used.toLocaleString()}MB`, |
55 | inline: true |
56 | }, { |
57 | name: 'Storage Available', |
58 | value: `${remains.toLocaleString()}MB`, |
59 | inline: true |
60 | }) |
61 | .setTimestamp() |
62 | .setFooter({ |
63 | text: client.footer, |
64 | iconURL: client.logo |
65 | }) |
66 | ] |
67 | }) |
68 | }) |
69 | .catch((e) => { |
70 | |
71 | return client.interaction.reply({ |
72 | embeds: [ |
73 | new client.Gateway.EmbedBuilder() |
74 | .setTitle('Error: api unavailable') |
75 | .setColor(client.colors.error) |
76 | .setThumbnail(client.logo) |
77 | .setDescription('Hold up, either i was unable to locate your data or our API is down. Have you logged in or created an account? If you have you can check our status below') |
78 | .addFields({ |
79 | name: 'Error', |
80 | value: `${e.message}`, |
81 | inline: true, |
82 | },{ |
83 | name: 'View Our Status', |
84 | value: `[click me](https://beta.cordx.lol/status) or run the "/status" command.` |
85 | }) |
86 | .setTimestamp() |
87 | .setFooter({ |
88 | text: client.footer, |
89 | iconURL: client.logo |
90 | }) |
91 | ] |
92 | }) |
93 | }) |
94 | } |
95 | } |