From 6ce017b4073562466e96afd6b38cdf1839a0da06 Mon Sep 17 00:00:00 2001 From: DJj123dj <80536295+DJj123dj@users.noreply.github.com> Date: Sun, 14 Sep 2025 22:04:42 +0200 Subject: [PATCH] Added /topic set command (Part 1, Incomplete) --- src/builders/embeds.ts | 14 +++++++++ src/core/api/defaults/builder.ts | 4 +++ src/core/api/defaults/client.ts | 2 ++ src/data/framework/commandLoader.ts | 45 ++++++++++++++++++++++++++++ src/data/framework/helpMenuLoader.ts | 24 ++++++++++----- 5 files changed, 81 insertions(+), 8 deletions(-) diff --git a/src/builders/embeds.ts b/src/builders/embeds.ts index a145298..52c2b12 100644 --- a/src/builders/embeds.ts +++ b/src/builders/embeds.ts @@ -1313,6 +1313,20 @@ const autoEmbeds = () => { } const extraEmbeds = () => { + //TOPIC SET + embeds.add(new api.ODEmbed("opendiscord:topic-set")) + embeds.get("opendiscord:topic-set").workers.add( + new api.ODWorker("opendiscord:topic-set",0,async (instance,params,source) => { + const {user,topic} = params + + instance.setAuthor(user.displayName,user.displayAvatarURL()) + instance.setColor(generalConfig.data.mainColor) + instance.setTitle(utilities.emojiTitle("ℹ️","Topic Changed")) //TODO TRANSLATION!!! + instance.setDescription("The channel topic has been changed by "+discord.userMention(user.id)+" successfully!") //TODO TRANSLATION!!! + if (topic) instance.addFields({name:"Topic"+":",value:"```"+topic+"```"}) //TODO TRANSLATION!!! + }) + ) + //PRIORITY SET embeds.add(new api.ODEmbed("opendiscord:priority-set")) embeds.get("opendiscord:priority-set").workers.add( diff --git a/src/core/api/defaults/builder.ts b/src/core/api/defaults/builder.ts index 7d8ff2a..bb84507 100644 --- a/src/core/api/defaults/builder.ts +++ b/src/core/api/defaults/builder.ts @@ -295,6 +295,8 @@ export interface ODEmbedManagerIds_Default { "opendiscord:autodelete-enable":{source:"slash"|"text"|"other",params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,time:number,reason:string|null},workers:"opendiscord:autodelete-enable"}, "opendiscord:autoclose-disable":{source:"slash"|"text"|"other",params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,reason:string|null},workers:"opendiscord:autoclose-disable"}, "opendiscord:autodelete-disable":{source:"slash"|"text"|"other",params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,reason:string|null},workers:"opendiscord:autodelete-disable"}, + + "opendiscord:topic-set":{source:"slash"|"text"|"other",params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,topic:string},workers:"opendiscord:topic-set"}, "opendiscord:priority-set":{source:"slash"|"text"|"other",params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,priority:ODPriority,reason:string|null},workers:"opendiscord:priority-set"}, "opendiscord:priority-get":{source:"slash"|"text"|"other",params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,priority:ODPriority},workers:"opendiscord:priority-get"}, } @@ -431,6 +433,8 @@ export interface ODMessageManagerIds_Default { "opendiscord:autodelete-enable":{source:"slash"|"text"|"other",params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,time:number,reason:string|null},workers:"opendiscord:autodelete-enable"}, "opendiscord:autoclose-disable":{source:"slash"|"text"|"other",params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,reason:string|null},workers:"opendiscord:autoclose-disable"}, "opendiscord:autodelete-disable":{source:"slash"|"text"|"other",params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,reason:string|null},workers:"opendiscord:autodelete-disable"}, + + "opendiscord:topic-set":{source:"slash"|"text"|"other",params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,topic:string},workers:"opendiscord:topic-set"}, "opendiscord:priority-set":{source:"slash"|"text"|"other",params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,priority:ODPriority,reason:string|null},workers:"opendiscord:priority-set"}, "opendiscord:priority-get":{source:"slash"|"text"|"other",params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,priority:ODPriority},workers:"opendiscord:priority-get"}, } diff --git a/src/core/api/defaults/client.ts b/src/core/api/defaults/client.ts index c191d09..a56ad33 100644 --- a/src/core/api/defaults/client.ts +++ b/src/core/api/defaults/client.ts @@ -50,6 +50,7 @@ export interface ODSlashCommandManagerIds_Default { "opendiscord:clear":ODSlashCommand, "opendiscord:autoclose":ODSlashCommand, "opendiscord:autodelete":ODSlashCommand, + "opendiscord:topic":ODSlashCommand, "opendiscord:priority":ODSlashCommand, } @@ -121,6 +122,7 @@ export interface ODTextCommandManagerIds_Default { "opendiscord:autoclose-enable":ODTextCommand, "opendiscord:autodelete-disable":ODTextCommand, "opendiscord:autodelete-enable":ODTextCommand, + "opendiscord:topic-set":ODTextCommand, "opendiscord:priority-set":ODTextCommand, "opendiscord:priority-get":ODTextCommand, } diff --git a/src/data/framework/commandLoader.ts b/src/data/framework/commandLoader.ts index 08133e7..d20df8f 100644 --- a/src/data/framework/commandLoader.ts +++ b/src/data/framework/commandLoader.ts @@ -555,6 +555,32 @@ export const loadAllSlashCommands = async () => { } ] })) + + //TOPIC + if (allowedCommands.includes("topic")) commands.add(new api.ODSlashCommand("opendiscord:topic",{ + type:act.ChatInput, + name:"topic", + description:"Change the topic of the ticket channel.", //TODO TRANSLATION!!! + contexts:[discord.InteractionContextType.Guild], + integrationTypes:[discord.ApplicationIntegrationType.GuildInstall], + options:[ + { + name:"set", + description:"Set the topic of the ticket channel to a specific value.", //TODO TRANSLATION!!! + type:acot.Subcommand, + options:[ + { + name:"topic", + description:"The new topic of the channel.", + type:acot.String, + required:true + } + ] + }, + //TODO: list (v4.2) + ] + })) + //PRIORITY if (allowedCommands.includes("priority")) commands.add(new api.ODSlashCommand("opendiscord:priority",{ type:act.ChatInput, @@ -1093,6 +1119,25 @@ export const loadAllTextCommands = async () => { } ] })) + + //TOPIC + //TODO: topic list (v4.2) + if (allowedCommands.includes("topic")) commands.add(new api.ODTextCommand("opendiscord:topic-set",{ + name:"topic set", + prefix, + dmPermission:false, + guildPermission:true, + allowBots:false, + options:[ + { + name:"topic", + type:"string", + required:true, + allowSpaces:true + } + ] + })) + //PRIORITY //TODO: priority list (v4.2) if (allowedCommands.includes("priority")) commands.add(new api.ODTextCommand("opendiscord:priority-set",{ diff --git a/src/data/framework/helpMenuLoader.ts b/src/data/framework/helpMenuLoader.ts index 9f301b1..3cc1917 100644 --- a/src/data/framework/helpMenuLoader.ts +++ b/src/data/framework/helpMenuLoader.ts @@ -207,13 +207,13 @@ export const loadAllHelpMenuComponents = async () => { const advanced = helpmenu.get("opendiscord:advanced") if (advanced){ - if (allowedCommands.includes("stats")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:stats-global",5,{ + if (allowedCommands.includes("stats")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:stats-global",9,{ textName:prefix+"stats global", textDescription:lang.getTranslation("commands.statsGlobal"), slashName:"/stats global", slashDescription:lang.getTranslation("commands.statsGlobal") })) - if (allowedCommands.includes("stats")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:stats-ticket",4,{ + if (allowedCommands.includes("stats")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:stats-ticket",8,{ textName:prefix+"stats ticket", textDescription:lang.getTranslation("commands.statsTicket"), slashName:"/stats ticket", @@ -221,7 +221,7 @@ export const loadAllHelpMenuComponents = async () => { textOptions:[{name:"ticket",optional:false}], slashOptions:[{name:"ticket",optional:false}] })) - if (allowedCommands.includes("stats")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:stats-user",2,{ + if (allowedCommands.includes("stats")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:stats-user",7,{ textName:prefix+"stats user", textDescription:lang.getTranslation("commands.statsUser"), slashName:"/stats user", @@ -229,7 +229,7 @@ export const loadAllHelpMenuComponents = async () => { textOptions:[{name:"user",optional:false}], slashOptions:[{name:"user",optional:false}] })) - if (allowedCommands.includes("stats")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:stats-reset",2,{ + if (allowedCommands.includes("stats")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:stats-reset",6,{ textName:prefix+"stats reset", textDescription:lang.getTranslation("commands.statsReset"), slashName:"/stats reset", @@ -237,7 +237,7 @@ export const loadAllHelpMenuComponents = async () => { textOptions:[{name:"reason",optional:true}], slashOptions:[{name:"reason",optional:true}] })) - if (allowedCommands.includes("autoclose")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:autoclose-disable",1,{ + if (allowedCommands.includes("autoclose")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:autoclose-disable",5,{ textName:prefix+"autoclose disable", textDescription:lang.getTranslation("commands.autocloseDisable"), slashName:"/autoclose disable", @@ -245,7 +245,7 @@ export const loadAllHelpMenuComponents = async () => { textOptions:[{name:"reason",optional:true}], slashOptions:[{name:"reason",optional:true}] })) - if (allowedCommands.includes("autoclose")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:autoclose-enable",0,{ + if (allowedCommands.includes("autoclose")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:autoclose-enable",4,{ textName:prefix+"autoclose enable", textDescription:lang.getTranslation("commands.autocloseEnable"), slashName:"/autoclose enable", @@ -253,7 +253,7 @@ export const loadAllHelpMenuComponents = async () => { textOptions:[{name:"time",optional:false},{name:"reason",optional:true}], slashOptions:[{name:"time",optional:false},{name:"reason",optional:true}] })) - if (allowedCommands.includes("autodelete")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:autodelete-disable",1,{ + if (allowedCommands.includes("autodelete")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:autodelete-disable",3,{ textName:prefix+"autodelete disable", textDescription:lang.getTranslation("commands.autodeleteDisable"), slashName:"/autodelete disable", @@ -261,7 +261,7 @@ export const loadAllHelpMenuComponents = async () => { textOptions:[{name:"reason",optional:true}], slashOptions:[{name:"reason",optional:true}] })) - if (allowedCommands.includes("autodelete")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:autodelete-enable",0,{ + if (allowedCommands.includes("autodelete")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:autodelete-enable",2,{ textName:prefix+"autodelete enable", textDescription:lang.getTranslation("commands.autodeleteEnable"), slashName:"/autodelete enable", @@ -269,6 +269,14 @@ export const loadAllHelpMenuComponents = async () => { textOptions:[{name:"time",optional:false},{name:"reason",optional:true}], slashOptions:[{name:"time",optional:false},{name:"reason",optional:true}] })) + if (allowedCommands.includes("topic")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:topic-set",1,{ + textName:prefix+"topic set", + textDescription:"Change the topic of the ticket channel.", //TODO TRANSLATION!!! + slashName:"/topic set", + slashDescription:"Change the topic of the ticket channel.", //TODO TRANSLATION!!! + textOptions:[{name:"topic",optional:false}], + slashOptions:[{name:"topic",optional:false}] + })) if (allowedCommands.includes("priority")) advanced.add(new api.ODHelpMenuCommandComponent("opendiscord:priority-set",0,{ textName:prefix+"priority set", textDescription:"Set the priority of the ticket channel.", //TODO TRANSLATION!!!