-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Arisamiga/RoleViewer
Second Branch merge to Master
- Loading branch information
Showing
7 changed files
with
109 additions
and
353 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,111 @@ | ||
const Jsonfile = require('../config.json'); | ||
exports.run = async (client, message, args) => { | ||
if (message.author.id !== Jsonfile.owner) return message.channel.send("Sorry but you cant use this command D:").then((msg) => { | ||
exports.run = async (client, message) => { | ||
if (message.author.id !== Jsonfile.owner) return message.channel.send("Sorry but you cant use this command D:").then((msg) => { | ||
setTimeout(() => msg.delete(), 7000); | ||
}) | ||
const signup = await message.channel.send({embed: { | ||
color: Jsonfile.signup_color, | ||
fields: [{ | ||
name: Jsonfile.signup_title, | ||
value: "To create a ticket react with 📩" | ||
} | ||
], | ||
timestamp: new Date(), | ||
footer: { | ||
icon_url: client.user.avatarURL() | ||
}) | ||
const signupEmbed = { | ||
color: Jsonfile.signup_color, | ||
fields: [{ | ||
name: Jsonfile.signup_title, | ||
value: "To create a ticket react with 📩" | ||
}], | ||
footer: { | ||
icon_url: client.user.avatarURL() | ||
} | ||
} | ||
const signup = await message.channel.send({ | ||
embeds: [signupEmbed] | ||
}); | ||
await signup.react("📩") | ||
const collector = signup.createReactionCollector( | ||
(reaction, user) => message.guild.members.cache.find((member) => member.id === user.id), { | ||
dispose: true | ||
} | ||
); | ||
collector.on("collect", (reaction, user) => { | ||
if (user.bot) return; | ||
switch (reaction.emoji.name) { | ||
case "📩": | ||
let channelname = `ticket-${user.username}-${user.discriminator}` | ||
channelname = channelname.replace(/\s/g, '-').toLowerCase() | ||
if (message.guild.channels.cache.find(channel => channel.name === channelname) && Jsonfile.one_app) { | ||
user.send(`You already have an ongoing ticket.`).catch(console.error); | ||
reaction.users.remove(user.id) | ||
return; | ||
} else { | ||
contining(user) | ||
reaction.users.remove(user.id) | ||
} | ||
} | ||
break; | ||
} | ||
}) | ||
async function contining(user) { | ||
const channel = await message.guild.channels.create(`ticket: ${user.username + "-" + user.discriminator}`); | ||
|
||
channel.permissionOverwrites.edit(message.guild.id, { | ||
"SEND_MESSAGES": false, | ||
"VIEW_CHANNEL": false, | ||
}); | ||
await signup.react("📩") | ||
const collector = signup.createReactionCollector( | ||
(reaction, user) => message.guild.members.cache.find((member) => member.id === user.id), | ||
{ dispose: true } | ||
); | ||
collector.on("collect", (reaction, user) => { | ||
switch (reaction.emoji.name) { | ||
case "📩": | ||
contining(user) | ||
break; | ||
} | ||
channel.permissionOverwrites.edit(user.id, { | ||
"SEND_MESSAGES": true, | ||
"VIEW_CHANNEL": true, | ||
}); | ||
channel.permissionOverwrites.edit(Jsonfile.Channelrole, { | ||
"SEND_MESSAGES": true, | ||
"VIEW_CHANNEL": true, | ||
}) | ||
async function contining(user){ | ||
const channel = await message.guild.channels.create(`ticket: ${user.username + "-" + user.discriminator}`); | ||
|
||
channel.updateOverwrite(message.guild.id, { | ||
"SEND_MESSAGE": false, | ||
"VIEW_CHANNEL": false, | ||
}); | ||
channel.updateOverwrite(user.id, { | ||
"SEND_MESSAGE": true, | ||
"VIEW_CHANNEL": true, | ||
}); | ||
|
||
const reactionMessage = await channel.send({embed: { | ||
color: Jsonfile.answer_color, | ||
fields: [{ | ||
name: Jsonfile.answer_title, | ||
value: Jsonfile.answer_description | ||
} | ||
], | ||
timestamp: new Date(), | ||
footer: { | ||
icon_url: client.user.avatarURL() | ||
} | ||
} | ||
}) | ||
await reactionMessage.react("🔒"); | ||
await reactionMessage.react("⛔"); | ||
const reactionMessageEmbed = { | ||
color: Jsonfile.answer_color, | ||
fields: [{ | ||
name: Jsonfile.answer_title, | ||
value: Jsonfile.answer_description | ||
}], | ||
footer: { | ||
icon_url: client.user.avatarURL() | ||
} | ||
} | ||
const reactionMessage = await channel.send({ | ||
embeds: [reactionMessageEmbed] | ||
}) | ||
await reactionMessage.react("🔒"); | ||
await reactionMessage.react("⛔"); | ||
|
||
const collector = reactionMessage.createReactionCollector( | ||
(reaction, user) => message.guild.members.cache.find((member) => member.id === user.id).hasPermission("ADMINISTRATOR"), | ||
{ dispose: true } | ||
); | ||
const collector = reactionMessage.createReactionCollector( | ||
(reaction, user) => message.guild.members.cache.find((member) => member.id === user.id).permissions.has("ADMINISTRATOR") || message.guild.members.cache.find((member) => member.id === user.id).roles.cache.find(r => r.id === Jsonfile.Channelrole), { | ||
dispose: true | ||
} | ||
); | ||
|
||
collector.on("collect", (reaction, user) => { | ||
switch (reaction.emoji.name) { | ||
case "🔒": | ||
channel.updateOverwrite(user.id, { "SEND_MESSAGES": false }); | ||
channel.send("Channel has been locked!"); | ||
collector.on("collect", (reaction, user) => { | ||
if (user.bot) return; | ||
switch (reaction.emoji.name) { | ||
case "🔒": | ||
if (message.guild.members.cache.find((member) => member.id === user.id).permissions.has("ADMINISTRATOR") || message.guild.members.cache.find((member) => member.id === user.id).roles.cache.find(r => r.id === Jsonfile.Channelrole)) { | ||
channel.permissionOverwrites.edit(user.id, { | ||
"SEND_MESSAGES": false | ||
}); | ||
channel.send("Channel Locked 🔒"); | ||
break; | ||
case "⛔": | ||
if (message.guild.channels.cache.find(c => c.name.toLowerCase() === channel.name)) { //checks if there in an item in the channels collection that corresponds with the supplied parameters, returns a boolean | ||
} else { | ||
user.send("Only Staff can lock the channels") | ||
reaction.users.remove(user.id) | ||
break | ||
} | ||
case "⛔": | ||
if (message.guild.channels.cache.find(c => c.name.toLowerCase() === channel.name)) { | ||
if (message.guild.members.cache.find((member) => member.id === user.id).permissions.has("ADMINISTRATOR") || message.guild.members.cache.find((member) => member.id === user.id).roles.cache.find(r => r.id === Jsonfile.Channelrole)) { | ||
setTimeout(() => channel.delete(), 5000); | ||
channel.send("Deleting this channel in 5 seconds!"); | ||
return; | ||
} else { | ||
user.send("Only Staff can delete the channels") | ||
reaction.users.remove(user.id) | ||
break | ||
} | ||
} | ||
break; | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
} |
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
File renamed without changes.
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
Oops, something went wrong.