-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTicket.js
More file actions
125 lines (113 loc) · 5.17 KB
/
Copy pathTicket.js
File metadata and controls
125 lines (113 loc) · 5.17 KB
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
let Discord = require('discord.js')
module.exports = {
name: "ticket",
descirption: "ticket order",
alias: [],
run : async (bot, message, args) => {
let user = message.author;
let userid = user.id;
let name = "ticket-" + userid;
if(message.guild.channels.cache.find(x => x.name === name)){
if(message.member.hasPermission("MANAGE_CHANNELS")) {
const mention = message.mentions.users.first()
if(!mention){
message.channel.send({embed: {title: "Are you sure you want to end your ticket?", description: "You can always create a ticket again. Type `sure` if you want to end your ticket and type `cancel` if you still wanted to continue your ticket.", footer: {text: "This prompt ends in 30 seconds"}}}).then(
mes => {
const collector = mes.channel.createMessageCollector(filter => filter.author.id == userid, { time: 30000 })
collector.on("collect", collected => {
if(collected.content == "sure") {
message.guild.channels.cache.find(x => x.name === name).delete("The user ended his ticket")
mes.delete()
collector.stop()
mes.channel.send({embed: {color: "GREEN", description: "Ticket ended! Thank you for using our ticket system."}})
} else if (collected.content == "cancel") {
mes.delete()
collector.stop()
mes.channel.send("Prompt canceled")
} else {
mes.delete()
collector.stop()
mes.channel.send("Invalid response. Canceling prompt....")
}
})
collector.on('end', () => {
mes.edit({embed: {title: "Prompt Canceled", color: "RED", description: "No response retrieved in 30 seconds"}})
})
}
)
} else {
const filterch = message.guild.channels.cache.find(x => x.name == `ticket-${mention.id}`)
if(!filterch) {
message.channel.send({embed: {color: "RED", description: "Can't find the ticket of the user you mentioned"}})
} else {
message.channel.send({embed: {title: `Are you sure you want to end ${mention.username} ticket?`, description: "The user can always create their ticket again. Type `sure` if you want to end the user's ticket and type `cancel` if you still want to continue their ticket.", footer: {text: "This prompt ends in 30 seconds"}}}).then(
mes => {
const collector = mes.channel.createMessageCollector(filter => filter.author.id == userid, { time: 30000 })
collector.on("collect", collected => {
if(collected.content == "sure") {
message.guild.channels.cache.find(x => x.name === filterch.name).delete(`${message.author.username} ended ticket`)
mes.delete()
collector.stop()
mes.channel.send({embed: {color: "GREEN", description: "Ticket ended!"}})
mention.send({embed: {color: "GREEN", description: `Your ticket ended by ${message.author.username}. Thank you for using our ticket system.`}})
} else if (collected.content == "cancel") {
mes.delete()
collector.stop()
mes.channel.send("Prompt canceled")
} else {
mes.delete()
collector.stop()
mes.channel.send("Invalid response. Canceling prompt....")
}
})
collector.on('end', () => {
mes.edit({embed: {title: "Prompt Canceled", color: "RED", description: "No response retrieved in 30 seconds"}})
})
}
)
}
}
} else {
let embed = new Discord.MessageEmbed()
.setTitle("Are you sure you want to end your ticket?")
.setDescription("You can always create a ticket again. Type `sure` if you want to end your ticket and type `cancel` if you still wanted to continue your ticket.")
.setFooter("This prompt ends in 30 seconds")
message.channel.send(embed).then(mes => {
const collector = mes.channel.createMessageCollector(filter => filter.author.id == userid, { time: 30000 })
collector.on("collect", collected => {
if(collected.content == "sure") {
message.guild.channels.cache.find(x => x.name === name).delete("The user ended his ticket")
mes.delete()
collector.stop()
mes.channel.send({embed: {color: "GREEN", description: "Ticket ended! Thank you for using our ticket system."}})
} else if (collected.content == "cancel") {
mes.delete()
collector.stop()
mes.channel.send("Prompt canceled")
} else {
mes.delete()
collector.stop()
mes.channel.send("Invalid response. Canceling prompt....")
}
})
collector.on('end', () => {
mes.edit({embed: {title: "Prompt Canceled", color: "RED", description: "No response retrieved in 30 seconds"}})
})
});
}
} else {
message.guild.channels.create(name).then(chan => {
chan.setParent("756513276543762512");
chan.updateOverwrite(message.guild.roles.cache.find(x => x.name === "@everyone"),{
SEND_MESSAGES: false,
VIEW_CHANNEL: false
})
chan.updateOverwrite(user, {
SEND_MESSAGES: true,
VIEW_CHANNEL: true
})
})
async (m) => await m.send("test")
}
}
}