Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
barbarbar338 authored May 18, 2020
1 parent c145b9c commit cacdb85
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Discord ReactionRole System
<p>This module is compatible with all node.js discord modules (like discord.js, eris, discord.js-commando etc.)</p>
<p>You also don't need to write any bot code if you want! You can also use this module alone. You just need a Discord Bot Token!</p>

<b>[Discord: https://discord.com/invite/BjEJFwh](https://discord.com/invite/BjEJFwh)</b>
-------

<b>[NPM Page](https://www.npmjs.com/package/reaction-role)</b>
-------

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reaction-role",
"version": "1.6.3",
"version": "1.6.4",
"description": "ReactionRole is a module that allows you to create Discord reaction role easily! It also has several functions for you to use.",
"main": "reactionRole.js",
"scripts": {
Expand Down
24 changes: 12 additions & 12 deletions reactionRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ class ReactionRole {
if (typeof client == "string") {
this.client = new Discord.Client();
this.client.login(client).catch(err => {
throw new Error("[ReactionRole] Please specify a VALID Bot token");
throw new Error("[ReactionRole] Please specify a VALID Bot token" + " \n\nFOR MORE ADVANCED HELP: https://discord.com/invite/BjEJFwh");
})
} else if (typeof client == "object") {
this.client = client;
} else {
throw new Error("[ReactionRole] Please specify a Discord.js Client or Bot Token");
throw new Error("[ReactionRole] Please specify a Discord.js Client or Bot Token" + " \n\nFOR MORE ADVANCED HELP: https://discord.com/invite/BjEJFwh");
}
}
reInit() {
Expand All @@ -25,20 +25,20 @@ class ReactionRole {
var debug_count_messagesFetched = 0;
for (var { channel, message: message_id, reactions } of this.config) {
var message = await this.client.channels.cache.get(channel).messages.fetch(message_id)
.catch(error => {throw new Error("[ReactionRole] " + error)});
.catch(error => {throw new Error("[ReactionRole] " + error + " \n\nFOR MORE ADVANCED HELP: https://discord.com/invite/BjEJFwh")});
if (!message) continue;
debug_count_messagesFetched += 1;
for (var {emoji} of reactions) {
emoji = this.cleanEmojiDiscriminator(emoji);
var messageReaction = message.reactions.cache.get(emoji);
if (!messageReaction) {
await message.react(emoji)
.catch(error => {throw new Error("[ReactionRole] " + error)});
.catch(error => {throw new Error("[ReactionRole] " + error + " \n\nFOR MORE ADVANCED HELP: https://discord.com/invite/BjEJFwh")});
} else {
if (!messageReaction.me) {
messageReaction.fetchUsers();
await message.react(emoji)
.catch(error => {throw new Error("[ReactionRole] " + error)});
.catch(error => {throw new Error("[ReactionRole] " + error + " \n\nFOR MORE ADVANCED HELP: https://discord.com/invite/BjEJFwh")});
}
}
}
Expand All @@ -54,20 +54,20 @@ class ReactionRole {
var debug_count_messagesFetched = 0;
for (var { channel, message: message_id, reactions } of this.config) {
var message = await this.client.channels.cache.get(channel).messages.fetch(message_id)
.catch(error => {throw new Error("[ReactionRole] " + error)});
.catch(error => {throw new Error("[ReactionRole] " + error + " \n\nFOR MORE ADVANCED HELP: https://discord.com/invite/BjEJFwh")});
if (!message) continue;
debug_count_messagesFetched += 1;
for (var {emoji} of reactions) {
emoji = this.cleanEmojiDiscriminator(emoji);
var messageReaction = message.reactions.cache.get(emoji);
if (!messageReaction) {
await message.react(emoji)
.catch(error => {throw new Error("[ReactionRole] " + error)});
.catch(error => {throw new Error("[ReactionRole] " + error + " \n\nFOR MORE ADVANCED HELP: https://discord.com/invite/BjEJFwh")});
} else {
if (!messageReaction.me) {
messageReaction.fetchUsers();
await message.react(emoji)
.catch(error => {throw new Error("[ReactionRole] " + error)});
.catch(error => {throw new Error("[ReactionRole] " + error + " \n\nFOR MORE ADVANCED HELP: https://discord.com/invite/BjEJFwh")});
}
}
}
Expand Down Expand Up @@ -97,7 +97,7 @@ class ReactionRole {
}
rolesNew.push.apply(rolesNew, rolesWhitelist);
await member.roles.add(rolesNew)
.catch(error => {throw new Error("[ReactionRole] " + error);});
.catch(error => {throw new Error("[ReactionRole] " + error + " \n\nFOR MORE ADVANCED HELP: https://discord.com/invite/BjEJFwh");});
}
})();
});
Expand All @@ -122,7 +122,7 @@ class ReactionRole {
(member.roles.cache.get(role))
);
await member.roles.remove(rolesToRemove)
.catch(error => {throw new Error("[ReactionRole] " + error)});
.catch(error => {throw new Error("[ReactionRole] " + error + " \n\nFOR MORE ADVANCED HELP: https://discord.com/invite/BjEJFwh")});
}
})();
});
Expand Down Expand Up @@ -248,14 +248,14 @@ class ReactionRole {
});
}
createWebhook(webhook_url) {
if (!webhook_url.includes("discordapp") || !webhook_url.includes("api") || !webhook_url.includes("webhooks")) throw new Error("[ReactionRole] Please specify a valid Discord Webhook URL");
if (!webhook_url.includes("discordapp") || !webhook_url.includes("api") || !webhook_url.includes("webhooks")) throw new Error("[ReactionRole] Please specify a valid Discord Webhook URL" + " \n\nFOR MORE ADVANCED HELP: https://discord.com/invite/BjEJFwh");
webhook_url = webhook_url.split("/");
const hook = new Discord.WebhookClient(webhook_url[5], webhook_url[6]);
hook.auth = true;
return hook;
}
intervalMessage(webhook, time, message) {
if (!webhook.auth) throw new Error("[ReactionRole] Please use a ReactionRole Webhook");
if (!webhook.auth) throw new Error("[ReactionRole] Please use a ReactionRole Webhook" + " \n\nFOR MORE ADVANCED HELP: https://discord.com/invite/BjEJFwh");
setInterval(() => {
webhook.send(message)
}, time);
Expand Down

0 comments on commit cacdb85

Please sign in to comment.