exports.run = (client, message, args) => {
const setStatus = message.content.split(' ');
if(!message.member.hasPermission("ADMINISTRATOR")){
return message.channel.send("You don't have the permissions to use this command!");
}
else if(setStatus[1] === 'idle'){
client.user.setStatus('idle')
.then(message.channel.send("My status has been set to: "+setStatus[1]))
.catch(console.error);
}
else if(setStatus[1] === 'online'){
client.user.setStatus('online')
.then(message.channel.send("My status has been set to: "+ setStatus[1]))
.catch(console.error);
}
else if(setStatus[1] === 'invisible'){
client.user.setStatus('invisible')
.then(message.channel.send("My status has been set to: "+ setStatus[1]))
.catch(console.error);
}
else if(setStatus[1] === 'dnd'){
client.user.setStatus('invisible')
.then(message.channel.send("My status has been set to: "+ setStatus[1] + "(do not disturb)"))
.catch(console.error);
}
else{
return message.channel.send("I could not set my status please type one of the following status: idle, online, invisible, dnd (do not disturb)");
}
}
The follow code do the same :
exports.run = (client, message) => {
const setStatus = message.content.split(' ')[1]
if(!message.member.hasPermission('ADMINISTRATOR')){
return message.channel.send('You don\'t have the permissions to use this command!')
}
const statusList = ['idle', 'online', 'invisible', 'dnd']
if(!statusList.includes(setStatus)) {
return message.channel.send('I could not set my status please type one of the following status: idle, online, invisible, dnd (do not disturb)')
}
client.user.setStatus(setStatus)
.then(message.channel.send('My status has been set to: '+setStatus))
.catch(console.error)
}
Solution
Check all files one by one and follow for example the instructions of standardjs.
I can do it in my own time if the project maintainers agree.
Hello @6346563751 ,
I checked your solution and the code does the same thing in less lines. You can create a pull request if you want to request those changes.
Problem
This bot is designed to help beginners. However, good practices are not followed.
Look how this code is complicated : (https://github.com/Cramenorn/RaptorSA/blob/master/src/commands/admin/setbotstatus.js)
The follow code do the same :
Solution
Check all files one by one and follow for example the instructions of standardjs. I can do it in my own time if the project maintainers agree.