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
+5 -6
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"add")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"add")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
//fetch data
+8 -22
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,19 +14,19 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"autoclose")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"autoclose")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketOpen = await actionUtils.replyTicketMustBeOpen(instance,origin,ticket)
const isTicketOpen = await openticketUtils.replyTicketMustBeOpen(instance,origin,ticket)
if (!isTicketOpen) return cancel()
//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}))
}
//update ticket message
const ticketMessage = await opendiscord.tickets.getTicketMessage(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"))
}
}
//update ticket message (no await)
openticketUtils.updateTicketMessage(guild,channel,user,ticket)
}),
new api.ODWorker("opendiscord:logs",-1,(instance,params,origin,cancel) => {
const scope = instance.options.getSubCommand()
+7 -21
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"autodelete")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"autodelete")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
//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}))
}
//update ticket message
const ticketMessage = await opendiscord.tickets.getTicketMessage(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"))
}
}
//update ticket message (no await)
openticketUtils.updateTicketMessage(guild,channel,user,ticket)
}),
new api.ODWorker("opendiscord:logs",-1,(instance,params,origin,cancel) => {
const scope = instance.options.getSubCommand()
+1 -2
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
+24 -25
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages
@@ -17,19 +16,19 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"claim")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"claim")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketUnclaimed = await actionUtils.replyTicketMustBeUnclaimed(instance,origin,ticket)
const isTicketUnclaimed = await openticketUtils.replyTicketMustBeUnclaimed(instance,origin,ticket)
if (!isTicketUnclaimed) return cancel()
//start claiming ticket
@@ -66,22 +65,22 @@ export async function registerButtonResponders(){
const {guild,channel,user,message} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"claim")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"claim")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/claim")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/claim")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketUnclaimed = await actionUtils.replyTicketMustBeUnclaimed(instance,origin,ticket)
const isTicketUnclaimed = await openticketUtils.replyTicketMustBeUnclaimed(instance,origin,ticket)
if (!isTicketUnclaimed) return cancel()
//fetch state details
@@ -116,22 +115,22 @@ export async function registerVerifyBars(){
const {user,member,channel,guild,message} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"claim")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"claim")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/claim")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/claim")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketUnclaimed = await actionUtils.replyTicketMustBeUnclaimed(instance,origin,ticket)
const isTicketUnclaimed = await openticketUtils.replyTicketMustBeUnclaimed(instance,origin,ticket)
if (!isTicketUnclaimed) return cancel()
//fetch state details
@@ -189,22 +188,22 @@ export async function registerModalResponders(){
const message = await opendiscord.client.fetchChannelMessage(match[1],match[2])
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"claim")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"claim")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/claim")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/claim")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketUnclaimed = await actionUtils.replyTicketMustBeUnclaimed(instance,origin,ticket)
const isTicketUnclaimed = await openticketUtils.replyTicketMustBeUnclaimed(instance,origin,ticket)
if (!isTicketUnclaimed) return cancel()
//fetch state details
+5 -6
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
const clearMsgState = opendiscord.states.get("opendiscord:clear-message")
@@ -17,10 +16,10 @@ export async function registerCommandResponders(){
//responder checks
//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()
const isInGuild = await actionUtils.replyIsInGuild(instance,origin)
const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel()
//fetch data
@@ -79,10 +78,10 @@ export async function registerButtonResponders(){
}
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"clear")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"clear")
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()
//fetch state details
+27 -28
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages
@@ -17,22 +16,22 @@ export async function registerCommandResponders(){
const {user,member,channel,guild} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"close")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"close")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketOpen = await actionUtils.replyTicketMustBeOpen(instance,origin,ticket)
const isTicketOpen = await openticketUtils.replyTicketMustBeOpen(instance,origin,ticket)
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()
//start closing ticket
@@ -68,25 +67,25 @@ export async function registerButtonResponders(){
const {guild,channel,message,user,member} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"close")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"close")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/close")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/close")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketOpen = await actionUtils.replyTicketMustBeOpen(instance,origin,ticket)
const isTicketOpen = await openticketUtils.replyTicketMustBeOpen(instance,origin,ticket)
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()
//fetch state details
@@ -121,25 +120,25 @@ export async function registerVerifyBars(){
const {user,member,channel,guild,message} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"close")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"close")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/close")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/close")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketOpen = await actionUtils.replyTicketMustBeOpen(instance,origin,ticket)
const isTicketOpen = await openticketUtils.replyTicketMustBeOpen(instance,origin,ticket)
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()
//fetch state details
@@ -197,22 +196,22 @@ export async function registerModalResponders(){
const message = await opendiscord.client.fetchChannelMessage(match[1],match[2])
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"close")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"close")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/close")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/close")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketOpen = await actionUtils.replyTicketMustBeOpen(instance,origin,ticket)
const isTicketOpen = await openticketUtils.replyTicketMustBeOpen(instance,origin,ticket)
if (!isTicketOpen) return cancel()
//fetch state details
+24 -25
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages
@@ -17,22 +16,22 @@ export async function registerCommandResponders(){
const {user,member,channel,guild} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"delete")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"delete")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketOpen = await actionUtils.replyTicketMustBeOpen(instance,origin,ticket)
const isTicketOpen = await openticketUtils.replyTicketMustBeOpen(instance,origin,ticket)
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()
//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
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"delete")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"delete")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/delete")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/delete")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
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()
//fetch state details
@@ -127,22 +126,22 @@ export async function registerVerifyBars(){
const {user,member,channel,guild,message} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"delete")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"delete")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/delete")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/delete")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
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()
//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])
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"delete")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"delete")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/delete")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/delete")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
//fetch state details
+2 -3
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,7 +14,7 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"help")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"help")
if (!hasPerms) return cancel()
//calculate slash/text mode for help menu
+5 -6
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"move")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"move")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
//fetch data
+5 -6
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"panel")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"panel")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
//fetch data
+24 -25
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages
@@ -17,19 +16,19 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"pin")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"pin")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketUnpinned = await actionUtils.replyTicketMustBeUnpinned(instance,origin,ticket)
const isTicketUnpinned = await openticketUtils.replyTicketMustBeUnpinned(instance,origin,ticket)
if (!isTicketUnpinned) return cancel()
//start pinning ticket
@@ -65,22 +64,22 @@ export async function registerButtonResponders(){
const {guild,channel,user,message} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"pin")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"pin")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/pin")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/pin")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketUnpinned = await actionUtils.replyTicketMustBeUnpinned(instance,origin,ticket)
const isTicketUnpinned = await openticketUtils.replyTicketMustBeUnpinned(instance,origin,ticket)
if (!isTicketUnpinned) return cancel()
//fetch state details
@@ -116,22 +115,22 @@ export async function registerVerifyBars(){
const {user,member,channel,guild,message} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"pin")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"pin")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/pin")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/pin")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketUnpinned = await actionUtils.replyTicketMustBeUnpinned(instance,origin,ticket)
const isTicketUnpinned = await openticketUtils.replyTicketMustBeUnpinned(instance,origin,ticket)
if (!isTicketUnpinned) return cancel()
//fetch state details
@@ -189,22 +188,22 @@ export async function registerModalResponders(){
const message = await opendiscord.client.fetchChannelMessage(match[1],match[2])
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"pin")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"pin")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/pin")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/pin")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketUnpinned = await actionUtils.replyTicketMustBeUnpinned(instance,origin,ticket)
const isTicketUnpinned = await openticketUtils.replyTicketMustBeUnpinned(instance,origin,ticket)
if (!isTicketUnpinned) return cancel()
//fetch state details
+5 -6
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"priority")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"priority")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
//subcommands
+5 -6
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"remove")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"remove")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
//fetch data
+5 -6
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"rename")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"rename")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
//fetch data
+24 -25
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages
@@ -17,19 +16,19 @@ export async function registerCommandResponders(){
const {guild,channel,user,member} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"reopen")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"reopen")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketClosed = await actionUtils.replyTicketMustBeClosed(instance,origin,ticket)
const isTicketClosed = await openticketUtils.replyTicketMustBeClosed(instance,origin,ticket)
if (!isTicketClosed) return cancel()
//start reopening ticket
@@ -65,22 +64,22 @@ export async function registerButtonResponders(){
const {guild,channel,message,user,member} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"reopen")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"reopen")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/reopen")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/reopen")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketClosed = await actionUtils.replyTicketMustBeClosed(instance,origin,ticket)
const isTicketClosed = await openticketUtils.replyTicketMustBeClosed(instance,origin,ticket)
if (!isTicketClosed) return cancel()
//fetch state details
@@ -119,22 +118,22 @@ export async function registerVerifyBars(){
const {user,member,channel,guild,message} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"reopen")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"reopen")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/reopen")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/reopen")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketClosed = await actionUtils.replyTicketMustBeClosed(instance,origin,ticket)
const isTicketClosed = await openticketUtils.replyTicketMustBeClosed(instance,origin,ticket)
if (!isTicketClosed) return cancel()
//fetch state details
@@ -205,22 +204,22 @@ export async function registerModalResponders(){
const message = await opendiscord.client.fetchChannelMessage(match[1],match[2])
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"reopen")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"reopen")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/reopen")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/reopen")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketClosed = await actionUtils.replyTicketMustBeClosed(instance,origin,ticket)
const isTicketClosed = await openticketUtils.replyTicketMustBeClosed(instance,origin,ticket)
if (!isTicketClosed) return cancel()
//fetch state details
+2 -3
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,7 +14,7 @@ export async function registerButtonResponders(){
const {guild,channel,user} = instance
//responder checks
const isInGuild = await actionUtils.replyIsInGuild(instance,origin)
const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel()
//get option data
+3 -4
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -21,12 +20,12 @@ export async function registerCommandResponders(){
return cancel()
}else{
//default permissions check
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"stats")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"stats")
if (!hasPerms) return cancel()
}
//responder checks
const isInGuild = await actionUtils.replyIsInGuild(instance,origin)
const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel()
//subcommands
+6 -7
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages
@@ -34,10 +33,10 @@ export async function registerCommandResponders(){
const {user,member,channel,guild} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"ticket")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"ticket")
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()
//get option data
@@ -86,7 +85,7 @@ export async function registerButtonResponders(){
const {guild,channel,user} = instance
//responder checks
const isInGuild = await actionUtils.replyIsInGuild(instance,origin)
const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel()
//get option data
@@ -128,7 +127,7 @@ export async function registerDropdownResponders(){
const {guild,channel,user} = instance
//responder checks
const isInGuild = await actionUtils.replyIsInGuild(instance,origin)
const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || channel.isDMBased()) return cancel()
//get option data
@@ -178,7 +177,7 @@ export async function registerModalResponders(){
const {guild,channel,user} = instance
//responder checks
const isInGuild = await actionUtils.replyIsInGuild(instance,origin)
const isInGuild = await openticketUtils.replyIsInGuild(instance,origin)
if (!isInGuild || !guild || !channel || channel.isDMBased()) return cancel()
//get option data
+5 -6
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
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) => {
const {user,member,channel,guild} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"topic")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"topic")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
//subcommands
+5 -6
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
@@ -15,16 +14,16 @@ export async function registerCommandResponders(){
const {user,member,channel,guild} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"transfer")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"transfer")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
//fetch data
+24 -25
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages
@@ -17,19 +16,19 @@ export async function registerCommandResponders(){
const {user,member,channel,guild} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unclaim")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unclaim")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketClaimed = await actionUtils.replyTicketMustBeClaimed(instance,origin,ticket)
const isTicketClaimed = await openticketUtils.replyTicketMustBeClaimed(instance,origin,ticket)
if (!isTicketClaimed) return cancel()
//start unclaiming ticket
@@ -65,22 +64,22 @@ export async function registerButtonResponders(){
const {guild,channel,user,message} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unclaim")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unclaim")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unclaim")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unclaim")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketClaimed = await actionUtils.replyTicketMustBeClaimed(instance,origin,ticket)
const isTicketClaimed = await openticketUtils.replyTicketMustBeClaimed(instance,origin,ticket)
if (!isTicketClaimed) return cancel()
//fetch state details
@@ -115,22 +114,22 @@ export async function registerVerifyBars(){
const {user,member,channel,guild,message} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unclaim")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unclaim")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unclaim")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unclaim")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketClaimed = await actionUtils.replyTicketMustBeClaimed(instance,origin,ticket)
const isTicketClaimed = await openticketUtils.replyTicketMustBeClaimed(instance,origin,ticket)
if (!isTicketClaimed) return cancel()
//fetch state details
@@ -188,22 +187,22 @@ export async function registerModalResponders(){
const message = await opendiscord.client.fetchChannelMessage(match[1],match[2])
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unclaim")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unclaim")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unclaim")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unclaim")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketClaimed = await actionUtils.replyTicketMustBeClaimed(instance,origin,ticket)
const isTicketClaimed = await openticketUtils.replyTicketMustBeClaimed(instance,origin,ticket)
if (!isTicketClaimed) return cancel()
//fetch state details
+24 -25
View File
@@ -1,9 +1,8 @@
///////////////////////////////////////
//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 actionUtils from "../actions/utilities.js"
const generalConfig = opendiscord.configs.get("opendiscord:general")
const lang = opendiscord.languages
@@ -17,19 +16,19 @@ export async function registerCommandResponders(){
const {user,member,channel,guild} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unpin")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unpin")
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()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketPinned = await actionUtils.replyTicketMustBePinned(instance,origin,ticket)
const isTicketPinned = await openticketUtils.replyTicketMustBePinned(instance,origin,ticket)
if (!isTicketPinned) return cancel()
//start unpining ticket
@@ -65,22 +64,22 @@ export async function registerButtonResponders(){
const {guild,channel,user,message} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unpin")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unpin")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unpin")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unpin")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketPinned = await actionUtils.replyTicketMustBePinned(instance,origin,ticket)
const isTicketPinned = await openticketUtils.replyTicketMustBePinned(instance,origin,ticket)
if (!isTicketPinned) return cancel()
//fetch state details
@@ -115,22 +114,22 @@ export async function registerVerifyBars(){
const {user,member,channel,guild,message} = instance
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unpin")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unpin")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unpin")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unpin")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketPinned = await actionUtils.replyTicketMustBePinned(instance,origin,ticket)
const isTicketPinned = await openticketUtils.replyTicketMustBePinned(instance,origin,ticket)
if (!isTicketPinned) return cancel()
//fetch state details
@@ -188,22 +187,22 @@ export async function registerModalResponders(){
const message = await opendiscord.client.fetchChannelMessage(match[1],match[2])
//responder checks
const hasPerms = await actionUtils.replyHasPermissions(instance,origin,"unpin")
const hasPerms = await openticketUtils.replyHasPermissions(instance,origin,"unpin")
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()
const state = await actionUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unpin")
const state = await openticketUtils.replyInteractiveMessageState(instance,origin,channel,message,"/unpin")
if (!state) return cancel()
const ticket = await actionUtils.replyIsTicket(instance,origin)
const ticket = await openticketUtils.replyIsTicket(instance,origin)
if (!ticket) return cancel()
const isAvailable = await actionUtils.replyTicketIsAvailable(instance,origin,ticket)
const isAvailable = await openticketUtils.replyTicketIsAvailable(instance,origin,ticket)
if (!isAvailable) return cancel()
const isTicketPinned = await actionUtils.replyTicketMustBePinned(instance,origin,ticket)
const isTicketPinned = await openticketUtils.replyTicketMustBePinned(instance,origin,ticket)
if (!isTicketPinned) return cancel()
//fetch state details