Merge branch 'dev' into dev-v4.1.0
This commit is contained in:
@@ -20,7 +20,7 @@ export const registerActions = async () => {
|
||||
const channelCategory = option.get("opendiscord:channel-category").value
|
||||
const channelBackupCategory = option.get("opendiscord:channel-category-backup").value
|
||||
const channelDescription = option.get("opendiscord:channel-description").value
|
||||
const channelSuffix = opendiscord.options.suffix.getSuffixFromOption(option,user)
|
||||
const channelSuffix = await opendiscord.options.suffix.getSuffixFromOption(option,user)
|
||||
const channelName = channelPrefix+channelSuffix
|
||||
|
||||
//handle category
|
||||
|
||||
@@ -130,7 +130,7 @@ export class ODMain {
|
||||
|
||||
constructor(){
|
||||
this.versions = new ODVersionManager_Default()
|
||||
this.versions.add(ODVersion.fromString("opendiscord:version","v4.0.4"))
|
||||
this.versions.add(ODVersion.fromString("opendiscord:version","v4.0.5"))
|
||||
this.versions.add(ODVersion.fromString("opendiscord:api","v1.0.0"))
|
||||
this.versions.add(ODVersion.fromString("opendiscord:transcripts","v2.0.0"))
|
||||
this.versions.add(ODVersion.fromString("opendiscord:livestatus","v2.0.0"))
|
||||
|
||||
@@ -560,8 +560,8 @@ export class ODHTTPGetRequest {
|
||||
this.throwOnError = throwOnError
|
||||
const newConfig = config ?? {}
|
||||
newConfig.method = "GET"
|
||||
if (newConfig.headers) Object.assign(newConfig.headers,{"User-Agent":"OpenDiscordBots-OpenTicket/4.0.4"})
|
||||
else newConfig.headers = {"User-Agent":"OpenDiscordBots-OpenTicket/4.0.4"}
|
||||
if (newConfig.headers) Object.assign(newConfig.headers,{"User-Agent":"OpenDiscordBots-OpenTicket/4.0.5"})
|
||||
else newConfig.headers = {"User-Agent":"OpenDiscordBots-OpenTicket/4.0.5"}
|
||||
this.config = newConfig
|
||||
}
|
||||
|
||||
@@ -615,8 +615,8 @@ export class ODHTTPPostRequest {
|
||||
this.throwOnError = throwOnError
|
||||
const newConfig = config ?? {}
|
||||
newConfig.method = "POST"
|
||||
if (newConfig.headers) Object.assign(newConfig.headers,{"User-Agent":"OpenDiscordBots-OpenTicket/4.0.4"})
|
||||
else newConfig.headers = {"User-Agent":"OpenDiscordBots-OpenTicket/4.0.4"}
|
||||
if (newConfig.headers) Object.assign(newConfig.headers,{"User-Agent":"OpenDiscordBots-OpenTicket/4.0.5"})
|
||||
else newConfig.headers = {"User-Agent":"OpenDiscordBots-OpenTicket/4.0.5"}
|
||||
this.config = newConfig
|
||||
}
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ export class ODQuickButton {
|
||||
/**The id of this button. */
|
||||
id: ODId
|
||||
/**The current data of this button */
|
||||
data: ODButtonData = {
|
||||
data: Partial<ODButtonData> = {
|
||||
customId:"",
|
||||
mode:"button",
|
||||
url:null,
|
||||
@@ -267,7 +267,7 @@ export class ODQuickButton {
|
||||
disabled:false
|
||||
}
|
||||
|
||||
constructor(id:ODValidId,data:ODButtonData){
|
||||
constructor(id:ODValidId,data:Partial<ODButtonData>){
|
||||
this.id = new ODId(id)
|
||||
this.data = data
|
||||
}
|
||||
@@ -277,7 +277,7 @@ export class ODQuickButton {
|
||||
try {
|
||||
//create the discord.js button
|
||||
const button = new discord.ButtonBuilder()
|
||||
if (this.data.mode == "button") button.setCustomId(this.data.customId)
|
||||
if (this.data.mode == "button") button.setCustomId(this.data.customId ?? "od:unknown-button")
|
||||
if (this.data.mode == "url") button.setStyle(discord.ButtonStyle.Link)
|
||||
else if (this.data.color == "gray") button.setStyle(discord.ButtonStyle.Secondary)
|
||||
else if (this.data.color == "blue") button.setStyle(discord.ButtonStyle.Primary)
|
||||
@@ -287,7 +287,7 @@ export class ODQuickButton {
|
||||
if (this.data.label) button.setLabel(this.data.label)
|
||||
if (this.data.emoji) button.setEmoji(this.data.emoji)
|
||||
if (this.data.disabled) button.setDisabled(this.data.disabled)
|
||||
if (!this.data.emoji && !this.data.label) button.setLabel(this.data.customId)
|
||||
if (!this.data.emoji && !this.data.label) button.setLabel(this.data.customId ?? "od:unknown-button")
|
||||
|
||||
return {id:this.id,component:button}
|
||||
}catch(err){
|
||||
@@ -564,7 +564,7 @@ export class ODQuickDropdown {
|
||||
/**The id of this dropdown. */
|
||||
id: ODId
|
||||
/**The current data of this dropdown */
|
||||
data: ODDropdownData = {
|
||||
data: Partial<ODDropdownData> = {
|
||||
customId:"",
|
||||
type:"string",
|
||||
placeholder:null,
|
||||
@@ -580,7 +580,7 @@ export class ODQuickDropdown {
|
||||
mentionables:[]
|
||||
}
|
||||
|
||||
constructor(id:ODValidId,data:ODDropdownData){
|
||||
constructor(id:ODValidId,data:Partial<ODDropdownData>){
|
||||
this.id = new ODId(id)
|
||||
this.data = data
|
||||
}
|
||||
@@ -590,8 +590,9 @@ export class ODQuickDropdown {
|
||||
try{
|
||||
//create the discord.js dropdown
|
||||
if (this.data.type == "string"){
|
||||
if (!this.data.options) throw new ODSystemError("ODQuickDropdown:build(): "+this.id.value+" => Dropdown requires at least 1 option to be present.")
|
||||
const dropdown = new discord.StringSelectMenuBuilder()
|
||||
dropdown.setCustomId(this.data.customId)
|
||||
dropdown.setCustomId(this.data.customId ?? "od:unknown-dropdown")
|
||||
dropdown.setOptions(...this.data.options)
|
||||
if (this.data.placeholder) dropdown.setPlaceholder(this.data.placeholder)
|
||||
if (this.data.minValues) dropdown.setMinValues(this.data.minValues)
|
||||
@@ -601,8 +602,9 @@ export class ODQuickDropdown {
|
||||
return {id:this.id,component:dropdown}
|
||||
|
||||
}else if (this.data.type == "user"){
|
||||
if (!this.data.users) throw new ODSystemError("ODQuickDropdown:build(): "+this.id.value+" => Dropdown requires at least 1 user option to be present.")
|
||||
const dropdown = new discord.UserSelectMenuBuilder()
|
||||
dropdown.setCustomId(this.data.customId)
|
||||
dropdown.setCustomId(this.data.customId ?? "od:unknown-dropdown")
|
||||
if (this.data.users.length > 0) dropdown.setDefaultUsers(...this.data.users.map((u) => u.id))
|
||||
if (this.data.placeholder) dropdown.setPlaceholder(this.data.placeholder)
|
||||
if (this.data.minValues) dropdown.setMinValues(this.data.minValues)
|
||||
@@ -612,8 +614,9 @@ export class ODQuickDropdown {
|
||||
return {id:this.id,component:dropdown}
|
||||
|
||||
}else if (this.data.type == "role"){
|
||||
if (!this.data.roles) throw new ODSystemError("ODQuickDropdown:build(): "+this.id.value+" => Dropdown requires at least 1 role option to be present.")
|
||||
const dropdown = new discord.RoleSelectMenuBuilder()
|
||||
dropdown.setCustomId(this.data.customId)
|
||||
dropdown.setCustomId(this.data.customId ?? "od:unknown-dropdown")
|
||||
if (this.data.roles.length > 0) dropdown.setDefaultRoles(...this.data.roles.map((r) => r.id))
|
||||
if (this.data.placeholder) dropdown.setPlaceholder(this.data.placeholder)
|
||||
if (this.data.minValues) dropdown.setMinValues(this.data.minValues)
|
||||
@@ -623,8 +626,9 @@ export class ODQuickDropdown {
|
||||
return {id:this.id,component:dropdown}
|
||||
|
||||
}else if (this.data.type == "channel"){
|
||||
if (!this.data.channels) throw new ODSystemError("ODQuickDropdown:build(): "+this.id.value+" => Dropdown requires at least 1 channel option to be present.")
|
||||
const dropdown = new discord.ChannelSelectMenuBuilder()
|
||||
dropdown.setCustomId(this.data.customId)
|
||||
dropdown.setCustomId(this.data.customId ?? "od:unknown-dropdown")
|
||||
if (this.data.channels.length > 0) dropdown.setDefaultChannels(...this.data.channels.map((c) => c.id))
|
||||
if (this.data.placeholder) dropdown.setPlaceholder(this.data.placeholder)
|
||||
if (this.data.minValues) dropdown.setMinValues(this.data.minValues)
|
||||
@@ -634,6 +638,7 @@ export class ODQuickDropdown {
|
||||
return {id:this.id,component:dropdown}
|
||||
|
||||
}else if (this.data.type == "mentionable"){
|
||||
if (!this.data.mentionables) throw new ODSystemError("ODQuickDropdown:build(): "+this.id.value+" => Dropdown requires at least 1 mentionable option to be present.")
|
||||
const dropdown = new discord.MentionableSelectMenuBuilder()
|
||||
|
||||
const values: ({type:discord.SelectMenuDefaultValueType.User,id:string}|{type:discord.SelectMenuDefaultValueType.Role,id:string})[] = []
|
||||
@@ -645,7 +650,7 @@ export class ODQuickDropdown {
|
||||
}
|
||||
})
|
||||
|
||||
dropdown.setCustomId(this.data.customId)
|
||||
dropdown.setCustomId(this.data.customId ?? "od:unknown-dropdown")
|
||||
if (this.data.mentionables.length > 0) dropdown.setDefaultValues(...values)
|
||||
if (this.data.placeholder) dropdown.setPlaceholder(this.data.placeholder)
|
||||
if (this.data.minValues) dropdown.setMinValues(this.data.minValues)
|
||||
@@ -799,14 +804,14 @@ export class ODQuickFile {
|
||||
/**The id of this file. */
|
||||
id: ODId
|
||||
/**The current data of this file */
|
||||
data: ODFileData = {
|
||||
data: Partial<ODFileData> = {
|
||||
file:"",
|
||||
name:"file.txt",
|
||||
description:null,
|
||||
spoiler:false
|
||||
}
|
||||
|
||||
constructor(id:ODValidId,data:ODFileData){
|
||||
constructor(id:ODValidId,data:Partial<ODFileData>){
|
||||
this.id = new ODId(id)
|
||||
this.data = data
|
||||
}
|
||||
@@ -815,7 +820,7 @@ export class ODQuickFile {
|
||||
async build(): Promise<ODFileBuildResult> {
|
||||
try{
|
||||
//create the discord.js attachment
|
||||
const file = new discord.AttachmentBuilder(this.data.file)
|
||||
const file = new discord.AttachmentBuilder(this.data.file ?? "<empty-file>")
|
||||
file.setName(this.data.name ? this.data.name : "file.txt")
|
||||
if (this.data.description) file.setDescription(this.data.description)
|
||||
if (this.data.spoiler) file.setSpoiler(this.data.spoiler)
|
||||
@@ -1055,7 +1060,7 @@ export class ODQuickEmbed {
|
||||
/**The id of this embed. */
|
||||
id: ODId
|
||||
/**The current data of this embed */
|
||||
data: ODEmbedData = {
|
||||
data: Partial<ODEmbedData> = {
|
||||
title:null,
|
||||
color:null,
|
||||
url:null,
|
||||
@@ -1071,7 +1076,7 @@ export class ODQuickEmbed {
|
||||
timestamp:null
|
||||
}
|
||||
|
||||
constructor(id:ODValidId,data:ODEmbedData){
|
||||
constructor(id:ODValidId,data:Partial<ODEmbedData>){
|
||||
this.id = new ODId(id)
|
||||
this.data = data
|
||||
}
|
||||
@@ -1097,7 +1102,7 @@ export class ODQuickEmbed {
|
||||
if (this.data.image) embed.setImage(this.data.image)
|
||||
if (this.data.thumbnail) embed.setThumbnail(this.data.thumbnail)
|
||||
if (this.data.timestamp) embed.setTimestamp(this.data.timestamp)
|
||||
if (this.data.fields.length > 0) embed.setFields(this.data.fields)
|
||||
if (this.data.fields && this.data.fields.length > 0) embed.setFields(this.data.fields)
|
||||
|
||||
return {id:this.id,embed}
|
||||
}catch(err){
|
||||
|
||||
@@ -350,10 +350,10 @@ export class ODOptionSuffixManager extends ODManager<ODOptionSuffix> {
|
||||
}
|
||||
|
||||
/**Instantly get the suffix from an `ODTicketOption`. */
|
||||
getSuffixFromOption(option:ODTicketOption,user:discord.User): string|null {
|
||||
async getSuffixFromOption(option:ODTicketOption,user:discord.User): Promise<string|null> {
|
||||
const suffix = this.getAll().find((suffix) => suffix.option.id.value == option.id.value)
|
||||
if (!suffix) return null
|
||||
return suffix.getSuffix(user)
|
||||
return await suffix.getSuffix(user)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,7 +374,7 @@ export class ODOptionSuffix extends ODManagerData {
|
||||
}
|
||||
|
||||
/**Get the suffix for a new ticket. */
|
||||
getSuffix(user:discord.User): string {
|
||||
async getSuffix(user:discord.User): Promise<string> {
|
||||
throw new ODSystemError("Tried to use an unimplemented ODOptionSuffix!")
|
||||
}
|
||||
}
|
||||
@@ -387,7 +387,7 @@ export class ODOptionSuffix extends ODManagerData {
|
||||
* Use `getSuffix()` to get the new suffix!
|
||||
*/
|
||||
export class ODOptionUserNameSuffix extends ODOptionSuffix {
|
||||
getSuffix(user:discord.User): string {
|
||||
async getSuffix(user:discord.User): Promise<string> {
|
||||
return user.username
|
||||
}
|
||||
}
|
||||
@@ -400,7 +400,7 @@ export class ODOptionUserNameSuffix extends ODOptionSuffix {
|
||||
* Use `getSuffix()` to get the new suffix!
|
||||
*/
|
||||
export class ODOptionUserIdSuffix extends ODOptionSuffix {
|
||||
getSuffix(user:discord.User): string {
|
||||
async getSuffix(user:discord.User): Promise<string> {
|
||||
return user.id
|
||||
}
|
||||
}
|
||||
@@ -426,11 +426,11 @@ export class ODOptionCounterDynamicSuffix extends ODOptionSuffix {
|
||||
async #init(){
|
||||
if (!await this.database.exists("opendiscord:option-suffix-counter",this.option.id.value)) await this.database.set("opendiscord:option-suffix-counter",this.option.id.value,0)
|
||||
}
|
||||
getSuffix(user:discord.User): string {
|
||||
const rawCurrentValue = this.database.get("opendiscord:option-suffix-counter",this.option.id.value)
|
||||
async getSuffix(user:discord.User): Promise<string> {
|
||||
const rawCurrentValue = await this.database.get("opendiscord:option-suffix-counter",this.option.id.value)
|
||||
const currentValue = (typeof rawCurrentValue != "number") ? 0 : rawCurrentValue
|
||||
const newValue = currentValue+1
|
||||
this.database.set("opendiscord:option-suffix-counter",this.option.id.value,newValue)
|
||||
await this.database.set("opendiscord:option-suffix-counter",this.option.id.value,newValue)
|
||||
return newValue.toString()
|
||||
}
|
||||
}
|
||||
@@ -456,12 +456,12 @@ export class ODOptionCounterFixedSuffix extends ODOptionSuffix {
|
||||
async #init(){
|
||||
if (!await this.database.exists("opendiscord:option-suffix-counter",this.option.id.value)) await this.database.set("opendiscord:option-suffix-counter",this.option.id.value,0)
|
||||
}
|
||||
getSuffix(user:discord.User): string {
|
||||
const rawCurrentValue = this.database.get("opendiscord:option-suffix-counter",this.option.id.value)
|
||||
async getSuffix(user:discord.User): Promise<string> {
|
||||
const rawCurrentValue = await this.database.get("opendiscord:option-suffix-counter",this.option.id.value)
|
||||
const currentValue = (typeof rawCurrentValue != "number") ? 0 : rawCurrentValue
|
||||
const newValue = (currentValue >= 9999) ? 0 : currentValue+1
|
||||
|
||||
this.database.set("opendiscord:option-suffix-counter",this.option.id.value,newValue)
|
||||
await this.database.set("opendiscord:option-suffix-counter",this.option.id.value,newValue)
|
||||
if (newValue.toString().length == 1) return "000"+newValue.toString()
|
||||
else if (newValue.toString().length == 2) return "00"+newValue.toString()
|
||||
else if (newValue.toString().length == 3) return "0"+newValue.toString()
|
||||
@@ -501,13 +501,13 @@ export class ODOptionRandomNumberSuffix extends ODOptionSuffix {
|
||||
if (history.includes(number)) return this.#generateUniqueValue(history)
|
||||
else return number
|
||||
}
|
||||
getSuffix(user:discord.User): string {
|
||||
const rawCurrentValues = this.database.get("opendiscord:option-suffix-history",this.option.id.value)
|
||||
async getSuffix(user:discord.User): Promise<string> {
|
||||
const rawCurrentValues = await this.database.get("opendiscord:option-suffix-history",this.option.id.value)
|
||||
const currentValues = ((Array.isArray(rawCurrentValues)) ? rawCurrentValues : []) as string[]
|
||||
const newValue = this.#generateUniqueValue(currentValues)
|
||||
currentValues.push(newValue)
|
||||
if (currentValues.length > 50) currentValues.shift()
|
||||
this.database.set("opendiscord:option-suffix-history",this.option.id.value,currentValues)
|
||||
await this.database.set("opendiscord:option-suffix-history",this.option.id.value,currentValues)
|
||||
return newValue
|
||||
}
|
||||
}
|
||||
@@ -539,13 +539,13 @@ export class ODOptionRandomHexSuffix extends ODOptionSuffix {
|
||||
if (history.includes(hex)) return this.#generateUniqueValue(history)
|
||||
else return hex
|
||||
}
|
||||
getSuffix(user:discord.User): string {
|
||||
const rawCurrentValues = this.database.get("opendiscord:option-suffix-history",this.option.id.value)
|
||||
async getSuffix(user:discord.User): Promise<string> {
|
||||
const rawCurrentValues = await this.database.get("opendiscord:option-suffix-history",this.option.id.value)
|
||||
const currentValues = ((Array.isArray(rawCurrentValues)) ? rawCurrentValues : []) as string[]
|
||||
const newValue = this.#generateUniqueValue(currentValues)
|
||||
currentValues.push(newValue)
|
||||
if (currentValues.length > 50) currentValues.shift()
|
||||
this.database.set("opendiscord:option-suffix-history",this.option.id.value,currentValues)
|
||||
await this.database.set("opendiscord:option-suffix-history",this.option.id.value,currentValues)
|
||||
return newValue
|
||||
}
|
||||
}
|
||||
@@ -22,5 +22,8 @@ export const migrations = [
|
||||
new utilities.ODVersionMigration(api.ODVersion.fromString("opendiscord:version","v4.0.3"),async () => {},async () => {}),
|
||||
|
||||
//MIGRATE TO v4.0.4
|
||||
new utilities.ODVersionMigration(api.ODVersion.fromString("opendiscord:version","v4.0.4"),async () => {},async () => {})
|
||||
new utilities.ODVersionMigration(api.ODVersion.fromString("opendiscord:version","v4.0.4"),async () => {},async () => {}),
|
||||
|
||||
//MIGRATE TO v4.0.5
|
||||
new utilities.ODVersionMigration(api.ODVersion.fromString("opendiscord:version","v4.0.5"),async () => {},async () => {})
|
||||
]
|
||||
@@ -456,7 +456,7 @@ export const defaultPanelsStructure = new api.ODCheckerArrayStructure("opendisco
|
||||
{key:"id",optional:false,priority:0,checker:new api.ODCheckerCustomStructure_UniqueId("opendiscord:panel-id","openticket","panel-ids",{regex:/^[A-Za-z0-9-éèçàêâôûî]+$/,minLength:3,maxLength:40,cliDisplayName:"Id",cliDisplayDescription:"The id of this panel. Used in the /panel command."})},
|
||||
{key:"name",optional:false,priority:0,checker:new api.ODCheckerStringStructure("opendiscord:panel-name",{minLength:3,maxLength:50,cliDisplayName:"Name",cliDisplayDescription:"The name of this panel."})},
|
||||
{key:"dropdown",optional:false,priority:0,checker:new api.ODCheckerBooleanStructure("opendiscord:panel-dropdown",{cliDisplayName:"Dropdown",cliDisplayDescription:"Decide whether to use buttons or a dropdown in the panel. Dropdowns only support options of the 'ticket' type!"})},
|
||||
{key:"options",optional:false,priority:0,checker:new api.ODCheckerCustomStructure_UniqueIdArray("opendiscord:panel-options","openticket","option-ids","option-ids-used",{allowDoubles:false,maxLength:25,cliDisplayPropertyName:"option",cliDisplayName:"Options",cliDisplayDescription:"A list of valid option IDs to show in this panel."},{cliDisplayName:"Option ID",cliDisplayDescription:"A valid option ID from the options.json config.",cliAutocompleteFunc:async () => {
|
||||
{key:"options",optional:false,priority:0,checker:new api.ODCheckerCustomStructure_UniqueIdArray("opendiscord:panel-options","openticket","option-ids","option-ids-used",{allowDoubles:false,minLength:1,maxLength:25,cliDisplayPropertyName:"option",cliDisplayName:"Options",cliDisplayDescription:"A list of valid option IDs to show in this panel."},{cliDisplayName:"Option ID",cliDisplayDescription:"A valid option ID from the options.json config.",cliAutocompleteFunc:async () => {
|
||||
const uncheckedRawData = opendiscord.configs.get("opendiscord:options").data
|
||||
if (!Array.isArray(uncheckedRawData)) return null
|
||||
const idList = uncheckedRawData.filter((option) => typeof option == "object" && typeof option["id"] == "string").map((option) => option.id)
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
|
||||
INFORMATION:
|
||||
============
|
||||
Open Ticket v4.0.4 - © DJdj Development
|
||||
Open Ticket v4.0.5 - © DJdj Development
|
||||
|
||||
support us: https://github.com/sponsors/DJj123dj
|
||||
discord: https://discord.dj-dj.be
|
||||
|
||||
Reference in New Issue
Block a user