Code Cleanup & Improved channel rename errors

This commit is contained in:
DJj123dj
2026-05-15 22:30:24 +02:00
parent ca5faa3365
commit afd7f80b8d
49 changed files with 348 additions and 523 deletions
+3 -16
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET ADD USER SYSTEM //TICKET ADD USER SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -34,21 +34,8 @@ export async function registerActions(){
opendiscord.log("Failed to add channel permission overwrites on add-ticket-user","error") opendiscord.log("Failed to add channel permission overwrites on add-ticket-user","error")
} }
//update ticket message //update ticket message (no await)
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket) openticketUtils.updateTicketMessage(guild,channel,user,ticket)
if (ticketMessage){
try{
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message on ticket user adding!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"messageid",value:ticketMessage.id},
{key:"option",value:ticket.option.id.value,hidden:true}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
//reply with new message //reply with new message
if (params.sendMessage) await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:add-message").build(origin,{guild,channel,user,ticket,reason,data})).message) if (params.sendMessage) await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:add-message").build(origin,{guild,channel,user,ticket,reason,data})).message)
+1 -1
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//CALCULATE TICKET CATEGORY SYSTEM //CALCULATE TICKET CATEGORY SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
+1 -1
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//CALCULATE TICKET NAME SYSTEM //CALCULATE TICKET NAME SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
+5 -17
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET CLAIMING SYSTEM //TICKET CLAIMING SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -39,7 +39,8 @@ export async function registerActions(){
ticket.get("opendiscord:category-mode").value = categoryResult.newCategoryMode ticket.get("opendiscord:category-mode").value = categoryResult.newCategoryMode
ticket.get("opendiscord:category").value = categoryResult.newCategoryId ticket.get("opendiscord:category").value = categoryResult.newCategoryId
}catch(err){ }catch(err){
await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-category").build("ticket-claim",{guild,channel,user,originalCategory:originalCategoryName,newCategory:newCategoryName})).message) const sentMsg = await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-category").build("ticket-claim",{guild,channel,user,originalCategory:originalCategoryName,newCategory:newCategoryName})).message)
setTimeout(() => {if (sentMsg.deletable) sentMsg.delete()},7000) //autodelete error message
opendiscord.log("Unable to move ticket to claimed category.","error",[ opendiscord.log("Unable to move ticket to claimed category.","error",[
{key:"channel",value:"#"+channel.name}, {key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true}, {key:"channelid",value:channel.id,hidden:true},
@@ -49,21 +50,8 @@ export async function registerActions(){
} }
} }
//update ticket message //update ticket message (no await)
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket) openticketUtils.updateTicketMessage(guild,channel,user,ticket)
if (ticketMessage){
try{
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message on ticket claiming!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"messageid",value:ticketMessage.id},
{key:"option",value:ticket.option.id.value}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
//reply with new message //reply with new message
if (params.sendMessage){ if (params.sendMessage){
+1 -1
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//CLEAR TICKETS SYSTEM //CLEAR TICKETS SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
+5 -17
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET CLOSING SYSTEM //TICKET CLOSING SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -47,7 +47,8 @@ export async function registerActions(){
ticket.get("opendiscord:category-mode").value = categoryResult.newCategoryMode ticket.get("opendiscord:category-mode").value = categoryResult.newCategoryMode
ticket.get("opendiscord:category").value = categoryResult.newCategoryId ticket.get("opendiscord:category").value = categoryResult.newCategoryId
}catch(err){ }catch(err){
await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-category").build("ticket-close",{guild,channel,user,originalCategory:originalCategoryName,newCategory:newCategoryName})).message) const sentMsg = await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-category").build("ticket-close",{guild,channel,user,originalCategory:originalCategoryName,newCategory:newCategoryName})).message)
setTimeout(() => {if (sentMsg.deletable) sentMsg.delete()},7000) //autodelete error message
opendiscord.log("Unable to move ticket to closed category.","error",[ opendiscord.log("Unable to move ticket to closed category.","error",[
{key:"channel",value:"#"+channel.name}, {key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true}, {key:"channelid",value:channel.id,hidden:true},
@@ -114,21 +115,8 @@ export async function registerActions(){
}) })
channel.permissionOverwrites.set(permissions) channel.permissionOverwrites.set(permissions)
//update ticket message //update ticket message (no await)
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket) openticketUtils.updateTicketMessage(guild,channel,user,ticket)
if (ticketMessage){
try{
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message on ticket closing!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"messageid",value:ticketMessage.id},
{key:"option",value:ticket.option.id.value}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
//reply with new message //reply with new message
if (params.sendMessage){ if (params.sendMessage){
+1 -1
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET CREATION SYSTEM //TICKET CREATION SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
+1 -1
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET CREATION SYSTEM //TICKET CREATION SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
export async function registerActions(){ export async function registerActions(){
+1 -1
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TRANSCRIPT CREATION SYSTEM //TRANSCRIPT CREATION SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const transcriptConfig = opendiscord.configs.get("opendiscord:transcripts") const transcriptConfig = opendiscord.configs.get("opendiscord:transcripts")
+3 -16
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET DELETION SYSTEM //TICKET DELETION SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -20,21 +20,8 @@ export async function registerActions(){
ticket.get("opendiscord:for-deletion").value = true ticket.get("opendiscord:for-deletion").value = true
ticket.get("opendiscord:busy").value = true ticket.get("opendiscord:busy").value = true
//update ticket message //update ticket message (no await)
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket) openticketUtils.updateTicketMessage(guild,channel,user,ticket)
if (ticketMessage){
try{
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message on ticket deletion!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"messageid",value:ticketMessage.id},
{key:"option",value:ticket.option.id.value}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
if (params.sendMessage) await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:delete-message").build(origin,{guild,channel,user,ticket,reason})).message) if (params.sendMessage) await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:delete-message").build(origin,{guild,channel,user,ticket,reason})).message)
+10 -10
View File
@@ -1,8 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//TRANSCRIPT ERROR SYSTEM //TRANSCRIPT ERROR SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as actionUtils from "../actions/utilities.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -14,16 +14,16 @@ export async function registerButtonResponders(){
const {guild,channel,user,member} = instance const {guild,channel,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"delete") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"delete")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
//fetch data //fetch data
@@ -57,16 +57,16 @@ export async function registerButtonResponders(){
const {guild,channel,user} = instance const {guild,channel,user} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"delete") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"delete")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
//fetch data //fetch data
+2 -1
View File
@@ -1,7 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//VERIFYBAR SYSTEM //VERIFYBAR SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js"
export async function registerButtonResponders(){ export async function registerButtonResponders(){
//HANDLE VERIFYBAR BUTTON //HANDLE VERIFYBAR BUTTON
+7 -18
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET MOVING SYSTEM //TICKET MOVING SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -32,7 +32,8 @@ export async function registerActions(){
ticket.get("opendiscord:category-mode").value = categoryResult.newCategoryMode ticket.get("opendiscord:category-mode").value = categoryResult.newCategoryMode
ticket.get("opendiscord:category").value = categoryResult.newCategoryId ticket.get("opendiscord:category").value = categoryResult.newCategoryId
}catch(err){ }catch(err){
await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-category").build("ticket-move",{guild,channel,user,originalCategory:originalCategoryName,newCategory:newCategoryName})).message) const sentMsg = await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-category").build("ticket-move",{guild,channel,user,originalCategory:originalCategoryName,newCategory:newCategoryName})).message)
setTimeout(() => {if (sentMsg.deletable) sentMsg.delete()},7000) //autodelete error message
opendiscord.log("Unable to move ticket to moved category.","error",[ opendiscord.log("Unable to move ticket to moved category.","error",[
{key:"channel",value:"#"+channel.name}, {key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true}, {key:"channelid",value:channel.id,hidden:true},
@@ -119,25 +120,13 @@ export async function registerActions(){
{key:"oldName",value:originalName}, {key:"oldName",value:originalName},
{key:"newName",value:newName} {key:"newName",value:newName}
]) ])
await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-rename").build("ticket-move",{guild,channel,user,originalName,newName})).message) const sentMsg = await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-rename").build("ticket-move",{guild,channel,user,originalName,newName})).message)
setTimeout(() => {if (sentMsg.deletable) sentMsg.delete()},7000) //autodelete error message
} }
} }
//update ticket message //update ticket message (no await)
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket) openticketUtils.updateTicketMessage(guild,channel,user,ticket)
if (ticketMessage){
try{
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message on ticket moving!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"messageid",value:ticketMessage.id},
{key:"option",value:ticket.option.id.value}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
//reply with new message //reply with new message
if (params.sendMessage) await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:move-message").build(origin,{guild,channel,user,ticket,reason,data})).message) if (params.sendMessage) await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:move-message").build(origin,{guild,channel,user,ticket,reason,data})).message)
+5 -17
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET PINNING SYSTEM //TICKET PINNING SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -45,25 +45,13 @@ export async function registerActions(){
{key:"oldName",value:originalName}, {key:"oldName",value:originalName},
{key:"newName",value:newName} {key:"newName",value:newName}
]) ])
await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-rename").build("ticket-pin",{guild,channel,user,originalName,newName})).message) const sentMsg = await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-rename").build("ticket-pin",{guild,channel,user,originalName,newName})).message)
setTimeout(() => {if (sentMsg.deletable) sentMsg.delete()},7000) //autodelete error message
} }
} }
//update ticket message //update ticket message (no await)
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket) openticketUtils.updateTicketMessage(guild,channel,user,ticket)
if (ticketMessage){
try{
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message on ticket pinning!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"message",value:ticketMessage.id},
{key:"option",value:ticket.option.id.value}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
//reply with new message //reply with new message
if (params.sendMessage){ if (params.sendMessage){
+1 -1
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//REACTION ROLE SYSTEM //REACTION ROLE SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
+3 -15
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET REMOVE USER SYSTEM //TICKET REMOVE USER SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -29,20 +29,8 @@ export async function registerActions(){
opendiscord.log("Failed to remove channel permission overwrites on remove-ticket-user","error") opendiscord.log("Failed to remove channel permission overwrites on remove-ticket-user","error")
} }
//update ticket message //update ticket message (no await)
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket) openticketUtils.updateTicketMessage(guild,channel,user,ticket)
if (ticketMessage){
try{
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message on ticket user removal!","error",[
{key:"channel",value:channel.id},
{key:"message",value:ticketMessage.id},
{key:"option",value:ticket.option.id.value}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
//reply with new message //reply with new message
if (params.sendMessage) await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:remove-message").build(origin,{guild,channel,user,ticket,reason,data})).message) if (params.sendMessage) await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:remove-message").build(origin,{guild,channel,user,ticket,reason,data})).message)
+5 -17
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET RENAMING SYSTEM //TICKET RENAMING SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -32,25 +32,13 @@ export async function registerActions(){
{key:"oldName",value:originalName}, {key:"oldName",value:originalName},
{key:"newName",value:newName} {key:"newName",value:newName}
]) ])
await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-rename").build("ticket-rename",{guild,channel,user,originalName,newName})).message) const sentMsg = await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-rename").build("ticket-rename",{guild,channel,user,originalName,newName})).message)
setTimeout(() => {if (sentMsg.deletable) sentMsg.delete()},7000) //autodelete error message
} }
} }
//update ticket message //update ticket message (no await)
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket) openticketUtils.updateTicketMessage(guild,channel,user,ticket)
if (ticketMessage){
try{
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message on ticket renaming!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"messageid",value:ticketMessage.id},
{key:"option",value:ticket.option.id.value}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
//reply with new message //reply with new message
if (params.sendMessage) await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:rename-message").build(origin,{guild,channel,user,ticket,reason,data})).message) if (params.sendMessage) await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:rename-message").build(origin,{guild,channel,user,ticket,reason,data})).message)
+5 -17
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET REOPENING SYSTEM //TICKET REOPENING SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -52,7 +52,8 @@ export async function registerActions(){
ticket.get("opendiscord:category-mode").value = categoryResult.newCategoryMode ticket.get("opendiscord:category-mode").value = categoryResult.newCategoryMode
ticket.get("opendiscord:category").value = categoryResult.newCategoryId ticket.get("opendiscord:category").value = categoryResult.newCategoryId
}catch(err){ }catch(err){
await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-category").build("ticket-reopen",{guild,channel,user,originalCategory:originalCategoryName,newCategory:newCategoryName})).message) const sentMsg = await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-category").build("ticket-reopen",{guild,channel,user,originalCategory:originalCategoryName,newCategory:newCategoryName})).message)
setTimeout(() => {if (sentMsg.deletable) sentMsg.delete()},7000) //autodelete error message
opendiscord.log("Unable to move ticket to reopened category.","error",[ opendiscord.log("Unable to move ticket to reopened category.","error",[
{key:"channel",value:"#"+channel.name}, {key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true}, {key:"channelid",value:channel.id,hidden:true},
@@ -113,21 +114,8 @@ export async function registerActions(){
}) })
channel.permissionOverwrites.set(permissions) channel.permissionOverwrites.set(permissions)
//update ticket message //update ticket message (no await)
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket) openticketUtils.updateTicketMessage(guild,channel,user,ticket)
if (ticketMessage){
try{
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message on ticket reopening!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"messageid",value:ticketMessage.id},
{key:"option",value:ticket.option.id.value}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
if (params.sendMessage){ if (params.sendMessage){
const sentMsg = await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:reopen-message").build(origin,{guild,channel,user,ticket,reason})).message) const sentMsg = await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:reopen-message").build(origin,{guild,channel,user,ticket,reason})).message)
+5 -17
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET TRANSFER SYSTEM //TICKET TRANSFER SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -103,25 +103,13 @@ export async function registerActions(){
{key:"oldName",value:originalName}, {key:"oldName",value:originalName},
{key:"newName",value:newName} {key:"newName",value:newName}
]) ])
await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-rename").build("ticket-transfer",{guild,channel,user,originalName,newName})).message) const sentMsg = await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-rename").build("ticket-transfer",{guild,channel,user,originalName,newName})).message)
setTimeout(() => {if (sentMsg.deletable) sentMsg.delete()},7000) //autodelete error message
} }
} }
//update ticket message //update ticket message (no await)
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket) openticketUtils.updateTicketMessage(guild,channel,user,ticket)
if (ticketMessage){
try{
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message on ticket transferring!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"messageid",value:ticketMessage.id},
{key:"option",value:ticket.option.id.value}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
//reply with new message //reply with new message
if (params.sendMessage) await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:transfer-message").build(origin,{guild,channel,user,ticket,oldCreator,newCreator,reason})).message) if (params.sendMessage) await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:transfer-message").build(origin,{guild,channel,user,ticket,oldCreator,newCreator,reason})).message)
+5 -17
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET UNCLAIMING SYSTEM //TICKET UNCLAIMING SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -35,7 +35,8 @@ export async function registerActions(){
ticket.get("opendiscord:category-mode").value = categoryResult.newCategoryMode ticket.get("opendiscord:category-mode").value = categoryResult.newCategoryMode
ticket.get("opendiscord:category").value = categoryResult.newCategoryId ticket.get("opendiscord:category").value = categoryResult.newCategoryId
}catch(err){ }catch(err){
await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-category").build("ticket-unclaim",{guild,channel,user,originalCategory:originalCategoryName,newCategory:newCategoryName})).message) const sentMsg = await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-category").build("ticket-unclaim",{guild,channel,user,originalCategory:originalCategoryName,newCategory:newCategoryName})).message)
setTimeout(() => {if (sentMsg.deletable) sentMsg.delete()},7000) //autodelete error message
opendiscord.log("Unable to move ticket to unclaimed category.","error",[ opendiscord.log("Unable to move ticket to unclaimed category.","error",[
{key:"channel",value:"#"+channel.name}, {key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true}, {key:"channelid",value:channel.id,hidden:true},
@@ -45,21 +46,8 @@ export async function registerActions(){
} }
} }
//update ticket message //update ticket message (no await)
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket) openticketUtils.updateTicketMessage(guild,channel,user,ticket)
if (ticketMessage){
try{
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message on ticket unclaiming!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"messageid",value:ticketMessage.id},
{key:"option",value:ticket.option.id.value}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
//reply with new message //reply with new message
if (params.sendMessage){ if (params.sendMessage){
+5 -17
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET UNPINNING SYSTEM //TICKET UNPINNING SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -36,25 +36,13 @@ export async function registerActions(){
{key:"oldName",value:originalName}, {key:"oldName",value:originalName},
{key:"newName",value:newName} {key:"newName",value:newName}
]) ])
await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-rename").build("ticket-unpin",{guild,channel,user,originalName,newName})).message) const sentMsg = await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-rename").build("ticket-unpin",{guild,channel,user,originalName,newName})).message)
setTimeout(() => {if (sentMsg.deletable) sentMsg.delete()},7000) //autodelete error message
} }
} }
//update ticket message //update ticket message (no await)
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket) openticketUtils.updateTicketMessage(guild,channel,user,ticket)
if (ticketMessage){
try{
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message on ticket unpinning!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"messageid",value:ticketMessage.id},
{key:"option",value:ticket.option.id.value}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
//reply with new message //reply with new message
if (params.sendMessage){ if (params.sendMessage){
+3 -2
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET TOPIC SYSTEM //TICKET TOPIC SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -34,7 +34,8 @@ export async function registerActions(){
{key:"oldName",value:originalName}, {key:"oldName",value:originalName},
{key:"newName",value:newName} {key:"newName",value:newName}
]) ])
await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-rename").build("ticket-priority",{guild,channel,user,originalName,newName})).message) const sentMsg = await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-rename").build("ticket-priority",{guild,channel,user,originalName,newName})).message)
setTimeout(() => {if (sentMsg.deletable) sentMsg.delete()},7000) //autodelete error message
} }
} }
+1 -1
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET TOPIC SYSTEM //TICKET TOPIC SYSTEM
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
+19 -3
View File
@@ -1,11 +1,9 @@
/////////////////////////////////////// ///////////////////////////////////////
//ACTION UTILITY FUNCTIONS //OPEN TICKET UTILITY FUNCTIONS
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
const lang = opendiscord.languages
/**Fetch the interactive message state. If not present, auto replies with error and returns `null`. When `null` is received, the worker should be returned and canceled. */ /**Fetch the interactive message state. If not present, auto replies with error and returns `null`. When `null` is received, the worker should be returned and canceled. */
export async function replyInteractiveMessageState(instance:api.ODButtonResponderInstance|api.ODDropdownResponderInstance|api.ODModalResponderInstance,origin:"slash"|"text"|"button"|"dropdown"|"modal"|"other",channel:discord.TextBasedChannel,message:discord.Message|null,replacementCommandName:string){ export async function replyInteractiveMessageState(instance:api.ODButtonResponderInstance|api.ODDropdownResponderInstance|api.ODModalResponderInstance,origin:"slash"|"text"|"button"|"dropdown"|"modal"|"other",channel:discord.TextBasedChannel,message:discord.Message|null,replacementCommandName:string){
//check message state //check message state
@@ -140,6 +138,7 @@ export async function replyMessageMustBeSentBeforeClose(instance:api.ODButtonRes
//return when not allowed because of missing messages //return when not allowed because of missing messages
const {user,member,channel,guild} = instance const {user,member,channel,guild} = instance
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages
const permsResult = await opendiscord.permissions.checkCommandPerms(generalConfig.data.system.permissions[commandName],"support",user,member,channel,guild) const permsResult = await opendiscord.permissions.checkCommandPerms(generalConfig.data.system.permissions[commandName],"support",user,member,channel,guild)
if (!permsResult.hasPerms) throw new api.ODSystemError("Please check permissions before using replyMessageMustBeSentBeforeClose()") if (!permsResult.hasPerms) throw new api.ODSystemError("Please check permissions before using replyMessageMustBeSentBeforeClose()")
@@ -157,4 +156,21 @@ export async function replyMessageMustBeSentBeforeClose(instance:api.ODButtonRes
} }
return true return true
}else return true }else return true
}
/**Update the ticket message from a given ticket channel. This should be used after every change to the `ODTicket` after an action. */
export async function updateTicketMessage(guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,ticket:api.ODTicket){
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket)
if (!ticketMessage || !user || !channel || !guild || channel.isDMBased()) return
try{
await ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"messageid",value:ticketMessage.id},
{key:"option",value:ticket.option.id.value}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
} }
+4 -4
View File
@@ -338,8 +338,8 @@ const errorEmbeds = () => {
instance.setDescription(lang.getTranslation("errors.descriptions.channelRename")) instance.setDescription(lang.getTranslation("errors.descriptions.channelRename"))
instance.setFooter(lang.getTranslationWithParams("errors.descriptions.channelRenameSource",[method])) instance.setFooter(lang.getTranslationWithParams("errors.descriptions.channelRenameSource",[method]))
instance.addFields( instance.addFields(
{name:lang.getTranslation("params.uppercase.originalName")+":",value:"```#"+originalName+"```",inline:false}, {name:lang.getTranslation("params.uppercase.originalName")+":",value:"```#"+originalName+"```",inline:true},
{name:lang.getTranslation("params.uppercase.newName")+":",value:"```#"+newName+"```",inline:false} {name:lang.getTranslation("params.uppercase.newName")+":",value:"```#"+newName+"```",inline:true}
) )
}) })
) )
@@ -361,9 +361,9 @@ const errorEmbeds = () => {
instance.setFooter(lang.getTranslationWithParams("errors.descriptions.channelRenameSource",[method])) instance.setFooter(lang.getTranslationWithParams("errors.descriptions.channelRenameSource",[method]))
instance.addFields( instance.addFields(
//TODO TRANSLATION!!! //TODO TRANSLATION!!!
{name:"Original Category"+":",value:"```"+originalCategory+"```",inline:false}, {name:"Original Category"+":",value:"```"+originalCategory+"```",inline:true},
//TODO TRANSLATION!!! //TODO TRANSLATION!!!
{name:"New Category"+":",value:"```"+newCategory+"```",inline:false} {name:"New Category"+":",value:"```"+newCategory+"```",inline:true}
) )
}) })
) )
+5 -6
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//ADD COMMAND //ADD COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance const {guild,channel,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"add") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"add")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
//fetch data //fetch data
+8 -22
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//AUTOCLOSE COMMAND //AUTOCLOSE COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,19 +14,19 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance const {guild,channel,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"autoclose") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"autoclose")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketOpen = await actionUtils.replyTicketMustBeOpen(instance,origin,ticket) const isTicketOpen = await openticketUtils.replyTicketMustBeOpen(instance,origin,ticket)
if (!isTicketOpen) return cancel() if (!isTicketOpen) return cancel()
//subcommands //subcommands
@@ -48,21 +47,8 @@ export async function registerCommandResponders(){
await instance.reply(await opendiscord.builders.messages.getSafe("opendiscord:autoclose-enable").build(origin,{guild,channel,user,ticket,reason,time})) await instance.reply(await opendiscord.builders.messages.getSafe("opendiscord:autoclose-enable").build(origin,{guild,channel,user,ticket,reason,time}))
} }
//update ticket message //update ticket message (no await)
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket) openticketUtils.updateTicketMessage(guild,channel,user,ticket)
if (ticketMessage){
try{
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message on autoclose "+scope+"!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"messageid",value:ticketMessage.id},
{key:"option",value:ticket.option.id.value}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
}), }),
new api.ODWorker("opendiscord:logs",-1,(instance,params,origin,cancel) => { new api.ODWorker("opendiscord:logs",-1,(instance,params,origin,cancel) => {
const scope = instance.options.getSubCommand() const scope = instance.options.getSubCommand()
+7 -21
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//AUTODELETE COMMAND //AUTODELETE COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance const {guild,channel,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"autodelete") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"autodelete")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
//subcommands //subcommands
@@ -45,21 +44,8 @@ export async function registerCommandResponders(){
await instance.reply(await opendiscord.builders.messages.getSafe("opendiscord:autodelete-enable").build(origin,{guild,channel,user,ticket,reason,time})) await instance.reply(await opendiscord.builders.messages.getSafe("opendiscord:autodelete-enable").build(origin,{guild,channel,user,ticket,reason,time}))
} }
//update ticket message //update ticket message (no await)
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket) openticketUtils.updateTicketMessage(guild,channel,user,ticket)
if (ticketMessage){
try{
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message on autodelete "+scope+"!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"messageid",value:ticketMessage.id},
{key:"option",value:ticket.option.id.value}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
}), }),
new api.ODWorker("opendiscord:logs",-1,(instance,params,origin,cancel) => { new api.ODWorker("opendiscord:logs",-1,(instance,params,origin,cancel) => {
const scope = instance.options.getSubCommand() const scope = instance.options.getSubCommand()
+1 -2
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//BLACKLIST COMMAND //BLACKLIST COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
+24 -25
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//CLAIM COMMAND //CLAIM COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages const lang = opendiscord.languages
@@ -17,19 +16,19 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance const {guild,channel,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"claim") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"claim")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketUnclaimed = await actionUtils.replyTicketMustBeUnclaimed(instance,origin,ticket) const isTicketUnclaimed = await openticketUtils.replyTicketMustBeUnclaimed(instance,origin,ticket)
if (!isTicketUnclaimed) return cancel() if (!isTicketUnclaimed) return cancel()
//start claiming ticket //start claiming ticket
@@ -66,22 +65,22 @@ export async function registerButtonResponders(){
const {guild,channel,user,message} = instance const {guild,channel,user,message} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"claim") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"claim")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/claim") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/claim")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketUnclaimed = await actionUtils.replyTicketMustBeUnclaimed(instance,origin,ticket) const isTicketUnclaimed = await openticketUtils.replyTicketMustBeUnclaimed(instance,origin,ticket)
if (!isTicketUnclaimed) return cancel() if (!isTicketUnclaimed) return cancel()
//fetch state details //fetch state details
@@ -116,22 +115,22 @@ export async function registerVerifyBars(){
const {user,member,channel,guild,message} = instance const {user,member,channel,guild,message} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"claim") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"claim")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/claim") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/claim")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketUnclaimed = await actionUtils.replyTicketMustBeUnclaimed(instance,origin,ticket) const isTicketUnclaimed = await openticketUtils.replyTicketMustBeUnclaimed(instance,origin,ticket)
if (!isTicketUnclaimed) return cancel() if (!isTicketUnclaimed) return cancel()
//fetch state details //fetch state details
@@ -189,22 +188,22 @@ export async function registerModalResponders(){
const message = await opendiscord.client.fetchChannelMessage(match[1],match[2]) const message = await opendiscord.client.fetchChannelMessage(match[1],match[2])
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"claim") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"claim")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel() if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/claim") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/claim")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketUnclaimed = await actionUtils.replyTicketMustBeUnclaimed(instance,origin,ticket) const isTicketUnclaimed = await openticketUtils.replyTicketMustBeUnclaimed(instance,origin,ticket)
if (!isTicketUnclaimed) return cancel() if (!isTicketUnclaimed) return cancel()
//fetch state details //fetch state details
+5 -6
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//CLEAR COMMAND //CLEAR COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
const clearMsgState = opendiscord.states.get("opendiscord:clear-message") const clearMsgState = opendiscord.states.get("opendiscord:clear-message")
@@ -17,10 +16,10 @@ export async function registerCommandResponders(){
//responder checks //responder checks
//check permissions (only allow global admins: ticket admins aren't allowed to clear tickets) //check permissions (only allow global admins: ticket admins aren't allowed to clear tickets)
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"clear",{allowChannelUserScope:false,allowChannelRoleScope:false}) const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"clear",{allowChannelUserScope:false,allowChannelRoleScope:false})
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
//fetch data //fetch data
@@ -79,10 +78,10 @@ export async function registerButtonResponders(){
} }
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"clear") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"clear")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel() if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel()
//fetch state details //fetch state details
+27 -28
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//CLOSE COMMAND //CLOSE COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages const lang = opendiscord.languages
@@ -17,22 +16,22 @@ export async function registerCommandResponders(){
const {user,member,channel,guild} = instance const {user,member,channel,guild} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"close") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"close")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketOpen = await actionUtils.replyTicketMustBeOpen(instance,origin,ticket) const isTicketOpen = await openticketUtils.replyTicketMustBeOpen(instance,origin,ticket)
if (!isTicketOpen) return cancel() if (!isTicketOpen) return cancel()
const messagesHaveBeenSent = await actionUtils.replyMessageMustBeSentBeforeClose(instance,origin,ticket,"close") const messagesHaveBeenSent = await openticketUtils.replyMessageMustBeSentBeforeClose(instance,origin,ticket,"close")
if (!messagesHaveBeenSent) return cancel() if (!messagesHaveBeenSent) return cancel()
//start closing ticket //start closing ticket
@@ -68,25 +67,25 @@ export async function registerButtonResponders(){
const {guild,channel,message,user,member} = instance const {guild,channel,message,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"close") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"close")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/close") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/close")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketOpen = await actionUtils.replyTicketMustBeOpen(instance,origin,ticket) const isTicketOpen = await openticketUtils.replyTicketMustBeOpen(instance,origin,ticket)
if (!isTicketOpen) return cancel() if (!isTicketOpen) return cancel()
const messagesHaveBeenSent = await actionUtils.replyMessageMustBeSentBeforeClose(instance,origin,ticket,"close") const messagesHaveBeenSent = await openticketUtils.replyMessageMustBeSentBeforeClose(instance,origin,ticket,"close")
if (!messagesHaveBeenSent) return cancel() if (!messagesHaveBeenSent) return cancel()
//fetch state details //fetch state details
@@ -121,25 +120,25 @@ export async function registerVerifyBars(){
const {user,member,channel,guild,message} = instance const {user,member,channel,guild,message} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"close") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"close")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/close") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/close")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketOpen = await actionUtils.replyTicketMustBeOpen(instance,origin,ticket) const isTicketOpen = await openticketUtils.replyTicketMustBeOpen(instance,origin,ticket)
if (!isTicketOpen) return cancel() if (!isTicketOpen) return cancel()
const messagesHaveBeenSent = await actionUtils.replyMessageMustBeSentBeforeClose(instance,origin,ticket,"close") const messagesHaveBeenSent = await openticketUtils.replyMessageMustBeSentBeforeClose(instance,origin,ticket,"close")
if (!messagesHaveBeenSent) return cancel() if (!messagesHaveBeenSent) return cancel()
//fetch state details //fetch state details
@@ -197,22 +196,22 @@ export async function registerModalResponders(){
const message = await opendiscord.client.fetchChannelMessage(match[1],match[2]) const message = await opendiscord.client.fetchChannelMessage(match[1],match[2])
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"close") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"close")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel() if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/close") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/close")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketOpen = await actionUtils.replyTicketMustBeOpen(instance,origin,ticket) const isTicketOpen = await openticketUtils.replyTicketMustBeOpen(instance,origin,ticket)
if (!isTicketOpen) return cancel() if (!isTicketOpen) return cancel()
//fetch state details //fetch state details
+24 -25
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//DELETE COMMAND //DELETE COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages const lang = opendiscord.languages
@@ -17,22 +16,22 @@ export async function registerCommandResponders(){
const {user,member,channel,guild} = instance const {user,member,channel,guild} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"delete") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"delete")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketOpen = await actionUtils.replyTicketMustBeOpen(instance,origin,ticket) const isTicketOpen = await openticketUtils.replyTicketMustBeOpen(instance,origin,ticket)
if (!isTicketOpen) return cancel() if (!isTicketOpen) return cancel()
const messagesHaveBeenSent = await actionUtils.replyMessageMustBeSentBeforeClose(instance,origin,ticket,"delete") const messagesHaveBeenSent = await openticketUtils.replyMessageMustBeSentBeforeClose(instance,origin,ticket,"delete")
if (!messagesHaveBeenSent) return cancel() if (!messagesHaveBeenSent) return cancel()
//don't allow deleteWithoutTranscript to non-global-admins when enabled //don't allow deleteWithoutTranscript to non-global-admins when enabled
@@ -69,22 +68,22 @@ export async function registerButtonResponders(){
const {guild,channel,message,user,member} = instance const {guild,channel,message,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"delete") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"delete")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/delete") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/delete")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const messagesHaveBeenSent = await actionUtils.replyMessageMustBeSentBeforeClose(instance,origin,ticket,"delete") const messagesHaveBeenSent = await openticketUtils.replyMessageMustBeSentBeforeClose(instance,origin,ticket,"delete")
if (!messagesHaveBeenSent) return cancel() if (!messagesHaveBeenSent) return cancel()
//fetch state details //fetch state details
@@ -127,22 +126,22 @@ export async function registerVerifyBars(){
const {user,member,channel,guild,message} = instance const {user,member,channel,guild,message} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"delete") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"delete")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/delete") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/delete")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const messagesHaveBeenSent = await actionUtils.replyMessageMustBeSentBeforeClose(instance,origin,ticket,"delete") const messagesHaveBeenSent = await openticketUtils.replyMessageMustBeSentBeforeClose(instance,origin,ticket,"delete")
if (!messagesHaveBeenSent) return cancel() if (!messagesHaveBeenSent) return cancel()
//don't allow deleteWithoutTranscript to non-global-admins when enabled //don't allow deleteWithoutTranscript to non-global-admins when enabled
@@ -222,19 +221,19 @@ export async function registerModalResponders(){
const message = await opendiscord.client.fetchChannelMessage(match[1],match[2]) const message = await opendiscord.client.fetchChannelMessage(match[1],match[2])
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"delete") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"delete")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel() if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/delete") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/delete")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
//fetch state details //fetch state details
+2 -3
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//HELP COMMAND //HELP COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,7 +14,7 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance const {guild,channel,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"help") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"help")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
//calculate slash/text mode for help menu //calculate slash/text mode for help menu
+5 -6
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//MOVE COMMAND //MOVE COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance const {guild,channel,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"move") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"move")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
//fetch data //fetch data
+5 -6
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//STATS COMMAND //STATS COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance const {guild,channel,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"panel") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"panel")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
//fetch data //fetch data
+24 -25
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//PIN COMMAND //PIN COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages const lang = opendiscord.languages
@@ -17,19 +16,19 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance const {guild,channel,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"pin") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"pin")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketUnpinned = await actionUtils.replyTicketMustBeUnpinned(instance,origin,ticket) const isTicketUnpinned = await openticketUtils.replyTicketMustBeUnpinned(instance,origin,ticket)
if (!isTicketUnpinned) return cancel() if (!isTicketUnpinned) return cancel()
//start pinning ticket //start pinning ticket
@@ -65,22 +64,22 @@ export async function registerButtonResponders(){
const {guild,channel,user,message} = instance const {guild,channel,user,message} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"pin") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"pin")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/pin") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/pin")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketUnpinned = await actionUtils.replyTicketMustBeUnpinned(instance,origin,ticket) const isTicketUnpinned = await openticketUtils.replyTicketMustBeUnpinned(instance,origin,ticket)
if (!isTicketUnpinned) return cancel() if (!isTicketUnpinned) return cancel()
//fetch state details //fetch state details
@@ -116,22 +115,22 @@ export async function registerVerifyBars(){
const {user,member,channel,guild,message} = instance const {user,member,channel,guild,message} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"pin") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"pin")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/pin") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/pin")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketUnpinned = await actionUtils.replyTicketMustBeUnpinned(instance,origin,ticket) const isTicketUnpinned = await openticketUtils.replyTicketMustBeUnpinned(instance,origin,ticket)
if (!isTicketUnpinned) return cancel() if (!isTicketUnpinned) return cancel()
//fetch state details //fetch state details
@@ -189,22 +188,22 @@ export async function registerModalResponders(){
const message = await opendiscord.client.fetchChannelMessage(match[1],match[2]) const message = await opendiscord.client.fetchChannelMessage(match[1],match[2])
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"pin") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"pin")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel() if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/pin") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/pin")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketUnpinned = await actionUtils.replyTicketMustBeUnpinned(instance,origin,ticket) const isTicketUnpinned = await openticketUtils.replyTicketMustBeUnpinned(instance,origin,ticket)
if (!isTicketUnpinned) return cancel() if (!isTicketUnpinned) return cancel()
//fetch state details //fetch state details
+5 -6
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//PRIORITY COMMAND //PRIORITY COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance const {guild,channel,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"priority") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"priority")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
//subcommands //subcommands
+5 -6
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//REMOVE COMMAND //REMOVE COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance const {guild,channel,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"remove") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"remove")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
//fetch data //fetch data
+5 -6
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//RENAME COMMAND //RENAME COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance const {guild,channel,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"rename") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"rename")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
//fetch data //fetch data
+24 -25
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//REOPEN COMMAND //REOPEN COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages const lang = opendiscord.languages
@@ -17,19 +16,19 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance const {guild,channel,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"reopen") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"reopen")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketClosed = await actionUtils.replyTicketMustBeClosed(instance,origin,ticket) const isTicketClosed = await openticketUtils.replyTicketMustBeClosed(instance,origin,ticket)
if (!isTicketClosed) return cancel() if (!isTicketClosed) return cancel()
//start reopening ticket //start reopening ticket
@@ -65,22 +64,22 @@ export async function registerButtonResponders(){
const {guild,channel,message,user,member} = instance const {guild,channel,message,user,member} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"reopen") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"reopen")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/reopen") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/reopen")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketClosed = await actionUtils.replyTicketMustBeClosed(instance,origin,ticket) const isTicketClosed = await openticketUtils.replyTicketMustBeClosed(instance,origin,ticket)
if (!isTicketClosed) return cancel() if (!isTicketClosed) return cancel()
//fetch state details //fetch state details
@@ -119,22 +118,22 @@ export async function registerVerifyBars(){
const {user,member,channel,guild,message} = instance const {user,member,channel,guild,message} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"reopen") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"reopen")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/reopen") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/reopen")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketClosed = await actionUtils.replyTicketMustBeClosed(instance,origin,ticket) const isTicketClosed = await openticketUtils.replyTicketMustBeClosed(instance,origin,ticket)
if (!isTicketClosed) return cancel() if (!isTicketClosed) return cancel()
//fetch state details //fetch state details
@@ -205,22 +204,22 @@ export async function registerModalResponders(){
const message = await opendiscord.client.fetchChannelMessage(match[1],match[2]) const message = await opendiscord.client.fetchChannelMessage(match[1],match[2])
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"reopen") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"reopen")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel() if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/reopen") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/reopen")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketClosed = await actionUtils.replyTicketMustBeClosed(instance,origin,ticket) const isTicketClosed = await openticketUtils.replyTicketMustBeClosed(instance,origin,ticket)
if (!isTicketClosed) return cancel() if (!isTicketClosed) return cancel()
//fetch state details //fetch state details
+2 -3
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//ROLE BUTTON (not command) //ROLE BUTTON (not command)
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,7 +14,7 @@ export async function registerButtonResponders(){
const {guild,channel,user} = instance const {guild,channel,user} = instance
//responder checks //responder checks
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
//get option data //get option data
+3 -4
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//STATS COMMAND //STATS COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -21,12 +20,12 @@ export async function registerCommandResponders(){
return cancel() return cancel()
}else{ }else{
//default permissions check //default permissions check
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"stats") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"stats")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
} }
//responder checks //responder checks
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
//subcommands //subcommands
+6 -7
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//TICKET COMMAND //TICKET COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages const lang = opendiscord.languages
@@ -34,10 +33,10 @@ export async function registerCommandResponders(){
const {user,member,channel,guild} = instance const {user,member,channel,guild} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"ticket") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"ticket")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
//get option data //get option data
@@ -86,7 +85,7 @@ export async function registerButtonResponders(){
const {guild,channel,user} = instance const {guild,channel,user} = instance
//responder checks //responder checks
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
//get option data //get option data
@@ -128,7 +127,7 @@ export async function registerDropdownResponders(){
const {guild,channel,user} = instance const {guild,channel,user} = instance
//responder checks //responder checks
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
//get option data //get option data
@@ -178,7 +177,7 @@ export async function registerModalResponders(){
const {guild,channel,user} = instance const {guild,channel,user} = instance
//responder checks //responder checks
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel() if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel()
//get option data //get option data
+5 -6
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//TOPIC COMMAND //TOPIC COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -14,16 +13,16 @@ export async function registerCommandResponders(){
new api.ODWorker("opendiscord:topic",0,async (instance,params,origin,cancel) => { new api.ODWorker("opendiscord:topic",0,async (instance,params,origin,cancel) => {
const {user,member,channel,guild} = instance const {user,member,channel,guild} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"topic") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"topic")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
//subcommands //subcommands
+5 -6
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//TRANSFER COMMAND //TRANSFER COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {user,member,channel,guild} = instance const {user,member,channel,guild} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"transfer") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"transfer")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
//fetch data //fetch data
+24 -25
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//UNCLAIM COMMAND //UNCLAIM COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages const lang = opendiscord.languages
@@ -17,19 +16,19 @@ export async function registerCommandResponders(){
const {user,member,channel,guild} = instance const {user,member,channel,guild} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unclaim") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unclaim")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketClaimed = await actionUtils.replyTicketMustBeClaimed(instance,origin,ticket) const isTicketClaimed = await openticketUtils.replyTicketMustBeClaimed(instance,origin,ticket)
if (!isTicketClaimed) return cancel() if (!isTicketClaimed) return cancel()
//start unclaiming ticket //start unclaiming ticket
@@ -65,22 +64,22 @@ export async function registerButtonResponders(){
const {guild,channel,user,message} = instance const {guild,channel,user,message} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unclaim") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unclaim")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unclaim") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unclaim")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketClaimed = await actionUtils.replyTicketMustBeClaimed(instance,origin,ticket) const isTicketClaimed = await openticketUtils.replyTicketMustBeClaimed(instance,origin,ticket)
if (!isTicketClaimed) return cancel() if (!isTicketClaimed) return cancel()
//fetch state details //fetch state details
@@ -115,22 +114,22 @@ export async function registerVerifyBars(){
const {user,member,channel,guild,message} = instance const {user,member,channel,guild,message} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unclaim") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unclaim")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unclaim") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unclaim")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketClaimed = await actionUtils.replyTicketMustBeClaimed(instance,origin,ticket) const isTicketClaimed = await openticketUtils.replyTicketMustBeClaimed(instance,origin,ticket)
if (!isTicketClaimed) return cancel() if (!isTicketClaimed) return cancel()
//fetch state details //fetch state details
@@ -188,22 +187,22 @@ export async function registerModalResponders(){
const message = await opendiscord.client.fetchChannelMessage(match[1],match[2]) const message = await opendiscord.client.fetchChannelMessage(match[1],match[2])
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unclaim") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unclaim")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel() if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unclaim") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unclaim")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketClaimed = await actionUtils.replyTicketMustBeClaimed(instance,origin,ticket) const isTicketClaimed = await openticketUtils.replyTicketMustBeClaimed(instance,origin,ticket)
if (!isTicketClaimed) return cancel() if (!isTicketClaimed) return cancel()
//fetch state details //fetch state details
+24 -25
View File
@@ -1,9 +1,8 @@
/////////////////////////////////////// ///////////////////////////////////////
//UNPIN COMMAND //UNPIN COMMAND
/////////////////////////////////////// ///////////////////////////////////////
import {opendiscord, api, utilities} from "../index.js" import {opendiscord, api, utilities, openticketUtils} from "../index.js"
import * as discord from "discord.js" import * as discord from "discord.js"
import * as actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages const lang = opendiscord.languages
@@ -17,19 +16,19 @@ export async function registerCommandResponders(){
const {user,member,channel,guild} = instance const {user,member,channel,guild} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unpin") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unpin")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketPinned = await actionUtils.replyTicketMustBePinned(instance,origin,ticket) const isTicketPinned = await openticketUtils.replyTicketMustBePinned(instance,origin,ticket)
if (!isTicketPinned) return cancel() if (!isTicketPinned) return cancel()
//start unpining ticket //start unpining ticket
@@ -65,22 +64,22 @@ export async function registerButtonResponders(){
const {guild,channel,user,message} = instance const {guild,channel,user,message} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unpin") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unpin")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unpin") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unpin")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketPinned = await actionUtils.replyTicketMustBePinned(instance,origin,ticket) const isTicketPinned = await openticketUtils.replyTicketMustBePinned(instance,origin,ticket)
if (!isTicketPinned) return cancel() if (!isTicketPinned) return cancel()
//fetch state details //fetch state details
@@ -115,22 +114,22 @@ export async function registerVerifyBars(){
const {user,member,channel,guild,message} = instance const {user,member,channel,guild,message} = instance
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unpin") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unpin")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel() if (!isInGuild || !guild || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unpin") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unpin")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketPinned = await actionUtils.replyTicketMustBePinned(instance,origin,ticket) const isTicketPinned = await openticketUtils.replyTicketMustBePinned(instance,origin,ticket)
if (!isTicketPinned) return cancel() if (!isTicketPinned) return cancel()
//fetch state details //fetch state details
@@ -188,22 +187,22 @@ export async function registerModalResponders(){
const message = await opendiscord.client.fetchChannelMessage(match[1],match[2]) const message = await opendiscord.client.fetchChannelMessage(match[1],match[2])
//responder checks //responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unpin") const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unpin")
if (!hasPerms) return cancel() if (!hasPerms) return cancel()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin) const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel() if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unpin") const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unpin")
if (!state) return cancel() if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin) const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel() if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket) const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel() if (!isAvailable) return cancel()
const isTicketPinned = await actionUtils.replyTicketMustBePinned(instance,origin,ticket) const isTicketPinned = await openticketUtils.replyTicketMustBePinned(instance,origin,ticket)
if (!isTicketPinned) return cancel() if (!isTicketPinned) return cancel()
//fetch state details //fetch state details
+1
View File
@@ -54,6 +54,7 @@ utilities.moduleInstalled("typescript",true)
utilities.moduleInstalled("terminal-kit",true) utilities.moduleInstalled("terminal-kit",true)
export const opendiscord: api.ODOpenTicketMain = new api.ODOpenTicketMain() export const opendiscord: api.ODOpenTicketMain = new api.ODOpenTicketMain()
export * as openticketUtils from "./actions/utilities.js"
utilities.initialStartupLogs(opendiscord,"openticket") utilities.initialStartupLogs(opendiscord,"openticket")