Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const botPrefix = tempVars('botPrefix');
- var reactionArray = [];
- var rectarray = globalVars('reactionRoleInf');
- const _this = this;
- var tempRole;
- var emojiArray = [];
- var roleArray = [];
- msg.channel.send(`Welcome to the autrole promt.\nPlease now mention/name a role (case sensitive) along with an emoji.\nEx. @role/role ✅`)
- .then((message) => {
- msg.channel.awaitMessages(response => response.author.id == msg.author.id, {
- max: 1,
- time: 60000,
- errors: ['time'],
- })
- .then(async function(collected) {
- msg.author.lastMessage.delete();
- if (collected.first().content.split(/ +/g).length > 1) {
- if (collected.first().content.split(/ +/g)[0] != null) {
- const tstValidRole = await msg.guild.roles.find(role => role.name === collected.first().content.split(/ +/g)[0]);
- if (collected.first().mentions.roles.first() || tstValidRole != null) {
- var unicodeStored = collected.first().content.split(/ +/g)[1];
- var roleMentioned;
- if (collected.first().mentions.roles.first() != null) {
- roleMentioned = collected.first().mentions.roles.first();
- } else {
- roleMentioned = tstValidRole;
- }
- if (unicodeStored.charCodeAt(0 > 127)) {
- reactionArray.push([unicodeStored, roleMentioned.id, roleMentioned.name]);
- emojiArray.push(unicodeStored);
- roleArray.push(roleMentioned.id);
- message.edit(`You have attached the role **${roleMentioned.name}** to the reaction ${unicodeStored}.\nIf this is correct, please respond "confirm".\nIf not, please respond "cancel" to cancel the prompt.`);
- msg.channel.awaitMessages(response => response.author.id == msg.author.id, {
- max: 1,
- time: 60000,
- errors: ['time'],
- })
- .then((collected) => {
- msg.author.lastMessage.delete();
- if (collected.first().content.toLowerCase() == "confirm") {
- reAsk(message)
- } else if (collected.first().content.toLowerCase() == "cancel") {
- message.delete();
- msg.channel.send("Prompt has been cancelled.\nPlease re-execute the command to go through the prompt again!");
- } else {
- message.delete();
- msg.channel.send("Prompt has been cancelled, you didn't provide a valid response!\nPlease re-execute the command to go through the prompt again!");
- }
- }).catch(() => {
- message.delete();
- msg.channel.send('Sorry, you didnt provide a valid response in time!\nPlease re-execute the command to go through the prompt again!');
- });
- } else {
- message.delete();
- msg.channel.send("Prompt has been cancelled, you didn't provide a valid emoji!\nPlease re-execute the command to go through the prompt again!");
- }
- } else {
- message.delete();
- msg.channel.send("Prompt has been cancelled, you didn't provide a valid response!\nPlease re-execute the command to go through the prompt again!");
- }
- } else {
- message.delete();
- msg.channel.send("Prompt has been cancelled, you didn't provide a valid mentioned role!\nPlease re-execute the command to go through the prompt again!");
- }
- } else {
- message.delete();
- msg.channel.send("Prompt has been cancelled, you didn't provide a emoji/mentioned role!\nPlease re-execute the command to go through the prompt again!");
- }
- }).catch((error) => {
- console.log(error);
- message.delete();
- msg.channel.send('Sorry, you didnt provide a valid response in time!\nPlease re-execute the command to go through the prompt again!');
- });
- })
- function reAsk(message) {
- if (reactionArray.length != 10) {
- var finalText = "";
- reactionArray.forEach(subarray => {
- finalText = finalText + `${subarray[0]} => ${subarray[2]}\n`
- })
- message.edit(`So far you have the following connections (Max 10)\n ${finalText}\n\nIf you would like to attach another reaction to a role, please insert a role along with an emoji.\nIf not, please reply with "done".\nIf you would like to cancel the prompt, please respond with "cancel"`);
- msg.channel.awaitMessages(response => response.author.id == msg.author.id, {
- max: 1,
- time: 60000,
- errors: ['time'],
- })
- .then(async function(collected) {
- msg.author.lastMessage.delete();
- if (collected.first().content.toLowerCase() == "done") {
- done(message)
- } else if (collected.first().mentions.roles.first() == "cancel") {
- message.delete();
- msg.channel.send("Prompt has been cancelled.\nPlease re-execute the command to go through the prompt again!");
- } else {
- if (collected.first().content.split(/ +/g).length > 1) {
- const tstValidRole = await msg.guild.roles.find(role => role.name === collected.first().content.split(/ +/g)[0]);
- if (collected.first().mentions.roles.first() || tstValidRole != null) {
- var unicodeStored = collected.first().content.split(/ +/g)[1];
- if (collected.first().mentions.roles.first() != null) {
- roleMentioned = collected.first().mentions.roles.first();
- } else {
- roleMentioned = tstValidRole;
- }
- if (unicodeStored != null) {
- if (!emojiArray.includes(unicodeStored)) {
- if (!roleArray.includes(roleMentioned.id)) {
- if (unicodeStored.charCodeAt(0 > 127)) {
- reactionArray.push([unicodeStored, roleMentioned.id, roleMentioned.name]);
- emojiArray.push(unicodeStored);
- roleArray.push(roleMentioned.id);
- reAsk(message)
- } else {
- message.delete();
- msg.channel.send("Prompt has been cancelled, you used the same emoji twice for differnt roles!\nPlease re-execute the command to go through the prompt again!");
- }
- } else {
- message.delete();
- msg.channel.send("Prompt has been cancelled, you used the same role twice in the prompt!\nPlease re-execute the command to go through the prompt again!");
- }
- } else {
- message.delete();
- msg.channel.send("Prompt has been cancelled, you didn't provide a valid emoji!\nPlease re-execute the command to go through the prompt again!");
- }
- }
- } else {
- message.delete();
- msg.channel.send("Prompt has been cancelled, you didn't mention a valid role!\nPlease re-execute the command to go through the prompt again!");
- }
- } else {
- message.delete();
- msg.channel.send("Prompt has been cancelled, you didn't provide a emoji/mentioned role!\nPlease re-execute the command to go through the prompt again!");
- }
- }
- }).catch(() => {
- message.delete();
- msg.channel.send('Sorry, you didnt provide a valid response in time!\nPlease re-execute the command to go through the prompt again!');
- });
- } else {
- done(message);
- }
- }
- function done(message) {
- var finalText = "";
- reactionArray.forEach(subarray => {
- finalText = finalText + `${subarray[0]} => ${subarray[2]}\n`
- })
- message.edit(`Final conformation menu\n\nBelow is the list of reactions to their roles\n${finalText}\n\nIf this is correct, please respond with a mention to a text channel where the role menu will be sent.\nIf this isn't correct, respond with "cancel" to cancel the prompt.`)
- msg.channel.awaitMessages(response => response.author.id == msg.author.id, {
- max: 1,
- time: 60000,
- errors: ['time'],
- })
- .then((collected) => {
- msg.author.lastMessage.delete();
- if (collected.first().mentions.channels.first()) {
- var menchannel = collected.first().mentions.channels.first()
- message.delete();
- menchannel.send({
- embed: {
- color: 0xffff00,
- title: "Wybierz Swoją Płeć",
- description: `Użyj reakcji przypisanej do podanej roli aby otrzymąć daną rolę.\n${finalText}`,
- timestamp: new Date()
- }
- })
- .then(embedmessage => {
- reactionArray.forEach(async function(subarray) {
- await embedmessage.react(subarray[0])
- })
- rectarray.push({
- [embedmessage.id]: reactionArray
- })
- _this.storeValue(rectarray, 3, "reactionRoleInf", cache);
- _this.callNextAction(cache);
- })
- } else if (collected.first().content == "cancel") {
- message.delete();
- msg.channel.send("Prompt has been cancelled.\nPlease re-execute the command to go through the prompt again!");
- } else {
- message.delete();
- msg.channel.send("Prompt has been cancelled, you didn't provide a valid response!\nPlease re-execute the command to go through the prompt again!");
- }
- }).catch(() => {
- message.delete();
- msg.channel.send('Sorry, you didnt provide a valid response in time!\nPlease re-execute the command to go through the prompt again!');
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement