Get icon of current game from Member object

Hello! I've been working on a project that uses Discord.js to grab the current activity of a Guild Member and display it as an SVG. I've got Custom Statuses and Rich Presence working, but I don't know how to get a URL to the icon of a non-Rich Presence application like Baldur's Gate 3. This is the Activity object associated with it:
Activity {
name: "Baldur's Gate 3",
type: 0,
url: null,
details: null,
state: null,
applicationId: '1137125502985961543',
timestamps: { start: 2024-07-28T23:36:20.761Z, end: null },
party: null,
syncId: null,
assets: null,
flags: ActivityFlagsBitField { bitfield: 0 },
emoji: null,
buttons: [],
createdTimestamp: 1722209793336
}
Activity {
name: "Baldur's Gate 3",
type: 0,
url: null,
details: null,
state: null,
applicationId: '1137125502985961543',
timestamps: { start: 2024-07-28T23:36:20.761Z, end: null },
party: null,
syncId: null,
assets: null,
flags: ActivityFlagsBitField { bitfield: 0 },
emoji: null,
buttons: [],
createdTimestamp: 1722209793336
}
My understanding based on this discussion is that Discord maintains a list of detectable games with associated icon IDs. The URL they reference (https://discord.com/api/v9/applications/detectable) doesn't appear to contain icon data, though because it contains entries for relatively recent games I'm sure it's being updated. Am I overlooking something, is there another solution, or is this just no longer possible?
7 Replies
d.js toolkit
d.js toolkit4mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Tsuni
TsuniOP4mo ago
unfortunately doesn't seem to be available to bots, unless I'm being foolish
{
"message": "Bots cannot use this endpoint",
"code": 20001
}
{
"message": "Bots cannot use this endpoint",
"code": 20001
}
Retro
Retro4mo ago
hi, you can construct the avatar url by using
const app = client.users.fetch(appId) // this will fetch your app
const avatarUrl = app.displayAvatarURL()
const app = client.users.fetch(appId) // this will fetch your app
const avatarUrl = app.displayAvatarURL()
tho this would not be an svg
Tsuni
TsuniOP4mo ago
I have the avatar, banner, custom emoji, and rich presence assets working fine (https://github.com/TetraTsunami/discord-github-preview), but I appreciate the advice :)
Tsuni
TsuniOP4mo ago
I hope this might illustrate my issue. In my profile, I can see the logo for Cookie Clicker when I have cookie clicker open. The image URL according to devtools is https://cdn.discordapp.com/app-icons/1124351789895004280/a0820416954a79e24dfe9d9b7d31369b.webp?size=80&keep_aspect_ratio=false. But the API response for the activity is
Activity {
name: 'Cookie Clicker',
type: 0,
url: null,
details: null,
state: null,
applicationId: '1124351789895004280',
timestamps: { start: 2024-07-30T19:29:39.216Z, end: null },
party: null,
syncId: null,
assets: null,
flags: ActivityFlagsBitField { bitfield: 0 },
emoji: null,
buttons: [],
createdTimestamp: 1722367780370
},
Activity {
name: 'Cookie Clicker',
type: 0,
url: null,
details: null,
state: null,
applicationId: '1124351789895004280',
timestamps: { start: 2024-07-30T19:29:39.216Z, end: null },
party: null,
syncId: null,
assets: null,
flags: ActivityFlagsBitField { bitfield: 0 },
emoji: null,
buttons: [],
createdTimestamp: 1722367780370
},
As you can see, that icon URL is nowhere to be found. The application ID matches, but I don't know how to find "a0820416954a79e24dfe9d9b7d31369b" to construct the full image URL. Format doesn't matter because I'm embedding them anyway.
No description
Tsuni
TsuniOP4mo ago
found a solution from the Discord Developers server (https://discord.com/channels/613425648685547541/1183059417755815956), I need to make a request to https://discord.com/api/v10/applications/<app_id>/rpc and the icon hash is there
Want results from more Discord servers?
Add your server