Last active
September 7, 2022 01:42
-
-
Save iamnotacoder-djs/9214d8ee68300c671ddde34a74414a91 to your computer and use it in GitHub Desktop.
Discord.js@14.0.3 Rainbow-Role Bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Client, GatewayIntentBits } = require('discord.js'), // discord.js@14.0.3 | |
client = new Client({ intents: [ GatewayIntentBits.Guilds ] }); | |
client.login("your bot token") | |
.then(() => { | |
timeout1h(); | |
}); | |
async function timeout1h() { | |
setTimeout(timeout1h, 1000 * 60 * 60); | |
client.guilds.fetch("any guild_id") | |
.then(async (guild) => { | |
const role = await guild.roles.fetch("any role_id"); | |
role.setColor("#FFFFFF") | |
}).catch(console.log); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Client, GatewayIntentBits } = require('discord.js'), // discord.js@14.0.3 | |
client = new Client({ intents: [ GatewayIntentBits.Guilds ] }); | |
let colors = ["#E93237", "#FE7A18", "#FFF21F", "#48C90A", "#4AD9F8", "#4C63FF", "#771CBF"]; | |
client.login("your bot token") | |
.then(() => { | |
const colors_count = 7; | |
colors = new Array(colors_count); | |
for (let i = 0; i < colors_count; i++ ) { | |
const red = sin_to_hex(i, 0 * Math.PI * 2/3); // 0 deg | |
const blue = sin_to_hex(i, 1 * Math.PI * 2/3); // 120 deg | |
const green = sin_to_hex(i, 2 * Math.PI * 2/3); // 240 deg | |
colors[i] = `#${red}${green}${blue}`; | |
} | |
timeout1h(); | |
}); | |
function sin_to_hex(i, phase) { | |
const sin = Math.sin(Math.PI / colors.length * 2 * i + phase); | |
const int = Math.floor(sin * 127) + 128; | |
const hex = int.toString(16); | |
return hex.length === 1 ? `0${hex}`: hex; | |
} | |
async function timeout1h() { | |
setTimeout(timeout1h, 1000 * 60 * 60); | |
client.guilds.fetch("any guild_id") | |
.then(async (guild) => { | |
const role = await guild.roles.fetch("any role_id"); | |
role.setColor("#FFFFFF") | |
}).catch(console.log); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Client, GatewayIntentBits } = require('discord.js'), // discord.js@14.0.3 | |
client = new Client({ intents: [ GatewayIntentBits.Guilds ] }); | |
let colors = ["#E93237", "#FE7A18", "#FFF21F", "#48C90A", "#4AD9F8", "#4C63FF", "#771CBF"]; | |
let color_index = -1; | |
client.login("your bot token") | |
.then(() => { | |
const colors_count = 7; | |
colors = new Array(colors_count); | |
for (let i = 0; i < colors_count; i++ ) { | |
const red = sin_to_hex(i, 0 * Math.PI * 2/3); // 0 deg | |
const blue = sin_to_hex(i, 1 * Math.PI * 2/3); // 120 deg | |
const green = sin_to_hex(i, 2 * Math.PI * 2/3); // 240 deg | |
colors[i] = `#${red}${green}${blue}`; | |
} | |
timeout1h(); | |
}); | |
function sin_to_hex(i, phase) { | |
const sin = Math.sin(Math.PI / colors.length * 2 * i + phase); | |
const int = Math.floor(sin * 127) + 128; | |
const hex = int.toString(16); | |
return hex.length === 1 ? `0${hex}`: hex; | |
} | |
async function timeout1h() { | |
setTimeout(timeout1h, 1000 * 60 * 60); | |
client.guilds.fetch("any guild_id") | |
.then(async (guild) => { | |
const role = await guild.roles.fetch("any role_id"); | |
role.setColor(colors[color_index]); | |
color_index = color_index + 1 == colors.length ? 0: color_index++; | |
}).catch(console.log); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment