Skip to content

Commit

Permalink
Added buttons options
Browse files Browse the repository at this point in the history
  • Loading branch information
Prits001 committed Jul 10, 2022
1 parent c78e263 commit 1db1116
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 4 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This project was created only for good purposes and personal use.
- Unzip archive

#### Please set your informations in the config.json file!
#### Remember that the line has to be at least 2 characters long!
#### Remember that the lines has to be at least 2 characters long!
```json
{
"clientId":"", #application id of a bot(already set in releases/source code)
Expand All @@ -24,7 +24,17 @@ This project was created only for good purposes and personal use.

"additionalinfo":"Bottom text", #second line in rich presence

"largeimagetext":":)" #text when hovering above icon
"largeimagetext":":)", #text when hovering above icon


"numberOfButtons":2, #number of buttons shown(0-2)
#button one name and url
"button1Text":"Button One",
"button1Link":"https://github.com/Prits001",
#button two name and url
"button2Text":"Button Two",
"button2Link":"https://github.com/Prits001"

}
```
## How to run
Expand Down
12 changes: 11 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,15 @@

"additionalinfo":"Bottom text",

"largeimagetext":":)"
"largeimagetext":":)",


"numberOfButtons":2,

"button1Text":"Button One",
"button1Link":"https://github.com/Prits001",

"button2Text":"Button Two",
"button2Link":"https://github.com/Prits001"

}
53 changes: 52 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ function checkConfig(){
console.log('\x1b[36m%s\x1b[0m',"[#]", "Drawing name: ", "\x1b[32m"+config.drawingname+"\x1b[0m")
console.log('\x1b[36m%s\x1b[0m',"[#]", "Additional info: ", "\x1b[32m"+config.additionalinfo+"\x1b[0m")
console.log('\x1b[36m%s\x1b[0m',"[#]", "Text when hovering above large image icon: ","\x1b[32m"+config.largeimagetext+"\x1b[0m")
console.log('\x1b[36m%s\x1b[0m',"[#]", "Ammount of buttons: ","\x1b[32m"+config.numberOfButtons+"\x1b[0m")
if(config.numberOfButtons > 0){
console.log('\x1b[36m%s\x1b[0m',"[#]", "Name of the 1st button: ","\x1b[32m"+config.button1Text+"\x1b[0m")
console.log('\x1b[36m%s\x1b[0m',"[#]", "Url of the 1st button: ","\x1b[32m"+config.button1Link+"\x1b[0m")
if(config.numberOfButtons === 2){
console.log('\x1b[36m%s\x1b[0m',"[#]", "Name of the 2nd button: ","\x1b[32m"+config.button2Text+"\x1b[0m")
console.log('\x1b[36m%s\x1b[0m',"[#]", "Url of the 2nd button: ","\x1b[32m"+config.button2Link+"\x1b[0m")
}
}
if(config.numberOfButtons < 0 || config.numberOfButtons > 2){console.log(`\x1b[31mYou can't have ${config.numberOfButtons} buttons! Please abort and fix the issue!\x1b[0m`)}
console.log("Starting in 10 seconds..")
console.log("\x1b[46mPress Ctrl+C to abort\x1b[0m")
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 10000);
Expand All @@ -35,6 +45,7 @@ function start(){

async function setActivity() {
if (!Api) return;
if(config.numberOfButtons === 0){
Api.setActivity({
details: config.drawingname,
state: config.additionalinfo,
Expand All @@ -44,7 +55,47 @@ async function setActivity() {
smallImageKey: 'pfp',
smallImageText: "Made by Prits#2138",
instance: false,
});
});}
if(config.numberOfButtons === 1){
Api.setActivity({
details: config.drawingname,
state: config.additionalinfo,
startTimestamp: Date.now(),
largeImageKey: 'icon',
largeImageText: config.largeimagetext,
smallImageKey: 'pfp',
smallImageText: "Made by Prits#2138",
instance: false,
buttons: [
{
label: config.button1Text,
url: config.button1Link
}
]
})
}
if(config.numberOfButtons === 2){
Api.setActivity({
details: config.drawingname,
state: config.additionalinfo,
startTimestamp: Date.now(),
largeImageKey: 'icon',
largeImageText: config.largeimagetext,
smallImageKey: 'pfp',
smallImageText: "Made by Prits#2138",
instance: false,
buttons: [
{
label: config.button1Text,
url: config.button1Link
},
{
label: config.button2Text,
url: config.button2Link
}
]
})
}
};
start()
Api.on('ready', async () => {
Expand Down

0 comments on commit 1db1116

Please sign in to comment.