diff --git a/src/actions/addTicketUser.ts b/src/actions/addTicketUser.ts index 7d444dc..ac91b5c 100644 --- a/src/actions/addTicketUser.ts +++ b/src/actions/addTicketUser.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //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" 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") } - //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 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")) - } - } + //update ticket message (no await) + openticketUtils.updateTicketMessage(guild,channel,user,ticket) //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) diff --git a/src/actions/calculateTicketCategory.ts b/src/actions/calculateTicketCategory.ts index 94b69ef..cd75bb9 100644 --- a/src/actions/calculateTicketCategory.ts +++ b/src/actions/calculateTicketCategory.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //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" const generalConfig = opendiscord.configs.get("opendiscord:general") diff --git a/src/actions/calculateTicketName.ts b/src/actions/calculateTicketName.ts index 864afb6..2c98def 100644 --- a/src/actions/calculateTicketName.ts +++ b/src/actions/calculateTicketName.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //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" const generalConfig = opendiscord.configs.get("opendiscord:general") diff --git a/src/actions/claimTicket.ts b/src/actions/claimTicket.ts index 8eed7c2..b9ca1de 100644 --- a/src/actions/claimTicket.ts +++ b/src/actions/claimTicket.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //TICKET CLAIMING SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" 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").value = categoryResult.newCategoryId }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",[ {key:"channel",value:"#"+channel.name}, {key:"channelid",value:channel.id,hidden:true}, @@ -49,21 +50,8 @@ export async function registerActions(){ } } - //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 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")) - } - } + //update ticket message (no await) + openticketUtils.updateTicketMessage(guild,channel,user,ticket) //reply with new message if (params.sendMessage){ diff --git a/src/actions/clearTickets.ts b/src/actions/clearTickets.ts index 26e2352..4e75d1f 100644 --- a/src/actions/clearTickets.ts +++ b/src/actions/clearTickets.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //CLEAR TICKETS SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" const generalConfig = opendiscord.configs.get("opendiscord:general") diff --git a/src/actions/closeTicket.ts b/src/actions/closeTicket.ts index 7cc0279..c405fc1 100644 --- a/src/actions/closeTicket.ts +++ b/src/actions/closeTicket.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //TICKET CLOSING SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" 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").value = categoryResult.newCategoryId }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",[ {key:"channel",value:"#"+channel.name}, {key:"channelid",value:channel.id,hidden:true}, @@ -114,21 +115,8 @@ export async function registerActions(){ }) channel.permissionOverwrites.set(permissions) - //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 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")) - } - } + //update ticket message (no await) + openticketUtils.updateTicketMessage(guild,channel,user,ticket) //reply with new message if (params.sendMessage){ diff --git a/src/actions/createTicket.ts b/src/actions/createTicket.ts index f986260..68f2e89 100644 --- a/src/actions/createTicket.ts +++ b/src/actions/createTicket.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //TICKET CREATION SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" const generalConfig = opendiscord.configs.get("opendiscord:general") diff --git a/src/actions/createTicketPermissions.ts b/src/actions/createTicketPermissions.ts index 2b3b90d..39daa1b 100644 --- a/src/actions/createTicketPermissions.ts +++ b/src/actions/createTicketPermissions.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //TICKET CREATION 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 registerActions(){ diff --git a/src/actions/createTranscript.ts b/src/actions/createTranscript.ts index d86b69f..2bbcb3f 100644 --- a/src/actions/createTranscript.ts +++ b/src/actions/createTranscript.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //TRANSCRIPT CREATION SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" const transcriptConfig = opendiscord.configs.get("opendiscord:transcripts") diff --git a/src/actions/deleteTicket.ts b/src/actions/deleteTicket.ts index b7f0005..c6cc4ce 100644 --- a/src/actions/deleteTicket.ts +++ b/src/actions/deleteTicket.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //TICKET DELETION SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" 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:busy").value = true - //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 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")) - } - } + //update ticket message (no await) + openticketUtils.updateTicketMessage(guild,channel,user,ticket) if (params.sendMessage) await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:delete-message").build(origin,{guild,channel,user,ticket,reason})).message) diff --git a/src/actions/handleTranscriptErrors.ts b/src/actions/handleTranscriptErrors.ts index e7bbc9f..d9548d0 100644 --- a/src/actions/handleTranscriptErrors.ts +++ b/src/actions/handleTranscriptErrors.ts @@ -1,8 +1,8 @@ /////////////////////////////////////// //TRANSCRIPT ERROR SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" -import * as actionUtils from "../actions/utilities.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" +import * as discord from "discord.js" const generalConfig = opendiscord.configs.get("opendiscord:general") @@ -14,16 +14,16 @@ export async function registerButtonResponders(){ const {guild,channel,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 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 @@ -57,16 +57,16 @@ export async function registerButtonResponders(){ const {guild,channel,user} = 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() //fetch data diff --git a/src/actions/handleVerifyBar.ts b/src/actions/handleVerifyBar.ts index f2f5961..3eb6960 100644 --- a/src/actions/handleVerifyBar.ts +++ b/src/actions/handleVerifyBar.ts @@ -1,7 +1,8 @@ /////////////////////////////////////// //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(){ //HANDLE VERIFYBAR BUTTON diff --git a/src/actions/moveTicket.ts b/src/actions/moveTicket.ts index dafcd46..30ce42b 100644 --- a/src/actions/moveTicket.ts +++ b/src/actions/moveTicket.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //TICKET MOVING SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" 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").value = categoryResult.newCategoryId }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",[ {key:"channel",value:"#"+channel.name}, {key:"channelid",value:channel.id,hidden:true}, @@ -119,25 +120,13 @@ export async function registerActions(){ {key:"oldName",value:originalName}, {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 - 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 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")) - } - } + //update ticket message (no await) + openticketUtils.updateTicketMessage(guild,channel,user,ticket) //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) diff --git a/src/actions/pinTicket.ts b/src/actions/pinTicket.ts index 9590f4e..551b0fd 100644 --- a/src/actions/pinTicket.ts +++ b/src/actions/pinTicket.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //TICKET PINNING SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" const generalConfig = opendiscord.configs.get("opendiscord:general") @@ -45,25 +45,13 @@ export async function registerActions(){ {key:"oldName",value:originalName}, {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 - 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 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")) - } - } + //update ticket message (no await) + openticketUtils.updateTicketMessage(guild,channel,user,ticket) //reply with new message if (params.sendMessage){ diff --git a/src/actions/reactionRole.ts b/src/actions/reactionRole.ts index 2ec9190..5460ecf 100644 --- a/src/actions/reactionRole.ts +++ b/src/actions/reactionRole.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //REACTION ROLE SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" const generalConfig = opendiscord.configs.get("opendiscord:general") diff --git a/src/actions/removeTicketUser.ts b/src/actions/removeTicketUser.ts index 5a1bae9..5f91be8 100644 --- a/src/actions/removeTicketUser.ts +++ b/src/actions/removeTicketUser.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //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" 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") } - //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 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")) - } - } + //update ticket message (no await) + openticketUtils.updateTicketMessage(guild,channel,user,ticket) //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) diff --git a/src/actions/renameTicket.ts b/src/actions/renameTicket.ts index 1213842..ff552a1 100644 --- a/src/actions/renameTicket.ts +++ b/src/actions/renameTicket.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //TICKET RENAMING SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" const generalConfig = opendiscord.configs.get("opendiscord:general") @@ -32,25 +32,13 @@ export async function registerActions(){ {key:"oldName",value:originalName}, {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 - 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 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")) - } - } + //update ticket message (no await) + openticketUtils.updateTicketMessage(guild,channel,user,ticket) //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) diff --git a/src/actions/reopenTicket.ts b/src/actions/reopenTicket.ts index d5f1ffb..361f9fc 100644 --- a/src/actions/reopenTicket.ts +++ b/src/actions/reopenTicket.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //TICKET REOPENING SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" 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").value = categoryResult.newCategoryId }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",[ {key:"channel",value:"#"+channel.name}, {key:"channelid",value:channel.id,hidden:true}, @@ -113,21 +114,8 @@ export async function registerActions(){ }) channel.permissionOverwrites.set(permissions) - //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 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")) - } - } + //update ticket message (no await) + openticketUtils.updateTicketMessage(guild,channel,user,ticket) if (params.sendMessage){ const sentMsg = await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:reopen-message").build(origin,{guild,channel,user,ticket,reason})).message) diff --git a/src/actions/transferTicket.ts b/src/actions/transferTicket.ts index 218cc92..59ae605 100644 --- a/src/actions/transferTicket.ts +++ b/src/actions/transferTicket.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //TICKET TRANSFER SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" const generalConfig = opendiscord.configs.get("opendiscord:general") @@ -103,25 +103,13 @@ export async function registerActions(){ {key:"oldName",value:originalName}, {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 - 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 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")) - } - } + //update ticket message (no await) + openticketUtils.updateTicketMessage(guild,channel,user,ticket) //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) diff --git a/src/actions/unclaimTicket.ts b/src/actions/unclaimTicket.ts index ad216af..3f01cd8 100644 --- a/src/actions/unclaimTicket.ts +++ b/src/actions/unclaimTicket.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //TICKET UNCLAIMING SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" 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").value = categoryResult.newCategoryId }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",[ {key:"channel",value:"#"+channel.name}, {key:"channelid",value:channel.id,hidden:true}, @@ -45,21 +46,8 @@ export async function registerActions(){ } } - //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 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")) - } - } + //update ticket message (no await) + openticketUtils.updateTicketMessage(guild,channel,user,ticket) //reply with new message if (params.sendMessage){ diff --git a/src/actions/unpinTicket.ts b/src/actions/unpinTicket.ts index 62f0162..b1299c5 100644 --- a/src/actions/unpinTicket.ts +++ b/src/actions/unpinTicket.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //TICKET UNPINNING SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" const generalConfig = opendiscord.configs.get("opendiscord:general") @@ -36,25 +36,13 @@ export async function registerActions(){ {key:"oldName",value:originalName}, {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 - 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 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")) - } - } + //update ticket message (no await) + openticketUtils.updateTicketMessage(guild,channel,user,ticket) //reply with new message if (params.sendMessage){ diff --git a/src/actions/updateTicketPriority.ts b/src/actions/updateTicketPriority.ts index 23de01f..76be4ec 100644 --- a/src/actions/updateTicketPriority.ts +++ b/src/actions/updateTicketPriority.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //TICKET TOPIC SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" const generalConfig = opendiscord.configs.get("opendiscord:general") @@ -34,7 +34,8 @@ export async function registerActions(){ {key:"oldName",value:originalName}, {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 } } diff --git a/src/actions/updateTicketTopic.ts b/src/actions/updateTicketTopic.ts index d0cad7f..816cc1c 100644 --- a/src/actions/updateTicketTopic.ts +++ b/src/actions/updateTicketTopic.ts @@ -1,7 +1,7 @@ /////////////////////////////////////// //TICKET TOPIC SYSTEM /////////////////////////////////////// -import {opendiscord, api, utilities} from "../index.js" +import {opendiscord, api, utilities, openticketUtils} from "../index.js" import * as discord from "discord.js" const generalConfig = opendiscord.configs.get("opendiscord:general") diff --git a/src/actions/utilities.ts b/src/actions/utilities.ts index 30f8da7..4caa08b 100644 --- a/src/actions/utilities.ts +++ b/src/actions/utilities.ts @@ -1,11 +1,9 @@ /////////////////////////////////////// -//ACTION UTILITY FUNCTIONS +//OPEN TICKET UTILITY FUNCTIONS /////////////////////////////////////// import {opendiscord, api, utilities} from "../index.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. */ 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 @@ -140,6 +138,7 @@ export async function replyMessageMustBeSentBeforeClose(instance:api.ODButtonRes //return when not allowed because of missing messages const {user,member,channel,guild} = instance 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) 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 }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")) + } } \ No newline at end of file diff --git a/src/builders/embeds.ts b/src/builders/embeds.ts index 39d5442..df686db 100644 --- a/src/builders/embeds.ts +++ b/src/builders/embeds.ts @@ -338,8 +338,8 @@ const errorEmbeds = () => { instance.setDescription(lang.getTranslation("errors.descriptions.channelRename")) instance.setFooter(lang.getTranslationWithParams("errors.descriptions.channelRenameSource",[method])) instance.addFields( - {name:lang.getTranslation("params.uppercase.originalName")+":",value:"```#"+originalName+"```",inline:false}, - {name:lang.getTranslation("params.uppercase.newName")+":",value:"```#"+newName+"```",inline:false} + {name:lang.getTranslation("params.uppercase.originalName")+":",value:"```#"+originalName+"```",inline:true}, + {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.addFields( //TODO TRANSLATION!!! - {name:"Original Category"+":",value:"```"+originalCategory+"```",inline:false}, + {name:"Original Category"+":",value:"```"+originalCategory+"```",inline:true}, //TODO TRANSLATION!!! - {name:"New Category"+":",value:"```"+newCategory+"```",inline:false} + {name:"New Category"+":",value:"```"+newCategory+"```",inline:true} ) }) ) diff --git a/src/commands/add.ts b/src/commands/add.ts index 00601f2..dd1dec6 100644 --- a/src/commands/add.ts +++ b/src/commands/add.ts @@ -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 diff --git a/src/commands/autoclose.ts b/src/commands/autoclose.ts index 57e5c74..ba66cf7 100644 --- a/src/commands/autoclose.ts +++ b/src/commands/autoclose.ts @@ -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() diff --git a/src/commands/autodelete.ts b/src/commands/autodelete.ts index 184440b..235c2cf 100644 --- a/src/commands/autodelete.ts +++ b/src/commands/autodelete.ts @@ -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() diff --git a/src/commands/blacklist.ts b/src/commands/blacklist.ts index edd5996..7f445fc 100644 --- a/src/commands/blacklist.ts +++ b/src/commands/blacklist.ts @@ -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") diff --git a/src/commands/claim.ts b/src/commands/claim.ts index bec0392..38abf62 100644 --- a/src/commands/claim.ts +++ b/src/commands/claim.ts @@ -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 diff --git a/src/commands/clear.ts b/src/commands/clear.ts index 15e7f66..06093d9 100644 --- a/src/commands/clear.ts +++ b/src/commands/clear.ts @@ -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 diff --git a/src/commands/close.ts b/src/commands/close.ts index 8263062..9d60434 100644 --- a/src/commands/close.ts +++ b/src/commands/close.ts @@ -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 diff --git a/src/commands/delete.ts b/src/commands/delete.ts index 4a32cdc..6b06348 100644 --- a/src/commands/delete.ts +++ b/src/commands/delete.ts @@ -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 diff --git a/src/commands/help.ts b/src/commands/help.ts index 3f0e50f..b852a3b 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -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 diff --git a/src/commands/move.ts b/src/commands/move.ts index ffab4ab..3ec418f 100644 --- a/src/commands/move.ts +++ b/src/commands/move.ts @@ -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 diff --git a/src/commands/panel.ts b/src/commands/panel.ts index 56dde86..ff5356d 100644 --- a/src/commands/panel.ts +++ b/src/commands/panel.ts @@ -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 diff --git a/src/commands/pin.ts b/src/commands/pin.ts index 2b076aa..69def53 100644 --- a/src/commands/pin.ts +++ b/src/commands/pin.ts @@ -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 diff --git a/src/commands/priority.ts b/src/commands/priority.ts index 95e04d4..2125e41 100644 --- a/src/commands/priority.ts +++ b/src/commands/priority.ts @@ -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 diff --git a/src/commands/remove.ts b/src/commands/remove.ts index 6874490..554178d 100644 --- a/src/commands/remove.ts +++ b/src/commands/remove.ts @@ -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 diff --git a/src/commands/rename.ts b/src/commands/rename.ts index 376acec..6b2dee6 100644 --- a/src/commands/rename.ts +++ b/src/commands/rename.ts @@ -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 diff --git a/src/commands/reopen.ts b/src/commands/reopen.ts index 2b1fe59..94f7af1 100644 --- a/src/commands/reopen.ts +++ b/src/commands/reopen.ts @@ -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 diff --git a/src/commands/role.ts b/src/commands/role.ts index 14e7eb3..607125b 100644 --- a/src/commands/role.ts +++ b/src/commands/role.ts @@ -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 diff --git a/src/commands/stats.ts b/src/commands/stats.ts index 4dc1950..d6d6da6 100644 --- a/src/commands/stats.ts +++ b/src/commands/stats.ts @@ -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 diff --git a/src/commands/ticket.ts b/src/commands/ticket.ts index d821ef6..719d523 100644 --- a/src/commands/ticket.ts +++ b/src/commands/ticket.ts @@ -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 diff --git a/src/commands/topic.ts b/src/commands/topic.ts index 8143f96..b2b15ad 100644 --- a/src/commands/topic.ts +++ b/src/commands/topic.ts @@ -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 diff --git a/src/commands/transfer.ts b/src/commands/transfer.ts index 12105c3..7857ef8 100644 --- a/src/commands/transfer.ts +++ b/src/commands/transfer.ts @@ -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 diff --git a/src/commands/unclaim.ts b/src/commands/unclaim.ts index 729c189..13014b9 100644 --- a/src/commands/unclaim.ts +++ b/src/commands/unclaim.ts @@ -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 diff --git a/src/commands/unpin.ts b/src/commands/unpin.ts index cfeb4ea..30cd988 100644 --- a/src/commands/unpin.ts +++ b/src/commands/unpin.ts @@ -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 diff --git a/src/index.ts b/src/index.ts index 1a4752c..0f8f957 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,6 +54,7 @@ utilities.moduleInstalled("typescript",true) utilities.moduleInstalled("terminal-kit",true) export const opendiscord: api.ODOpenTicketMain = new api.ODOpenTicketMain() +export * as openticketUtils from "./actions/utilities.js" utilities.initialStartupLogs(opendiscord,"openticket")