-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
137 lines (114 loc) · 4.3 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
const Discord = require("discord.js");
const client = new Discord.Client();
const config = require("./config.json");
client.on("ready", () => {
console.log(`Bot has started.`);
client.user.setActivity(`RGBhelp | RGBifing ${client.guilds.size} servers`);
});
client.on("message", async message => {
if(message.author.bot) return;
if(message.content.toUpperCase().indexOf(config.prefix) !== 0) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if(message.author.id != message.guild.ownerID) {
message.reply("This bot can only be used by the server owner.")
return;
}
if (command === "help") {
const Embed = new Discord.RichEmbed()
.setTitle("Command help")
.addField("`" + config.prefix + 'addRoles <name> <amount>`', 'Add <amount> of roles in rainbow, called "<name> <count>". Add "true" to the end to seperate the roles in the user list.')
.addField("`" + config.prefix + 'removeRoles <name> <amount>`', 'Remove <amount> of roles , called "<name> <count>"')
.addField("`" + config.prefix + 'invite`', 'Get an invite link for me!')
.setFooter('All <amounts> are limited to 100. | Bot made by Xeyame#7391')
.setColor("#fffa00")
await message.channel.send({ embed: Embed });
}
if (command === "invite") {
const Embed = new Discord.RichEmbed()
.addField("Add me", "https://discordapp.com/api/oauth2/authorize?client_id=" + config.client_id + "&permissions=8&scope=bot", true)
.setColor("#fffa00")
await message.channel.send({ embed: Embed });
}
if (command === "addroles") {
if (typeof args[0] != 'string') {
message.reply("Usage: `" + config.prefix + 'addRoles <name> <amount>`');
return
}
var amount = Number(args[1]);
if (amount > 100) {
message.reply("Invalid amount.");
return
}
if (amount < 5) {
message.reply("Invalid amount.");
return
}
message.reply("Adding " + args[1] + " roles named " + args[0] + " <count>")
var hsl = require('hsl-to-rgb-for-reals')
const rgbHex = require('rgb-hex');
var count;
var multiplier = 360 / amount;
//add from last to first so its ordered correctly
for (var count=amount;count >= 1;count--) {
var step = count * multiplier - 1;
var color = "#" + rgbHex(hsl(step, 1, 0.5).toString())
if (message.guild.roles.find('name', args[0] + " " + count)) {
message.reply("Role `" + args[0] + " " + count + "` Already found.")
return
}
if (args[2]) {
message.guild.createRole({
name: args[0] + " " + count,
color: color,
hoist: true,
})
} else {
message.guild.createRole({
name: args[0] + " " + count,
color: color,
})
}
const addColorEmbed = new Discord.RichEmbed()
.setTitle("Added role")
.setColor(color)
.setDescription(args[0] + " " + count)
await message.channel.send({ embed: addColorEmbed });
}
}
if (command === "removeroles") {
if (typeof args[0] != 'string') {
message.reply("Usage: `" + config.prefix + 'removeRoles <name> <amount>`');
return
}
var amount = Number(args[1]);
if (amount > 100) {
message.reply("Invalid amount.");
return
}
if (amount < 5) {
message.reply("Invalid amount.");
return
}
message.reply("Removing " + args[1] + " roles named " + args[0] + " <count>")
var hsl = require('hsl-to-rgb-for-reals')
const rgbHex = require('rgb-hex');
var count;
var multiplier = 360 / amount;
for (var count=amount;count >= 1;count--) {
var step = count * multiplier - 1;
var color = "#" + rgbHex(hsl(step, 1, 0.5).toString())
if (message.guild.roles.find('name', args[0] + " " + count)) {
message.guild.roles.find('name', args[0] + " " + count).delete()
const removeColorEmbed = new Discord.RichEmbed()
.setTitle("Deleted role")
.setColor(color)
.setDescription(args[0] + " " + count)
await message.channel.send({ embed: removeColorEmbed });
} else {
message.reply("Couldn't find role `" + args[0] + " " + count + "`.")
}
}
}
});
client.login(process.env.rgbbot_token); //export rgbbot_token=TOKEN