ChilledGaming
ChilledGaming
DIAdiscord.js - Imagine an app
Created by ChilledGaming on 10/15/2024 in #djs-questions
How to automatically set status?
As in, when I first setup discord.js, it would make my bots status "online", when the code was running, and "offline" when it wasn't. How can I return to that behavior? (I used client.user.setStatus(PresenceUpdateStatus.Online); once, and it never went offline again).
8 replies
DIAdiscord.js - Imagine an app
Created by ChilledGaming on 10/15/2024 in #djs-questions
How to rename a channel when bot goes offline?
Here is what I did:
function updateChannelName(newChannelName) {
const canal = client.channels.cache.get('1295783100709732352')
if (canal) {
try{
canal.setName(newChannelName)
.then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
.catch(console.error);
return newChannelName
}catch(e){
console.error(e)
return 1
}
}
return 1
}

process.on('SIGINT', async () => {
console.log('exit')
try{
await updateChannelName('❌┃Servidor Offline');
} catch(e){
console.error(e)
}finally{
process.exit(0);
}
});

function updateChannelName(newChannelName) {
const canal = client.channels.cache.get('1295783100709732352')
if (canal) {
try{
canal.setName(newChannelName)
.then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
.catch(console.error);
return newChannelName
}catch(e){
console.error(e)
return 1
}
}
return 1
}

process.on('SIGINT', async () => {
console.log('exit')
try{
await updateChannelName('❌┃Servidor Offline');
} catch(e){
console.error(e)
}finally{
process.exit(0);
}
});

I can see the 'exit' console log, but the channel isn't renamed. Any help is appreciated. npm: 22.9.0 DJS: 14.16.3
6 replies