Last active
July 4, 2021 19:26
-
-
Save iAtog/dea9a7e7f25badb8f72c2895edaa59d5 to your computer and use it in GitHub Desktop.
Create discord rich presences with buttons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"details": "Wow step-brother", | |
"state": "Liquid", | |
"small_image": "discord", | |
"small_text": "Discord!", | |
"large_image": "uhoh", | |
"large_text": "text", | |
"buttons": { | |
"one": ["Button 1", "https://google.com/"], | |
"two": ["Button 2", "https://google.com/"] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rpc = require("discord-rpc"); | |
const clientId = "id"; | |
const clientSecret = "secret"; | |
const config = require("./config.json"); | |
rpc.register(clientId); | |
const presence = new rpc.Client({ transport: 'ipc' }); | |
presence.on("ready", () => { | |
presence.request('SET_ACTIVITY', { | |
pid: process.pid, | |
activity: { | |
details: config.details, | |
state: config.state, | |
timestamps: { | |
start: Date.now() | |
}, | |
assets: { | |
large_image: config.large_image, | |
large_text: config.large_text, | |
small_image: config.small_image, | |
small_text: config.small_text | |
}, | |
buttons: [ | |
{ label: config.buttons.one[0], url: config.buttons.one[1] }, | |
{ label: config.buttons.two[0], url: config.buttons.two[1] } | |
] | |
} | |
}); | |
}) | |
presence.login({ clientId, clientSecret }).then(() => { | |
console.log("Connected!"); | |
}).catch(err => { | |
console.log("Error:"); | |
console.error(err); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment