Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Discord.js v12 make Rainbow Role

I want to make a rainbow role(changes all 60seconds the color).
Is this possible?
I have a general understanding of discord.js.

Thanks allot dor trying to help.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I created a tutorial in german on YouTube. If you understand german and want to exectly understand what the code does, check it out here!

Here is a basic code for a rainbow role, you need to adjust some things to work for you.

client.on('ready' , async() =>{
    const guild = client.guilds.cache.get('///Your guild ID');
    colors = ['///Enter a list of hex codes here'];
    var role = guild.roles.cache.get('///Your Rainbow Role ID here!')
    setInterval(() => {
        const roleCount = guild.roles.cache.get(role).members.size;
        if(roleCount >= 1){
        var random = Math.floor(Math.random() * colors.length);
        role.edit({
        color: colors[random]
        })
        console.log('Rainbow Color changed, it is now: ' + colors[random])
        }
        else{
        console.log('No user with rainbow role')
        }
                
    }, 600*1000)
}

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading