v2.1.0 push 2

This commit is contained in:
DJj123dj
2022-06-08 18:07:42 +02:00
parent 62a1f0f8c1
commit 1728c3653a
10 changed files with 113 additions and 78 deletions
+11 -18
View File
@@ -7,24 +7,19 @@ module.exports = () => {
client.on("messageCreate",msg => { client.on("messageCreate",msg => {
if (!msg.content.startsWith(config.prefix+"add")) return if (!msg.content.startsWith(config.prefix+"add")) return
var user = msg.mentions.users.first() var user = msg.mentions.users.first()
if (!user){ if (!user) return msg.channel.send({embeds:[bot.errorLog.invalidArgsMessage("Missing Argument `<user>`:\n`"+config.prefix+"add <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")){ 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"}) return msg.channel.send({embeds:[bot.errorLog.noPermsMessage]})
} }
msg.channel.messages.fetchPinned().then(msglist => { msg.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last() var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id){ if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
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.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"}) msg.channel.send({embeds:[bot.errorLog.success("User Added!",user.tag+" is added to this ticket")]})
if (config.logs){console.log("[system] added user to ticket (name:"+user.username+",ticket:"+msg.channel.name+")")} if (config.logs){console.log("[system] added user to ticket (name:"+user.username+",ticket:"+msg.channel.name+")")}
var loguser = msg.mentions.users.first() var loguser = msg.mentions.users.first()
@@ -37,23 +32,21 @@ module.exports = () => {
if (!interaction.isCommand()) return if (!interaction.isCommand()) return
if (interaction.commandName != "add") return if (interaction.commandName != "add") return
const user = interaction.options.getUser("user") 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")){ const permsmember = client.guilds.cache.find(g => g.id == interaction.guild.id).members.cache.find(m => m.id == interaction.member.id)
return interaction.reply({content:"You have no permissions to add someone to the channel!\nYou need the `ADMINISTRATOR` or `MANAGE_CHANNELS` permission"}) if (config.main_adminroles.some((item)=>{return interaction.guild.members.cache.find((m) => m.id == interaction.member.id).roles.cache.has(item)}) == false && permsmember.permissions.has("ADMINISTRATOR")){
} interaction.reply({embeds:[bot.errorLog.noPermsMessage]})
return
}
interaction.channel.messages.fetchPinned().then(msglist => { interaction.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last() var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id){ if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.reply({embeds:[bot.errorLog.notInATicket]})
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.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"}) interaction.reply({embeds:[bot.errorLog.success("User Added!",user.tag+" is added to this ticket")]})
if (config.logs){console.log("[system] added user to ticket (name:"+user.username+",ticket:"+interaction.channel.name+")")} if (config.logs){console.log("[system] added user to ticket (name:"+user.username+",ticket:"+interaction.channel.name+")")}
var loguser = user var loguser = user
+4 -10
View File
@@ -11,10 +11,7 @@ module.exports = () => {
msg.channel.messages.fetchPinned().then(msglist => { msg.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last() var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id){ if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
msg.channel.send({content:"You are not in a ticket!"})
return
}
const closebutton = new discord.MessageActionRow() const closebutton = new discord.MessageActionRow()
.addComponents([ .addComponents([
@@ -25,7 +22,7 @@ module.exports = () => {
.setEmoji("🔒") .setEmoji("🔒")
]) ])
msg.channel.send({content:"**Click on the button below to close this ticket!**",components:[closebutton]}) msg.channel.send({embeds:[bot.errorLog.success("Close this ticket!","You can close this ticket by clicking on the button below!")],components:[closebutton]})
console.log("[system] closed a ticket via command") console.log("[system] closed a ticket via command")
@@ -41,10 +38,7 @@ module.exports = () => {
interaction.channel.messages.fetchPinned().then(msglist => { interaction.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last() var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id){ if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.reply({embeds:[bot.errorLog.notInATicket]})
interaction.reply({content:"You are not in a ticket!"})
return
}
const closebutton = new discord.MessageActionRow() const closebutton = new discord.MessageActionRow()
.addComponents([ .addComponents([
@@ -55,7 +49,7 @@ module.exports = () => {
.setEmoji("🔒") .setEmoji("🔒")
]) ])
interaction.reply({content:"**Click on the button below to close this ticket!**",components:[closebutton]}) interaction.reply({embeds:[bot.errorLog.success("Close this ticket!","You can close this ticket by clicking on the button below!")],components:[closebutton]})
console.log("[system] closed a ticket via command") console.log("[system] closed a ticket via command")
+4 -10
View File
@@ -11,10 +11,7 @@ module.exports = () => {
msg.channel.messages.fetchPinned().then(msglist => { msg.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last() var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id){ if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
msg.channel.send({content:"You are not in a ticket!"})
return
}
const closebutton = new discord.MessageActionRow() const closebutton = new discord.MessageActionRow()
.addComponents([ .addComponents([
@@ -25,7 +22,7 @@ module.exports = () => {
.setEmoji("❌") .setEmoji("❌")
]) ])
msg.channel.send({content:"**Click on the button below to delete this ticket!**",components:[closebutton]}) msg.channel.send({embeds:[bot.errorLog.success("Delete this ticket!","You can delete this ticket by clicking on the button below!")],components:[closebutton]})
console.log("[system] deleted a ticket via command") console.log("[system] deleted a ticket via command")
@@ -41,10 +38,7 @@ module.exports = () => {
interaction.channel.messages.fetchPinned().then(msglist => { interaction.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last() var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id){ if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.reply({embeds:[bot.errorLog.notInATicket]})
interaction.reply({content:"You are not in a ticket!"})
return
}
const closebutton = new discord.MessageActionRow() const closebutton = new discord.MessageActionRow()
.addComponents([ .addComponents([
@@ -55,7 +49,7 @@ module.exports = () => {
.setEmoji("❌") .setEmoji("❌")
]) ])
interaction.reply({content:"**Click on the button below to delete this ticket!**",components:[closebutton]}) interaction.reply({embeds:[bot.errorLog.success("Delete this ticket!","You can delete this ticket by clicking on the button below!")],components:[closebutton]})
console.log("[system] deleted a ticket via command") console.log("[system] deleted a ticket via command")
+12 -18
View File
@@ -7,24 +7,19 @@ module.exports = () => {
client.on("messageCreate",msg => { client.on("messageCreate",msg => {
if (!msg.content.startsWith(config.prefix+"remove")) return if (!msg.content.startsWith(config.prefix+"remove")) return
var user = msg.mentions.users.first() var user = msg.mentions.users.first()
if (!user){ if (!user) return msg.channel.send({embeds:[bot.errorLog.invalidArgsMessage("Missing Argument `<user>`:\n`"+config.prefix+"remove <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")){ 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"}) return msg.channel.send({embeds:[bot.errorLog.noPermsMessage]})
} }
msg.channel.messages.fetchPinned().then(msglist => { msg.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last() var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id){ if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
msg.channel.send({content:"You are not in a ticket!"})
return
}
msg.channel.permissionOverwrites.delete(user.id) msg.channel.permissionOverwrites.delete(user.id)
msg.channel.send({content:"Deleted "+user.tag+" from the ticket"}) msg.channel.send({embeds:[bot.errorLog.success("User removed!",user.tag+" is removed from this ticket")]})
if (config.logs){console.log("[system] deleted user from ticket (name:"+user.username+",ticket:"+msg.channel.name+")")} if (config.logs){console.log("[system] deleted user from ticket (name:"+user.username+",ticket:"+msg.channel.name+")")}
var loguser = msg.mentions.users.first() var loguser = msg.mentions.users.first()
@@ -37,23 +32,22 @@ module.exports = () => {
if (!interaction.isCommand()) return if (!interaction.isCommand()) return
if (interaction.commandName != "remove") return if (interaction.commandName != "remove") return
const user = interaction.options.getUser("user") 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")){ const permsmember = client.guilds.cache.find(g => g.id == interaction.guild.id).members.cache.find(m => m.id == interaction.member.id)
return interaction.reply({content:"You have no permissions to remove someone from the channel!\nYou need the `ADMINISTRATOR` or `MANAGE_CHANNELS` permission"}) if (config.main_adminroles.some((item)=>{return interaction.guild.members.cache.find((m) => m.id == interaction.member.id).roles.cache.has(item)}) == false && permsmember.permissions.has("ADMINISTRATOR")){
} interaction.reply({embeds:[bot.errorLog.noPermsMessage]})
return
}
interaction.channel.messages.fetchPinned().then(msglist => { interaction.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last() var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id){ if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.reply({embeds:[bot.errorLog.notInATicket]})
interaction.reply({content:"You are not in a ticket!"})
return
}
interaction.channel.permissionOverwrites.delete(user.id) interaction.channel.permissionOverwrites.delete(user.id)
interaction.reply({content:"Deleted "+user.tag+" from the ticket"}) interaction.reply({embeds:[bot.errorLog.success("User removed!",user.tag+" is removed from this ticket")]})
if (config.logs){console.log("[system] removed user from ticket (name:"+user.username+",ticket:"+interaction.channel.name+")")} if (config.logs){console.log("[system] removed user from ticket (name:"+user.username+",ticket:"+interaction.channel.name+")")}
var loguser = user var loguser = user
+12 -14
View File
@@ -10,17 +10,17 @@ module.exports = () => {
msg.channel.messages.fetchPinned().then(msglist => { msg.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last() var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id){ if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
msg.channel.send({content:"You are not in a ticket!"})
return
}
if (!msg.member.permissions.has("MANAGE_CHANNELS") && !msg.member.permissions.has("ADMINISTRATOR")){ 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"}) return msg.channel.send({embeds:[bot.errorLog.noPermsMessage]})
} }
var newname = msg.content.split(config.prefix+"rename")[1].substring(1) var newname = msg.content.split(config.prefix+"rename")[1].substring(1)
if (!newname) return msg.channel.send({embeds:[bot.errorLog.invalidArgsMessage("Missing Argument `<name>`:\n`"+config.prefix+"rename <name>`")]})
var name = msg.channel.name var name = msg.channel.name
var prefix = "" var prefix = ""
const tickets = config.options const tickets = config.options
@@ -33,7 +33,7 @@ module.exports = () => {
if (!prefix) prefix = "noprefix-" if (!prefix) prefix = "noprefix-"
msg.channel.setName(prefix+newname) 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)"}) msg.channel.send({embeds:[bot.errorLog.success("The name has changed!","Warning: you can only change the channel name 2 times per minute!\n(this is due discord rate limits)")]})
console.log("[system] renamed a ticket via command") console.log("[system] renamed a ticket via command")
@@ -49,14 +49,12 @@ module.exports = () => {
interaction.channel.messages.fetchPinned().then(msglist => { interaction.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last() var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id){ if (firstmsg == undefined || firstmsg.author.id != client.user.id)return interaction.reply({embeds:[bot.errorLog.notInATicket]})
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) const permsmember = 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")){ if (config.main_adminroles.some((item)=>{return interaction.guild.members.cache.find((m) => m.id == interaction.member.id).roles.cache.has(item)}) == false && permsmember.permissions.has("ADMINISTRATOR")){
return interaction.reply({content:"You have no permissions to change the channel name!\nYou need the `ADMINISTRATOR` or `MANAGE_CHANNELS` permission"}) interaction.reply({embeds:[bot.errorLog.noPermsMessage]})
return
} }
var newname = interaction.options.getString("name") var newname = interaction.options.getString("name")
@@ -72,7 +70,7 @@ module.exports = () => {
if (!prefix) prefix = "noprefix-" if (!prefix) prefix = "noprefix-"
interaction.channel.setName(prefix+newname) 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)"}) interaction.reply({embeds:[bot.errorLog.success("The name has changed!","Warning: you can only change the channel name 2 times per minute!\n(this is due discord rate limits)")]})
console.log("[system] renamed a ticket via command") console.log("[system] renamed a ticket via command")
+7 -6
View File
@@ -18,14 +18,14 @@ module.exports = () => {
client.on("messageCreate", msg => { client.on("messageCreate", msg => {
if (msg.content.startsWith(config.prefix+"msg")){ if (msg.content.startsWith(config.prefix+"msg")){
if (config.main_adminroles.some((item)=>{return msg.member.roles.cache.has(item)}) == false){ if (config.main_adminroles.some((item)=>{return msg.member.roles.cache.has(item)}) == false){
msg.channel.send({content:"You have no permission to run this command!"}) msg.channel.send({embeds:[bot.errorLog.noPermsMessage]})
return return
} }
const id = msg.content.split(config.prefix+"msg")[1].substring(1) ? msg.content.split(config.prefix+"msg")[1].substring(1) : false const id = msg.content.split(config.prefix+"msg")[1].substring(1) ? msg.content.split(config.prefix+"msg")[1].substring(1) : false
if (!id) return msg.channel.send({content:"**There is no id!**\nUse: `"+config.prefix+"msg <id>`"}) if (!id) return msg.channel.send({embeds:[bot.errorLog.invalidArgsMessage("Missing Argument `<id>`:\n`"+config.prefix+"msg <id>`")]})
if (!msgIds.includes(id)) return msg.channel.send({content:"**Invalid id!**\nChoose from this list:\n_"+msgIds.join("_\n_")+"_"}) if (!msgIds.includes(id)) return msg.channel.send({embeds:[bot.errorLog.invalidIdChooseFromList(msgIds)]})
const {embed,componentRows} = require("../core/ticketMessageEmbed").createEmbed(id) const {embed,componentRows} = require("../core/ticketMessageEmbed").createEmbed(id)
@@ -41,14 +41,15 @@ module.exports = () => {
if (!interaction.isCommand()) return if (!interaction.isCommand()) return
if (interaction.commandName != "message") return if (interaction.commandName != "message") return
if (config.main_adminroles.some((item)=>{return interaction.guild.members.cache.find((m) => m.id == interaction.member.id).roles.cache.has(item)}) == false){ const permsmember = client.guilds.cache.find(g => g.id == interaction.guild.id).members.cache.find(m => m.id == interaction.member.id)
interaction.reply({content:"You have no permission to run this command!"}) if (config.main_adminroles.some((item)=>{return interaction.guild.members.cache.find((m) => m.id == interaction.member.id).roles.cache.has(item)}) == false && permsmember.permissions.has("ADMINISTRATOR")){
interaction.reply({embeds:[bot.errorLog.noPermsMessage]})
return return
} }
const id = interaction.options.getString("id") const id = interaction.options.getString("id")
if (!msgIds.includes(id)) return interaction.reply({content:"**Invalid id!**\nChoose from this list:\n_"+msgIds.join("_\n_")+"_"}) if (!msgIds.includes(id)) return interaction.reply({embeds:[bot.errorLog.invalidIdChooseFromList(msgIds)]})
const {embed,componentRows} = require("../core/ticketMessageEmbed").createEmbed(id) const {embed,componentRows} = require("../core/ticketMessageEmbed").createEmbed(id)
+60
View File
@@ -0,0 +1,60 @@
const discord = require('discord.js')
const bot = require('../index')
const client = bot.client
const config = bot.config
const loadChalk = async () => {
return await (await import("chalk")).default
}
const embed = discord.MessageEmbed
exports.noPermsMessage = new embed()
.setColor("RED")
.setTitle(":x: No Permissions! :x:")
.setDescription("You don't have the correct roles to run this command!\nYou need the `ADMINISTRATOR` permission or be in the list of allowed roles!")
/**@param {String} message */
exports.invalidArgsMessage = (message) => {
var x = new embed()
.setColor("RED")
.setTitle(":x: Invalid Arguments! :x:")
.setDescription(message)
return x
}
/**@param {String} message */
exports.serverError = (message) => {
var x = new embed()
.setColor("ORANGE")
.setTitle(":warning: Bot Error! :warning:")
.setDescription(message)
return x
}
/**@param {String[]} list */
exports.invalidIdChooseFromList = (list) => {
var x = new embed()
.setColor("RED")
.setTitle(":x: Invalid ID :x:")
.setDescription("Choose one of the id's below:\n`"+list.join("`\n`")+"`")
return x
}
//seves
exports.notInATicket = new embed()
.setColor("RED")
.setTitle(":x: You are not in a ticket! :x:")
.setDescription("This command doesn't work outside tickets!")
exports.success = (title,message) => {
var x = new embed()
.setColor(config.main_color)
.setTitle(":white_check_mark: "+title+" :white_check_mark:")
.setDescription(message)
return x
}
+1 -1
View File
@@ -50,7 +50,7 @@ module.exports = async () => {
} }
}catch{ }catch{
interaction.reply({ephemeral:true,content:"Something went wrong! Contact the owner of this bot for more information"}) interaction.replyinteraction.channel.send({embeds:[bot.errorLog.serverError("Something went wrong!**\nPlease try again another time!")]})
} }
}) })
} }
+1 -1
View File
@@ -147,7 +147,7 @@ exports.runThis = () => {
if (fileattachment == false){ if (fileattachment == false){
console.log("[transcript] internal error: no transcript is created!") console.log("[transcript] internal error: no transcript is created!")
interaction.channel.send({content:"**Something went wrong while making the transcript!**\nPlease try again another time!"}) interaction.channel.send({embeds:[bot.errorLog.serverError("Something went wrong while making the transcript!**\nPlease try again another time!")]})
return return
} }
+1
View File
@@ -23,6 +23,7 @@ if (isDev){
} }
}else{var config = require('./config.json')} }else{var config = require('./config.json')}
exports.config = config exports.config = config
exports.errorLog = require("./core/errorLogSystem")
client.on('ready',async () => { client.on('ready',async () => {
const chalk = await (await import("chalk")).default const chalk = await (await import("chalk")).default