added some new commands
- rename - close - delete
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
const discord = require('discord.js')
|
||||
const bot = require('../index')
|
||||
const client = bot.client
|
||||
const config = bot.config
|
||||
|
||||
module.exports = () => {
|
||||
client.on("messageCreate",msg => {
|
||||
if (!msg.content.startsWith(config.prefix+"close")) return
|
||||
|
||||
|
||||
msg.channel.messages.fetchPinned().then(msglist => {
|
||||
var firstmsg = msglist.last()
|
||||
|
||||
if (firstmsg == undefined || firstmsg.author.id != client.user.id){
|
||||
msg.channel.send({content:"You are not in a ticket!"})
|
||||
return
|
||||
}
|
||||
|
||||
const closebutton = new discord.MessageActionRow()
|
||||
.addComponents([
|
||||
new discord.MessageButton()
|
||||
.setCustomId("closeTicketTrue1")
|
||||
.setDisabled(false)
|
||||
.setStyle("SECONDARY")
|
||||
.setEmoji("🔒")
|
||||
])
|
||||
|
||||
msg.channel.send({content:"**Click on the button below to close this ticket!**",components:[closebutton]})
|
||||
|
||||
console.log("[system] closed a ticket via command")
|
||||
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
client.on("interactionCreate",(interaction) => {
|
||||
if (!interaction.isCommand()) return
|
||||
if (interaction.commandName != "close") return
|
||||
|
||||
interaction.channel.messages.fetchPinned().then(msglist => {
|
||||
var firstmsg = msglist.last()
|
||||
|
||||
if (firstmsg == undefined || firstmsg.author.id != client.user.id){
|
||||
interaction.reply({content:"You are not in a ticket!"})
|
||||
return
|
||||
}
|
||||
|
||||
const closebutton = new discord.MessageActionRow()
|
||||
.addComponents([
|
||||
new discord.MessageButton()
|
||||
.setCustomId("closeTicketTrue1")
|
||||
.setDisabled(false)
|
||||
.setStyle("SECONDARY")
|
||||
.setEmoji("🔒")
|
||||
])
|
||||
|
||||
interaction.reply({content:"**Click on the button below to close this ticket!**",components:[closebutton]})
|
||||
|
||||
console.log("[system] closed a ticket via command")
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
const discord = require('discord.js')
|
||||
const bot = require('../index')
|
||||
const client = bot.client
|
||||
const config = bot.config
|
||||
|
||||
module.exports = () => {
|
||||
client.on("messageCreate",msg => {
|
||||
if (!msg.content.startsWith(config.prefix+"delete")) return
|
||||
|
||||
|
||||
msg.channel.messages.fetchPinned().then(msglist => {
|
||||
var firstmsg = msglist.last()
|
||||
|
||||
if (firstmsg == undefined || firstmsg.author.id != client.user.id){
|
||||
msg.channel.send({content:"You are not in a ticket!"})
|
||||
return
|
||||
}
|
||||
|
||||
const closebutton = new discord.MessageActionRow()
|
||||
.addComponents([
|
||||
new discord.MessageButton()
|
||||
.setCustomId("deleteTicketTrue")
|
||||
.setDisabled(false)
|
||||
.setStyle("SECONDARY")
|
||||
.setEmoji("❌")
|
||||
])
|
||||
|
||||
msg.channel.send({content:"**Click on the button below to delete this ticket!**",components:[closebutton]})
|
||||
|
||||
console.log("[system] deleted a ticket via command")
|
||||
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
client.on("interactionCreate",(interaction) => {
|
||||
if (!interaction.isCommand()) return
|
||||
if (interaction.commandName != "delete") return
|
||||
|
||||
interaction.channel.messages.fetchPinned().then(msglist => {
|
||||
var firstmsg = msglist.last()
|
||||
|
||||
if (firstmsg == undefined || firstmsg.author.id != client.user.id){
|
||||
interaction.reply({content:"You are not in a ticket!"})
|
||||
return
|
||||
}
|
||||
|
||||
const closebutton = new discord.MessageActionRow()
|
||||
.addComponents([
|
||||
new discord.MessageButton()
|
||||
.setCustomId("deleteTicketTrue")
|
||||
.setDisabled(false)
|
||||
.setStyle("SECONDARY")
|
||||
.setEmoji("❌")
|
||||
])
|
||||
|
||||
interaction.reply({content:"**Click on the button below to delete this ticket!**",components:[closebutton]})
|
||||
|
||||
console.log("[system] deleted a ticket via command")
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -8,33 +8,6 @@ const config = bot.config
|
||||
//=============================
|
||||
|
||||
module.exports = () => {
|
||||
client.on("messageCreate",msg => {
|
||||
var args = msg.content.split(" ")
|
||||
if (args[0] == config.prefix+"ticket" && args[1] == "close"){
|
||||
|
||||
msg.channel.messages.fetchPinned().then(msglist => {
|
||||
var firstmsg = msglist.last()
|
||||
|
||||
if (firstmsg == undefined){
|
||||
msg.channel.send({content:"I didn't find the close button!"})
|
||||
}
|
||||
if (firstmsg.author.id != client.user.id){
|
||||
msg.channel.send({content:"You are not in a ticket!"})
|
||||
return
|
||||
}
|
||||
var CloseMsg = new discord.MessageEmbed()
|
||||
.setColor(config.main_color)
|
||||
.setDescription("Click [here]("+firstmsg.url+") to close this ticket.")
|
||||
.setTitle("Close this ticket:")
|
||||
|
||||
msg.channel.send({embeds:[CloseMsg]})
|
||||
if (config.logs){console.log("[command] "+config.prefix+"ticket close (user:"+msg.author.username+")")}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
client.on("messageCreate",msg => {
|
||||
var args = msg.content.split(" ")
|
||||
if (args[0] == config.prefix+"ticket" && args[1] == "rename"){
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ module.exports = () => {
|
||||
if (!msg.content.startsWith(config.prefix)) return
|
||||
var args = msg.content.split(config.prefix)
|
||||
|
||||
if (!args[1].startsWith("close") && !args[1].startsWith("delete") && !args[1].startsWith("remove") && !args[1].startsWith("add") && !args[1].startsWith("msg") && !args[1].startsWith("remove") && !args[1].startsWith("msg")){
|
||||
if (!args[1].startsWith("close") && !args[1].startsWith("delete") && !args[1].startsWith("remove") && !args[1].startsWith("add") && !args[1].startsWith("msg") && !args[1].startsWith("remove") && !args[1].startsWith("rename")){
|
||||
|
||||
msg.channel.send({embeds:[helpEmbed]})
|
||||
if (config.logs){console.log("[command] "+config.prefix+"ticket help (user:"+msg.author.username+")")}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
const discord = require('discord.js')
|
||||
const bot = require('../index')
|
||||
const client = bot.client
|
||||
const config = bot.config
|
||||
|
||||
module.exports = () => {
|
||||
client.on("messageCreate",msg => {
|
||||
if (!msg.content.startsWith(config.prefix+"rename")) return
|
||||
|
||||
msg.channel.messages.fetchPinned().then(msglist => {
|
||||
var firstmsg = msglist.last()
|
||||
|
||||
if (firstmsg == undefined || firstmsg.author.id != client.user.id){
|
||||
msg.channel.send({content:"You are not in a ticket!"})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (!msg.member.permissions.has("MANAGE_CHANNELS") && !msg.member.permissions.has("ADMINISTRATOR")){
|
||||
return msg.channel.send({content:"You have no permissions to change the channel name!\nYou need the `ADMINISTRATOR` or `MANAGE_CHANNELS` permission"})
|
||||
}
|
||||
|
||||
var newname = msg.content.split(config.prefix+"rename")[1].substring(1)
|
||||
var name = msg.channel.name
|
||||
var prefix = ""
|
||||
const tickets = config.options
|
||||
tickets.forEach((ticket) => {
|
||||
if (name.startsWith(ticket.channelprefix)){
|
||||
prefix = ticket.channelprefix
|
||||
}
|
||||
})
|
||||
|
||||
if (!prefix) prefix = "noprefix-"
|
||||
|
||||
msg.channel.setName(prefix+newname)
|
||||
msg.channel.send({content:"**The name is changed!**\nWarning: you can only change the channel name 2 times per minute! (this is due discord rate limits)"})
|
||||
|
||||
console.log("[system] renamed a ticket via command")
|
||||
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
client.on("interactionCreate",(interaction) => {
|
||||
if (!interaction.isCommand()) return
|
||||
if (interaction.commandName != "rename") return
|
||||
|
||||
interaction.channel.messages.fetchPinned().then(msglist => {
|
||||
var firstmsg = msglist.last()
|
||||
|
||||
if (firstmsg == undefined || firstmsg.author.id != client.user.id){
|
||||
interaction.reply({content:"You are not in a ticket!"})
|
||||
return
|
||||
}
|
||||
|
||||
const member = client.guilds.cache.find(g => g.id == interaction.guild.id).members.cache.find(m => m.id == interaction.member.id)
|
||||
if (!member.permissions.has("MANAGE_CHANNELS") && !member.permissions.has("ADMINISTRATOR")){
|
||||
return interaction.reply({content:"You have no permissions to change the channel name!\nYou need the `ADMINISTRATOR` or `MANAGE_CHANNELS` permission"})
|
||||
}
|
||||
|
||||
var newname = interaction.options.getString("name")
|
||||
var name = interaction.channel.name
|
||||
var prefix = ""
|
||||
const tickets = config.options
|
||||
tickets.forEach((ticket) => {
|
||||
if (name.startsWith(ticket.channelprefix)){
|
||||
prefix = ticket.channelprefix
|
||||
}
|
||||
})
|
||||
|
||||
if (!prefix) prefix = "noprefix-"
|
||||
|
||||
interaction.channel.setName(prefix+newname)
|
||||
interaction.reply({content:"**The name is changed!**\nWarning: you can only change the channel name 2 times per minute! (this is due discord rate limits)"})
|
||||
|
||||
console.log("[system] renamed a ticket via command")
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -126,6 +126,36 @@ module.exports = () => {
|
||||
require("./ticketCloser").closeTicket(interaction,prefix,"close")
|
||||
})
|
||||
|
||||
client.on("interactionCreate",interaction => {
|
||||
if (!interaction.isButton()) return
|
||||
if (interaction.customId != "closeTicketTrue1") return
|
||||
|
||||
interaction.deferUpdate()
|
||||
const closedButtonDisabled = new discord.MessageActionRow()
|
||||
.addComponents([
|
||||
new discord.MessageButton()
|
||||
.setCustomId("closeTicketTrue1")
|
||||
.setDisabled(true)
|
||||
.setStyle("SECONDARY")
|
||||
.setEmoji("🔒")
|
||||
])
|
||||
interaction.message.edit({components:[closedButtonDisabled]})
|
||||
|
||||
/**
|
||||
* @type {String}
|
||||
*/
|
||||
const name = interaction.channel.name
|
||||
var prefix = ""
|
||||
const tickets = config.options
|
||||
tickets.forEach((ticket) => {
|
||||
if (name.startsWith(ticket.channelprefix)){
|
||||
prefix = ticket.channelprefix
|
||||
}
|
||||
})
|
||||
|
||||
require("./ticketCloser").closeTicket(interaction,prefix,"close")
|
||||
})
|
||||
|
||||
|
||||
//NORMAL DELETE
|
||||
client.on("interactionCreate",interaction => {
|
||||
|
||||
@@ -13,7 +13,6 @@ module.exports = async () => {
|
||||
var choices = []
|
||||
ids.forEach((id) => {
|
||||
const option = getoptions.getOptionsById(id)
|
||||
console.log(option.id)
|
||||
choices.push({name:option.name,value:option.id})
|
||||
})
|
||||
|
||||
@@ -26,8 +25,8 @@ module.exports = async () => {
|
||||
var readystats = 0
|
||||
|
||||
setInterval(() => {
|
||||
console.log("[status] there are "+chalk.blue(readystats+" out of 8")+" commands ready! (this can take some time)")
|
||||
if (readystats >= 8){
|
||||
console.log("[status] there are "+chalk.blue(readystats+" out of 9")+" commands ready! (this can take some time)")
|
||||
if (readystats >= 9){
|
||||
console.log(chalk.green("ready!"))
|
||||
console.log(chalk.blue("you can now start the bot with 'npm start'!"))
|
||||
process.exit(1)
|
||||
@@ -160,4 +159,22 @@ module.exports = async () => {
|
||||
readystats++
|
||||
})
|
||||
|
||||
//rename
|
||||
client.application.commands.create({
|
||||
name:"rename",
|
||||
description:"Rename this ticket.",
|
||||
defaultPermission:true,
|
||||
type:"CHAT_INPUT",
|
||||
options:[
|
||||
{
|
||||
type:"STRING",
|
||||
name:"name",
|
||||
description:"The new name (without prefix).",
|
||||
required:true
|
||||
}
|
||||
]
|
||||
},sid).then(() => {
|
||||
readystats++
|
||||
})
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user