Added labels to verifybars (improved accesibility)

This commit is contained in:
DJj123dj
2026-05-14 23:36:21 +02:00
parent e6f6aa1af4
commit 0c45a0ad6a
6 changed files with 45 additions and 42 deletions
+7 -7
View File
@@ -205,13 +205,13 @@
"transfer":"The ticket ownership has been transferred from {0} to {1} by {2}." "transfer":"The ticket ownership has been transferred from {0} to {1} by {2}."
}, },
"modal":{ "modal":{
"closePlaceholder":"Why did you close this ticket?", "closePlaceholder":"Why would you like to close this ticket?",
"deletePlaceholder":"Why did you delete this ticket?", "deletePlaceholder":"Why would you like to delete this ticket?",
"reopenPlaceholder":"Why did you reopen this ticket?", "reopenPlaceholder":"Why would you like to reopen this ticket?",
"claimPlaceholder":"Why did you claim this ticket?", "claimPlaceholder":"Why would you like to claim this ticket?",
"unclaimPlaceholder":"Why did you unclaim this ticket?", "unclaimPlaceholder":"Why would you like to unclaim this ticket?",
"pinPlaceholder":"Why did you pin this ticket?", "pinPlaceholder":"Why would you like to pin this ticket?",
"unpinPlaceholder":"Why did you unpin this ticket?" "unpinPlaceholder":"Why would you like to unpin this ticket?"
}, },
"logs":{ "logs":{
"createLog":"A new ticket got created by {0}.", "createLog":"A new ticket got created by {0}.",
+7 -7
View File
@@ -205,13 +205,13 @@
"transfer":"The ticket ownership has been transferred from {0} to {1} by {2}." "transfer":"The ticket ownership has been transferred from {0} to {1} by {2}."
}, },
"modal":{ "modal":{
"closePlaceholder":"Why whould you like to close this ticket?", "closePlaceholder":"Why would you like to close this ticket?",
"deletePlaceholder":"Why whould you like to delete this ticket?", "deletePlaceholder":"Why would you like to delete this ticket?",
"reopenPlaceholder":"Why whould you like to reopen this ticket?", "reopenPlaceholder":"Why would you like to reopen this ticket?",
"claimPlaceholder":"Why whould you like to claim this ticket?", "claimPlaceholder":"Why would you like to claim this ticket?",
"unclaimPlaceholder":"Why whould you like to unclaim this ticket?", "unclaimPlaceholder":"Why would you like to unclaim this ticket?",
"pinPlaceholder":"Why whould you like to pin this ticket?", "pinPlaceholder":"Why would you like to pin this ticket?",
"unpinPlaceholder":"Why whould you like to unpin this ticket?" "unpinPlaceholder":"Why would you like to unpin this ticket?"
}, },
"logs":{ "logs":{
"createLog":"A new ticket got created by {0}.", "createLog":"A new ticket got created by {0}.",
+1 -1
View File
@@ -26,7 +26,7 @@
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"dependencies": { "dependencies": {
"@discordjs/rest": "^2.6.1", "@discordjs/rest": "^2.6.1",
"@open-discord-bots/framework": "^0.3.15", "@open-discord-bots/framework": "^0.3.17",
"@types/node": "^22.5.0", "@types/node": "^22.5.0",
"@types/terminal-kit": "^2.5.7", "@types/terminal-kit": "^2.5.7",
"ansis": "^4.2.0", "ansis": "^4.2.0",
+5 -2
View File
@@ -17,8 +17,11 @@ export async function registerAllButtons(){
if (params.verifyButtonId.length > 40) throw new api.ODSystemError("ODButton:opendiscord:verifybar-button => verifyButtonId '"+verifyButtonId+"' exceeds 40 characters limit!") if (params.verifyButtonId.length > 40) throw new api.ODSystemError("ODButton:opendiscord:verifybar-button => verifyButtonId '"+verifyButtonId+"' exceeds 40 characters limit!")
const color = ("customColor" in params && params.customColor) ? params.customColor : "gray" const color = ("customColor" in params && params.customColor) ? params.customColor : "gray"
const label = ("customLabel" in params && params.customLabel) ? params.customLabel : null //TODO TRANSLATION!!!
const defaultEmoji = ("buttonStyle" in params && params.buttonStyle && params.buttonStyle == "✅") ? "✅" : "❌" const defaultLabel = (params.defaultButtonType == "✅") ? "Accept" : "Cancel"
const defaultEmoji = (params.defaultButtonType == "✅") ? "✅" : "❌"
const label = ("customLabel" in params && params.customLabel) ? params.customLabel : (params.useDefaultLabels ? defaultLabel : null)
const emoji = ("customEmoji" in params && params.customEmoji) ? params.customEmoji : defaultEmoji const emoji = ("customEmoji" in params && params.customEmoji) ? params.customEmoji : defaultEmoji
instance.setCustomId("od:verifybar|"+verifybar.id.value+"|"+verifyButtonId) instance.setCustomId("od:verifybar|"+verifybar.id.value+"|"+verifyButtonId)
+24 -24
View File
@@ -8,13 +8,13 @@ const modifiers = opendiscord.components.modifiers
const lang = opendiscord.languages const lang = opendiscord.languages
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
export async function addVerifyButton(instance:api.ODMessageInstance|api.ODComponentFactoryInstance<api.ODMessageComponent>,params:{guild:discord.Guild|null,channel:discord.TextBasedChannel,user:discord.User,verifybar:api.ODVerifyBar<string>},buttonStyle:"✅"|"❌",verifyButtonId:string,customLabel?:string,customColor?:api.ODValidButtonColor,customEmoji?:string){ export async function addVerifyButton(instance:api.ODMessageInstance|api.ODComponentFactoryInstance<api.ODMessageComponent>,params:{guild:discord.Guild|null,channel:discord.TextBasedChannel,user:discord.User,verifybar:api.ODVerifyBar<string>},defaultButtonType:"✅"|"❌",useDefaultLabels:boolean,verifyButtonId:string,customLabel?:string,customColor?:api.ODValidButtonColor,customEmoji?:string){
const {guild,channel,user,verifybar} = params const {guild,channel,user,verifybar} = params
if (instance instanceof api.ODMessageInstance){ if (instance instanceof api.ODMessageInstance){
//message builders //message builders
instance.addComponent(await opendiscord.builders.buttons.getSafe("opendiscord:verifybar-button").build("verifybar",{ instance.addComponent(await opendiscord.builders.buttons.getSafe("opendiscord:verifybar-button").build("verifybar",{
guild,channel,user,verifybar, guild,channel,user,verifybar,
buttonStyle,customColor,customEmoji,customLabel, defaultButtonType,useDefaultLabels,customColor,customEmoji,customLabel,
verifyButtonId verifyButtonId
})) }))
}else{ }else{
@@ -40,9 +40,9 @@ export async function registerAllVerifyBarModifiers(){
} }
//cancel, accept or close with reason //cancel, accept or close with reason
await addVerifyButton(instance,params,"❌",api.ODVerifyButtonId.Cancel) await addVerifyButton(instance,params,"❌",true,api.ODVerifyButtonId.Cancel)
await addVerifyButton(instance,params,"✅",api.ODVerifyButtonId.Accept) await addVerifyButton(instance,params,"✅",true,api.ODVerifyButtonId.Accept,lang.getTranslation("actions.buttons.close"))
if (generalConfig.data.system.enableTicketActionWithReason) await addVerifyButton(instance,params,"✅",api.ODVerifyButtonId.AcceptWithReason,lang.getTranslation("actions.buttons.withReason"),"blue","✏️") if (generalConfig.data.system.enableTicketActionWithReason) await addVerifyButton(instance,params,"✅",false,api.ODVerifyButtonId.AcceptWithReason,lang.getTranslation("actions.buttons.withReason"),"blue","✏️")
})) }))
//REOPEN TICKET VERIFYBAR //REOPEN TICKET VERIFYBAR
@@ -55,9 +55,9 @@ export async function registerAllVerifyBarModifiers(){
} }
//cancel, accept or reopen with reason //cancel, accept or reopen with reason
await addVerifyButton(instance,params,"❌",api.ODVerifyButtonId.Cancel) await addVerifyButton(instance,params,"❌",true,api.ODVerifyButtonId.Cancel)
await addVerifyButton(instance,params,"✅",api.ODVerifyButtonId.Accept) await addVerifyButton(instance,params,"✅",true,api.ODVerifyButtonId.Accept,lang.getTranslation("actions.buttons.reopen"))
if (generalConfig.data.system.enableTicketActionWithReason) await addVerifyButton(instance,params,"✅",api.ODVerifyButtonId.AcceptWithReason,lang.getTranslation("actions.buttons.withReason"),"blue","✏️") if (generalConfig.data.system.enableTicketActionWithReason) await addVerifyButton(instance,params,"✅",false,api.ODVerifyButtonId.AcceptWithReason,lang.getTranslation("actions.buttons.withReason"),"blue","✏️")
})) }))
//DELETE TICKET VERIFYBAR //DELETE TICKET VERIFYBAR
@@ -70,10 +70,10 @@ export async function registerAllVerifyBarModifiers(){
} }
//cancel, accept or delete with reason or without transcript //cancel, accept or delete with reason or without transcript
await addVerifyButton(instance,params,"❌",api.ODVerifyButtonId.Cancel) await addVerifyButton(instance,params,"❌",true,api.ODVerifyButtonId.Cancel)
await addVerifyButton(instance,params,"✅",api.ODVerifyButtonId.Accept) await addVerifyButton(instance,params,"✅",true,api.ODVerifyButtonId.Accept,lang.getTranslation("actions.buttons.delete"))
if (generalConfig.data.system.enableTicketActionWithReason) await addVerifyButton(instance,params,"✅",api.ODVerifyButtonId.AcceptWithReason,lang.getTranslation("actions.buttons.withReason"),"blue","✏️") if (generalConfig.data.system.enableTicketActionWithReason) await addVerifyButton(instance,params,"✅",false,api.ODVerifyButtonId.AcceptWithReason,lang.getTranslation("actions.buttons.withReason"),"blue","✏️")
if (generalConfig.data.system.enableDeleteWithoutTranscript) await addVerifyButton(instance,params,"✅",api.ODVerifyButtonId.AcceptWithoutTranscript,lang.getTranslation("actions.buttons.withoutTranscript"),"red","📄") if (generalConfig.data.system.enableDeleteWithoutTranscript) await addVerifyButton(instance,params,"✅",false,api.ODVerifyButtonId.AcceptWithoutTranscript,lang.getTranslation("actions.buttons.withoutTranscript"),"red","📄")
})) }))
//CLAIM TICKET VERIFYBAR //CLAIM TICKET VERIFYBAR
@@ -86,9 +86,9 @@ export async function registerAllVerifyBarModifiers(){
} }
//cancel, accept or claim with reason //cancel, accept or claim with reason
await addVerifyButton(instance,params,"❌",api.ODVerifyButtonId.Cancel) await addVerifyButton(instance,params,"❌",true,api.ODVerifyButtonId.Cancel)
await addVerifyButton(instance,params,"✅",api.ODVerifyButtonId.Accept) await addVerifyButton(instance,params,"✅",true,api.ODVerifyButtonId.Accept,lang.getTranslation("actions.buttons.claim"))
if (generalConfig.data.system.enableTicketActionWithReason) await addVerifyButton(instance,params,"✅",api.ODVerifyButtonId.AcceptWithReason,lang.getTranslation("actions.buttons.withReason"),"blue","✏️") if (generalConfig.data.system.enableTicketActionWithReason) await addVerifyButton(instance,params,"✅",false,api.ODVerifyButtonId.AcceptWithReason,lang.getTranslation("actions.buttons.withReason"),"blue","✏️")
})) }))
//UNCLAIM TICKET VERIFYBAR //UNCLAIM TICKET VERIFYBAR
@@ -101,9 +101,9 @@ export async function registerAllVerifyBarModifiers(){
} }
//cancel, accept or unclaim with reason //cancel, accept or unclaim with reason
await addVerifyButton(instance,params,"❌",api.ODVerifyButtonId.Cancel) await addVerifyButton(instance,params,"❌",true,api.ODVerifyButtonId.Cancel)
await addVerifyButton(instance,params,"✅",api.ODVerifyButtonId.Accept) await addVerifyButton(instance,params,"✅",true,api.ODVerifyButtonId.Accept,lang.getTranslation("actions.buttons.unclaim"))
if (generalConfig.data.system.enableTicketActionWithReason) await addVerifyButton(instance,params,"✅",api.ODVerifyButtonId.AcceptWithReason,lang.getTranslation("actions.buttons.withReason"),"blue","✏️") if (generalConfig.data.system.enableTicketActionWithReason) await addVerifyButton(instance,params,"✅",false,api.ODVerifyButtonId.AcceptWithReason,lang.getTranslation("actions.buttons.withReason"),"blue","✏️")
})) }))
//PIN TICKET VERIFYBAR //PIN TICKET VERIFYBAR
@@ -116,9 +116,9 @@ export async function registerAllVerifyBarModifiers(){
} }
//cancel, accept or pin with reason //cancel, accept or pin with reason
await addVerifyButton(instance,params,"❌",api.ODVerifyButtonId.Cancel) await addVerifyButton(instance,params,"❌",true,api.ODVerifyButtonId.Cancel)
await addVerifyButton(instance,params,"✅",api.ODVerifyButtonId.Accept) await addVerifyButton(instance,params,"✅",true,api.ODVerifyButtonId.Accept,lang.getTranslation("actions.buttons.pin"))
if (generalConfig.data.system.enableTicketActionWithReason) await addVerifyButton(instance,params,"✅",api.ODVerifyButtonId.AcceptWithReason,lang.getTranslation("actions.buttons.withReason"),"blue","✏️") if (generalConfig.data.system.enableTicketActionWithReason) await addVerifyButton(instance,params,"✅",false,api.ODVerifyButtonId.AcceptWithReason,lang.getTranslation("actions.buttons.withReason"),"blue","✏️")
})) }))
//UNPIN TICKET VERIFYBAR //UNPIN TICKET VERIFYBAR
@@ -131,8 +131,8 @@ export async function registerAllVerifyBarModifiers(){
} }
//cancel, accept or unpin with reason //cancel, accept or unpin with reason
await addVerifyButton(instance,params,"❌",api.ODVerifyButtonId.Cancel) await addVerifyButton(instance,params,"❌",true,api.ODVerifyButtonId.Cancel)
await addVerifyButton(instance,params,"✅",api.ODVerifyButtonId.Accept) await addVerifyButton(instance,params,"✅",true,api.ODVerifyButtonId.Accept,lang.getTranslation("actions.buttons.unpin"))
if (generalConfig.data.system.enableTicketActionWithReason) await addVerifyButton(instance,params,"✅",api.ODVerifyButtonId.AcceptWithReason,lang.getTranslation("actions.buttons.withReason"),"blue","✏️") if (generalConfig.data.system.enableTicketActionWithReason) await addVerifyButton(instance,params,"✅",false,api.ODVerifyButtonId.AcceptWithReason,lang.getTranslation("actions.buttons.withReason"),"blue","✏️")
})) }))
} }
+1 -1
View File
@@ -16,7 +16,7 @@ import * as discord from "discord.js"
* It's used to generate typescript declarations for this class. * It's used to generate typescript declarations for this class.
*/ */
export interface ODButtonManagerIdMappings extends api.ODButtonManagerIdConstraint { export interface ODButtonManagerIdMappings extends api.ODButtonManagerIdConstraint {
"opendiscord:verifybar-button":{origin:"verifybar"|"other",params:{guild:discord.Guild|null,channel:discord.TextBasedChannel,user:discord.User,verifybar:api.ODVerifyBar<string>,verifyButtonId:string,buttonStyle:"✅"|"❌",customLabel?:string,customColor?:api.ODValidButtonColor,customEmoji?:string},workers:"opendiscord:verifybar-button"}, "opendiscord:verifybar-button":{origin:"verifybar"|"other",params:{guild:discord.Guild|null,channel:discord.TextBasedChannel,user:discord.User,verifybar:api.ODVerifyBar<string>,verifyButtonId:string,defaultButtonType:"✅"|"❌",useDefaultLabels:boolean,customLabel?:string,customColor?:api.ODValidButtonColor,customEmoji?:string},workers:"opendiscord:verifybar-button"},
"opendiscord:error-ticket-deprecated-transcript":{origin:"slash"|"text"|"button"|"dropdown"|"modal"|"other",params:{},workers:"opendiscord:error-ticket-deprecated-transcript"}, "opendiscord:error-ticket-deprecated-transcript":{origin:"slash"|"text"|"button"|"dropdown"|"modal"|"other",params:{},workers:"opendiscord:error-ticket-deprecated-transcript"},