This commit is contained in:
yhqe committed 2026-03-15 19:06:45 -05:00
1 parent 55df89c02b
commit ebc644e269
3 files changed
+1061 -890

No files matched your search

+874 -874
View File
File diff suppressed because it is too large. Load diff
+139
View File
@@ -0,0 +1,139 @@
'use strict';
const { time } = require("discord.js");
const logger = require('../../utils/logger');
async function getAvailableCapes(username) {
const capes =[];
const mojangReq = await Promise.allSettled([
fetch(`https://api.ashcon.app/mojang/v2/user/${username}`),
]);
if (mojangReq.status === 'fulfilled' && mojangReq.value.ok) {
const mojangData = await mojangReq.value.json();
if (mojangData.textures && mojangData.textures.cape) {
capes.push({
source: 'Official (Equipped)',
url: mojangData.textures.cape.url
});
}
}
return capes;
}
module.exports = {
name: 'mc',
description: `request different information about a minecraft user`,
aliases: ['minecraft'],
usage: 'mc <username>',
async execute(client, message, args) {
var embed;
let sent = await message.reply({
content: null, embeds: [{
color: 0x8aa2b3,
title: '',
author: {
name: message.author.username,
icon_url: message.author.displayAvatarURL(),
},
description: '<a:loading_icon:1366587619890302998> fetching...',
footer: {
text: `twitter @ ${message.guild.name}`,
icon_url: client.user.displayAvatarURL(),
},
timestamp: new Date(),
}]
});
const username = args[0];
if (!username) {
embed = {
color: 0x8aa2b3,
title: '',
description: '<:no:1481811955592466492> please provide a valid minecraft username!',
footer: {
text: `twitter @ ${message.guild.name}`,
icon_url: client.user.displayAvatarURL(),
},
timestamp: new Date(),
};
return await sent.edit({ content: null, embeds: [embed] });
}
const uuid_res = await fetch(`https://api.mojang.com/users/profiles/minecraft/${username}`);
const uuid = await uuid_res.json().then(res => res.id).catch(err => {
embed = {
color: 0x8aa2b3,
title: '',
description: '<:no:1481811955592466492> cannot fetch uuid!',
footer: {
text: `twitter @ ${message.guild.name}`,
icon_url: client.user.displayAvatarURL(),
},
timestamp: new Date(),
};
return null;
});
const res = await fetch(`https://sessionserver.mojang.com/session/minecraft/profile/${uuid}`);
const data = await res.json().then(res => res).catch(err => {
embed = {
color: 0x8aa2b3,
title: '',
description: '<:no:1481811955592466492> cannot fetch data!',
footer: {
text: `twitter @ ${message.guild.name}`,
icon_url: client.user.displayAvatarURL(),
},
timestamp: new Date(),
};
return null;
});
getAvailableCapes(`${data.name}`).then(capes => {
logger.debug(`found ${capes.length} cape(s):`);
logger.debug(capes);
});
if (!data) return await sent.edit({ content: null, embeds: [embed] });
const skin = await fetch (`https://minotar.net/helm/${data.name}/420.png`).then(res => res.url).catch(err => null);
const capes = data.properties[0].value;
const decoded_capes = Buffer.from(capes, 'base64').toString('utf-8');
const cape_url = JSON.parse(decoded_capes).textures.CAPE ? JSON.parse(decoded_capes).textures.CAPE.url : null;
logger.debug(`[mc] fetched data for "${username}": ${JSON.stringify(data)}`);
logger.debug(`[mc] fetched cape data for "${username}": ${JSON.stringify(cape_url)}`);
embed = {
color: 0x8aa2b3,
title: '',
author: {
name: message.author.username,
icon_url: message.author.displayAvatarURL(),
},
description: `**[${data.name}](https://namemc.com/profile/${data.name})**`,
fields: [
{ name: 'uuid', value: `${data.id}`, inline: true },
],
footer: {
text: `twitter @ ${message.guild.name}`,
icon_url: client.user.displayAvatarURL(),
},
timestamp: new Date(),
thumbnail: {
url: skin,
height: 1024,
width: 1024,
},
};
await sent.edit({ content: null, embeds: [embed] });
},
};
+48 -16
View File
@@ -94,20 +94,25 @@ module.exports = {
let latency = Date.now() - message.createdTimestamp; let latency = Date.now() - message.createdTimestamp;
let apiLatency = Math.round(client.ws.ping); let apiLatency = Math.round(client.ws.ping);
if (subcommand === 'user') { if (subcommand === 'user' || subcommand === 'u') {
try { try {
const res = await fetch(`https://users.roproxy.com/v1/usernames/users`, { const res = await fetch(`https://users.roblox.com/v1/usernames/users`, {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${process.env.ROBLOSECURITY}` },
body: JSON.stringify({ usernames: [argument], excludeBannedUsers: false }) body: JSON.stringify({ usernames: [argument], excludeBannedUsers: false })
}); });
const data = await res.json(); const data = await res.json();
logger.debug(`[rbx] fetched user data (roblox, standard) for "${argument}": ${JSON.stringify(data)}`);
const extra_res = await fetch(`https://users.roproxy.com/v1/users/${data.data[0].id}`, { if (!data.data || !data.data[0]) {
throw new Error('User not found');
}
const extra_res = await fetch(`https://users.roblox.com/v1/users/${data.data[0].id}`, {
method: 'GET', method: 'GET',
headers: { 'Content-Type': 'application/json' } headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${process.env.ROBLOSECURITY}` }
}); });
const extra_data = await extra_res.json(); const extra_data = await extra_res.json();
logger.debug(`[rbx] fetched user data (roblox, extra) for "${argument}": ${JSON.stringify(extra_data)}`);
const r_res = await fetch(`https://api.rolimons.com/players/v1/playerinfo/${data.data[0].id}`, { const r_res = await fetch(`https://api.rolimons.com/players/v1/playerinfo/${data.data[0].id}`, {
method: 'GET', method: 'GET',
@@ -120,16 +125,13 @@ module.exports = {
logger.warn(`[rbx] Failed to fetch rolimons playerinfo for id ${data.data[0].id}: HTTP ${r_res.status}`); logger.warn(`[rbx] Failed to fetch rolimons playerinfo for id ${data.data[0].id}: HTTP ${r_res.status}`);
r_data = {}; r_data = {};
} }
logger.debug(`[rbx] fetched user data (rolimons) for "${argument}": ${JSON.stringify(r_data)}`);
const ra_res = await fetch(`https://api.rolimons.com/players/v1/playerassets/${data.data[0].id}`, { const ra_res = await fetch(`https://api.rolimons.com/players/v1/playerassets/${data.data[0].id}`, {
method: 'GET', method: 'GET',
headers: { 'Content-Type': 'application/json' } headers: { 'Content-Type': 'application/json' }
}); });
const ra_data = await ra_res.json(); const ra_data = await ra_res.json();
logger.debug(`[rbx] fetched user data (roblox, standard) for "${argument}": ${JSON.stringify(data)}`);
logger.debug(`[rbx] fetched user data (roblox, extra) for "${argument}": ${JSON.stringify(extra_data)}`);
logger.debug(`[rbx] fetched user data (rolimons) for "${argument}": ${JSON.stringify(r_data)}`);
logger.debug(`[rbx] fetched user data (rolimons, assets) for "${argument}": ${JSON.stringify(ra_data)}`); logger.debug(`[rbx] fetched user data (rolimons, assets) for "${argument}": ${JSON.stringify(ra_data)}`);
if (!data.data || !data.data[0]) { if (!data.data || !data.data[0]) {
@@ -157,15 +159,20 @@ module.exports = {
const viewInvRes = await fetch(`https://inventory.roblox.com/v1/users/${user.id}/can-view-inventory`); const viewInvRes = await fetch(`https://inventory.roblox.com/v1/users/${user.id}/can-view-inventory`);
const isInvPublic = (await viewInvRes.json()).canView; const isInvPublic = (await viewInvRes.json()).canView;
const formatted_desc = (extra_data.description || "no description")
.split('\n')
.map(line => line.trim() ? `-# *${line}*` : '')
.join('\n');
embed = { embed = {
color: 0x8aa2b3, color: 0x8aa2b3,
author: { author: {
name: message.author.username, name: message.author.username,
icon_url: message.author.displayAvatarURL(), icon_url: message.author.displayAvatarURL(),
}, },
description: `**[${user.displayName}](https://www.roblox.com/users/${user.id}/profile)** [(${user.name})](https://www.rolimons.com/player/${user.id}) ${isOnline ? "<:online:1482657396362055826>" : "<:offline:1482657564650115073>"} ${hasPremium ? "<:premium:1482660040358760602>" : ""} ${hasCheckmark ? "<:Verified:1376786225486364823>" : ""}\n-# *${extra_data.description || "no description"}*`, description: `**[${user.displayName}](https://www.roblox.com/users/${user.id}/profile)** [(${user.name})](https://www.rolimons.com/player/${user.id}) ${isOnline ? "<:online:1482657396362055826>" : "<:offline:1482657564650115073>"} ${hasPremium ? "<:premium:1482660040358760602>" : ""} ${hasCheckmark ? "<:Verified:1376786225486364823>" : ""}\n${formatted_desc}`,
fields: [ fields: [
{ name: 'id', value: String(user.id), inline: true }, { name: 'id', value: String(extra_data.id), inline: true },
{ name: 'rap', value: String(r_data.rap), inline: true }, { name: 'rap', value: String(r_data.rap), inline: true },
{ name: 'value', value: String(r_data.value), inline: true }, { name: 'value', value: String(r_data.value), inline: true },
{ name: 'inventory', value: `${isInvPublic ? 'public' : 'private'}`, inline: true }, { name: 'inventory', value: `${isInvPublic ? 'public' : 'private'}`, inline: true },
@@ -203,9 +210,27 @@ module.exports = {
} }
} else if (subcommand === 'item') { } else if (subcommand === 'item') {
try { try {
const res = await fetch(`https://economy.roproxy.com/v2/assets/${argument}/details`); const res = await fetch(`https://economy.roblox.com/v2/assets/${argument}/details`, {
const p_res = await fetch(`https://thumbnails.roproxy.com/v1/ assets?assetIds=${argument}&returnPolicy=PlaceHolder&size=420x420&format=Png&isCircular=false`) method: 'GET',
const resale_res = await fetch(`https://economy.roproxy.com/v1/assets/${argument}/resale-data`); headers: {
'Content-Type': 'application/json',
'Cookie': `.ROBLOSECURITY=${process.env.ROBLOSECURITY}`
}
});
const p_res = await fetch(`https://thumbnails.roblox.com/v1/assets?assetIds=${argument}&returnPolicy=PlaceHolder&size=420x420&format=Png&isCircular=false`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Cookie': `.ROBLOSECURITY=${process.env.ROBLOSECURITY}`
}
});
const resale_res = await fetch(`https://economy.roblox.com/v1/assets/${argument}/resale-data`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Cookie': `.ROBLOSECURITY=${process.env.ROBLOSECURITY}`
}
});
const item = await res.json(); const item = await res.json();
logger.debug(`[rbx] fetched item data (roblox) for "${argument}": ${JSON.stringify(item)}`); logger.debug(`[rbx] fetched item data (roblox) for "${argument}": ${JSON.stringify(item)}`);
@@ -237,6 +262,13 @@ module.exports = {
const item_thumb = await fetch_item_thumb(item.AssetId); const item_thumb = await fetch_item_thumb(item.AssetId);
const is_offsale = item.IsForSale; const is_offsale = item.IsForSale;
const is_limited = item.IsLimited;
const is_limited_unique = item.IsLimitedUnique;
const is_limited_at_all = is_limited || is_limited_unique;
const limited_string = is_limited ? (is_limited_unique ? "true (unique)" : "true") : "false";
embed = { embed = {
color: 0x8aa2b3, color: 0x8aa2b3,
author: { author: {
@@ -247,8 +279,8 @@ module.exports = {
fields: [ fields: [
{ name: "id", value: `${item.AssetId}`, inline: true }, { name: "id", value: `${item.AssetId}`, inline: true },
{ name: "price", value: `${is_offsale ? "offsale" : item.PriceInRobux}`, inline: true }, { name: "price", value: `${is_offsale ? "offsale" : item.PriceInRobux}`, inline: true },
{ name: "limited", value: `${item.IsLimited}`, inline: true }, { name: "limited", value: `${limited_string}`, inline: true },
{ name: "rap", value: `${item.IsLimited ? resale_data.recentAveragePrice : "0"}`, inline: true }, { name: "rap", value: `${is_limited_at_all ? resale_data.recentAveragePrice : "0"}`, inline: true },
{ name: "creator", value: `${item.Creator.Name}`, inline: true }, { name: "creator", value: `${item.Creator.Name}`, inline: true },
], ],
thumbnail: { thumbnail: {