Replies: 2 comments
-
If you are meaning to change Presence informations repeatedly, you will need to use setInterval, and one variable to count. For example: client.on('ready', async () => {
const r = new Discord.RichPresence()
.setApplicationId('XXX')
.setType('LISTENING')
.setURL('https://youtube.com/watch?v=dQw4w9WgXcQ')
.setName('Name1')
.setStartTimestamp(Date.now())
.setEndTimestamp(Date.now() + 1_000 * (2 * 60 + 56)) // Song length = 2m56s
.setAssetsLargeImage('XXX')
.setAssetsLargeText('Youtube123')
.setAssetsSmallImage('XXXX')
.setAssetsSmallText('Bot123')
.addButton('name', 'https://link.com/')
.setDetails('Details first time run')
.setState('State first time run');
client.user.presence.set(r);
const repeatTime = 15_000; // 15 seconds.
let count = 1;
setInterval(() => {
if (count == 1) {
r
.setDetails('Details 1')
.setState('State 1');
} else if (count == 2) {
r
.setDetails('Details 2')
.setState('State 2');
} else {
r
.setDetails('Details first time run')
.setState('State first time run');
count = 0;
}
client.user.presence.set(r);
count++;
}, repeatTime);
}); |
Beta Was this translation helpful? Give feedback.
0 replies
-
const net = require('net');
const Discord = require('discord.js-selfbot-v13');
const rpc = new Discord.RichPresence();
try {
client.on('ready', () => {
console.log('Discord RPC connected!');
const server = net.createServer((socket) => {
console.log('Client connected');
// Обработчик события получения данных от клиента
socket.on('data', async (data) => {
function seconds2time (seconds) {
let date = new Date(seconds * 1000);
let hh = date.getUTCHours();
let mm = date.getUTCMinutes();
let ss = date.getSeconds();
// If you were building a timestamp instead of a duration, you would uncomment the following line to get 12-hour (not 24) time
// if (hh > 12) {hh = hh % 12;}
// These lines ensure you have two-digits
if (hh < 10) {hh = "0"+hh;}
if (mm < 10) {mm = "0"+mm;}
if (ss < 10) {ss = "0"+ss;}
// This formats your string to HH:MM:SS
let t = mm+":"+ss;
return t;
}
const text = data.toString('utf8');
if (text.includes('ClearRPC')) {
client.user.setActivity(null);
} else {
let music = text.split('|');
//console.log(music);
const track = JSON.parse(music[1]);
const tprogress = JSON.parse(music[0]);
let title = "Неизвестный";
if (track.title) {
title = track.title;
}
let cover = "yamusiclogo";
if (track.cover) {
cover = "https://" + track.cover.replace("%%", "200x200");
}
const artistTitles = track.artists.map(artist => artist.title);
console.log(seconds2time(tprogress.position) + " / " + seconds2time(tprogress.duration));
const artistTitlesString = artistTitles.join(',');
const imageSet = await Discord.RichPresence.getExternal(client, '848835233767751680', cover, "https://i.ibb.co/Z8jBpXk/pngegg.png");
rpc
.setApplicationId('817229550684471297')
.setType('LISTENING')
.setURL('https://youtube.com/watch?v=dQw4w9WgXcQ')
.setName('🎶YaMusic🎶')
.setDetails(artistTitlesString + "-" + title)
.addButton('Слушать', 'https://music.yandex.ru' + track.link)
.setAssetsLargeImage(imageSet[0].external_asset_path)
.setAssetsSmallImage(imageSet[1].external_asset_path)
.setStartTimestamp(Date.now())
.setEndTimestamp(Date.now() + (2 * 60 + 56)) // Song length = 2m56s
client.user.setActivity(rpc);
if(client.user.presence !=null){
}
}
});
// Обработчик события отключения клиента
socket.on('end', () => {
client.user.setActivity(null);
console.log('Client disconnected');
// Закрытие сервера
server.close(() => {
console.log('Server closed');
process.exit(0);
});
});
});
// Сервер прослушивает порт 8080 на всех доступных сетевых интерфейсах
server.listen(8800, '0.0.0.0', () => {
console.log('Server started');
});
});
client.login(token)
.catch(console.error);
} catch (err) {
console.error('Ошибка:', err.message);
} Here is an example of my code, yes it is bad, but still, I need to update data in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have such a code, it works through a socket (data comes to the socket) how can I update the information? Basically the question is about setState, setDetails
Beta Was this translation helpful? Give feedback.
All reactions