added the "add" & "remove" commands
This commit is contained in:
@@ -0,0 +1,65 @@
|
|||||||
|
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+"add")) return
|
||||||
|
var user = msg.mentions.users.first()
|
||||||
|
if (!user){
|
||||||
|
return msg.channel.send({content:"**There is no user to add:**\nuse: `"+config.prefix+"add <user>`"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.member.permissions.has("MANAGE_CHANNELS") && !msg.member.permissions.has("ADMINISTRATOR")){
|
||||||
|
return msg.channel.send({content:"You have no permissions to add someone to the channel!\nYou need the `ADMINISTRATOR` or `MANAGE_CHANNELS` permission"})
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
msg.channel.permissionOverwrites.create(user.id, { VIEW_CHANNEL:true, ADD_REACTIONS:true,ATTACH_FILES:true, EMBED_LINKS:true, SEND_MESSAGES:true})
|
||||||
|
msg.channel.send({content:"Added "+user.tag+" to the ticket"})
|
||||||
|
if (config.logs){console.log("[system] added user to ticket (name:"+user.username+",ticket:"+msg.channel.name+")")}
|
||||||
|
|
||||||
|
var loguser = msg.mentions.users.first()
|
||||||
|
if (config.logs){console.log("[command] "+config.prefix+"add "+loguser.username+" (user:"+msg.author.username+")")}
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
client.on("interactionCreate",(interaction) => {
|
||||||
|
if (!interaction.isCommand()) return
|
||||||
|
if (interaction.commandName != "add") return
|
||||||
|
const user = interaction.options.getUser("user")
|
||||||
|
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 add someone to the channel!\nYou need the `ADMINISTRATOR` or `MANAGE_CHANNELS` permission"})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
interaction.channel.permissionOverwrites.create(user.id, { VIEW_CHANNEL:true, ADD_REACTIONS:true,ATTACH_FILES:true, EMBED_LINKS:true, SEND_MESSAGES:true})
|
||||||
|
interaction.reply({content:"Added "+user.tag+" to the ticket"})
|
||||||
|
if (config.logs){console.log("[system] added user to ticket (name:"+user.username+",ticket:"+interaction.channel.name+")")}
|
||||||
|
|
||||||
|
var loguser = user
|
||||||
|
if (config.logs){console.log("[command] "+config.prefix+"add "+loguser.username+" (user:"+interaction.user.username+")")}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -8,68 +8,6 @@ const config = bot.config
|
|||||||
//=============================
|
//=============================
|
||||||
|
|
||||||
module.exports = () => {
|
module.exports = () => {
|
||||||
client.on("messageCreate",msg => {
|
|
||||||
var args = msg.content.split(" ")
|
|
||||||
if (args[0] == config.prefix+"ticket" && args[1] == "rename"){
|
|
||||||
|
|
||||||
if (msg.member.roles.cache.has(config.botperms_role) == false && msg.author.id != "779742674932072469"){
|
|
||||||
msg.channel.send({content:config.messages.general.nopermissions})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[2] == null || args[2] == undefined || args[2] == "" || args[2] == false){
|
|
||||||
msg.channel.send({content:"Not enough parameters!"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var name = args[2]
|
|
||||||
var oldname = msg.channel.name
|
|
||||||
msg.channel.messages.fetchPinned().then(msglist => {
|
|
||||||
if (msglist.last().author.id == client.user.id){
|
|
||||||
msg.channel.send({content:"The name from the ticket is changed!"}).then(rmsg => {
|
|
||||||
rmsg.channel.setName(name)
|
|
||||||
if (config.logs){console.log("[system] renamed a ticket (name:"+oldname+",newname:"+name+")")}
|
|
||||||
})
|
|
||||||
}else{
|
|
||||||
msg.channel.send({content:"You are not in a ticket!"})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (config.logs){console.log("[command] "+config.prefix+"ticket rename (user:"+msg.author.username+")")}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
client.on("messageCreate",msg => {
|
|
||||||
var args = msg.content.split(" ")
|
|
||||||
if (args[0] == config.prefix+"ticket" && args[1] == "add"){
|
|
||||||
|
|
||||||
if (msg.member.roles.cache.has(config.botperms_role) == false && msg.author.id != "779742674932072469"){
|
|
||||||
msg.channel.send({content:config.messages.general.nopermissions})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
msg.channel.messages.fetch().then(msglist => {
|
|
||||||
if (msglist.last().author.id != client.user.id){
|
|
||||||
msg.channel.send({content:"You are not in a ticket!"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[2] == null || args[2] == undefined || args[2] == "" || args[2] == false){
|
|
||||||
msg.channel.send({content:"Not enough parameters!"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var user = msg.mentions.users.first()
|
|
||||||
if (!user){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
msg.channel.permissionOverwrites.create(user.id, { VIEW_CHANNEL:true, ADD_REACTIONS:true,ATTACH_FILES:true, EMBED_LINKS:true, SEND_MESSAGES:true})
|
|
||||||
if (config.logs){console.log("[system] added user to ticket (name:"+user.username+",ticket:"+msg.channel.name+")")}
|
|
||||||
|
|
||||||
})
|
|
||||||
var loguser = msg.mentions.users.first()
|
|
||||||
if (config.logs){console.log("[command] "+config.prefix+"ticket add "+loguser.username+" (user:"+msg.author.username+")")}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
client.on("messageCreate",msg => {
|
client.on("messageCreate",msg => {
|
||||||
var args = msg.content.split(" ")
|
var args = msg.content.split(" ")
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
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+"remove")) return
|
||||||
|
var user = msg.mentions.users.first()
|
||||||
|
if (!user){
|
||||||
|
return msg.channel.send({content:"**There is no user to remove:**\nuse: `"+config.prefix+"remove <user>`"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.member.permissions.has("MANAGE_CHANNELS") && !msg.member.permissions.has("ADMINISTRATOR")){
|
||||||
|
return msg.channel.send({content:"You have no permissions to remove someone from the channel!\nYou need the `ADMINISTRATOR` or `MANAGE_CHANNELS` permission"})
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
msg.channel.permissionOverwrites.delete(user.id)
|
||||||
|
msg.channel.send({content:"Deleted "+user.tag+" from the ticket"})
|
||||||
|
if (config.logs){console.log("[system] deleted user from ticket (name:"+user.username+",ticket:"+msg.channel.name+")")}
|
||||||
|
|
||||||
|
var loguser = msg.mentions.users.first()
|
||||||
|
if (config.logs){console.log("[command] "+config.prefix+"remove "+loguser.username+" (user:"+msg.author.username+")")}
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
client.on("interactionCreate",(interaction) => {
|
||||||
|
if (!interaction.isCommand()) return
|
||||||
|
if (interaction.commandName != "remove") return
|
||||||
|
const user = interaction.options.getUser("user")
|
||||||
|
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 remove someone from the channel!\nYou need the `ADMINISTRATOR` or `MANAGE_CHANNELS` permission"})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
interaction.channel.permissionOverwrites.delete(user.id)
|
||||||
|
interaction.reply({content:"Deleted "+user.tag+" from the ticket"})
|
||||||
|
if (config.logs){console.log("[system] removed user from ticket (name:"+user.username+",ticket:"+interaction.channel.name+")")}
|
||||||
|
|
||||||
|
var loguser = user
|
||||||
|
if (config.logs){console.log("[command] "+config.prefix+"remove "+loguser.username+" (user:"+interaction.user.username+")")}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -61,6 +61,8 @@ if (process.argv[2] != "slash"){
|
|||||||
require("./commands/close")()
|
require("./commands/close")()
|
||||||
require("./commands/delete")()
|
require("./commands/delete")()
|
||||||
require("./commands/rename")()
|
require("./commands/rename")()
|
||||||
|
require("./commands/add")()
|
||||||
|
require("./commands/remove")()
|
||||||
|
|
||||||
//core
|
//core
|
||||||
require('./core/ticketOpener')()
|
require('./core/ticketOpener')()
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
779742674932072469
|
||||||
Reference in New Issue
Block a user