aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commands/mod/sticky.js18
-rw-r--r--commands/mod/ticket.js2
-rw-r--r--commands/util/emote.js2
-rw-r--r--commands/util/help.js2
-rw-r--r--index.js109
5 files changed, 80 insertions, 53 deletions
diff --git a/commands/mod/sticky.js b/commands/mod/sticky.js
index f5034de..fc82758 100644
--- a/commands/mod/sticky.js
+++ b/commands/mod/sticky.js
@@ -31,17 +31,21 @@ module.exports = {
}
},
- s_options:[{type:"string",name:"action",desc:"what to do",required:true,autocomplete:["add","remove","dump"]},
- {type:"string",name:"message",desc:"(required for add) message to be sent",required:false,autocomplete:false},
- {type:"channel",name:"chan",desc:"(required for remove and add) channel to clear",required:false,autocomplete:false},
- {type:"bool",name:"embed",desc:"whether or not to use a embed",required:false,autocomplete:false}],
+ //s_options:[{type:"string",name:"action",desc:"what to do",required:true,autocomplete:false,choices:["add","remove","dump"]},
+ // {type:"string",name:"message",desc:"(required for add) message to be sent",required:false,autocomplete:false},
+ // {type:"channel",name:"chan",desc:"(required for remove and add) channel to clear",required:false,autocomplete:false},
+ // {type:"bool",name:"embed",desc:"whether or not to use a embed",required:false,autocomplete:false}],
+ s_options:[{type:"sub",name:"add",options:[{type:"string",name:"message",desc:"message to be sent",required:true,autocomplete:false},{type:"channel",name:"chan",desc:"channel to use",required:true,autocomplete:false}]},
+ {type:"sub",name:"remove",options:[{type:"channel",name:"chan",desc:"channel to clear",required:true,autocomplete:false}]},
+ {type:"sub",name:"dump",options:[]}
+ ],
async s_main(client,Discord,interaction){
- let action = interaction.options.getString("action")
+ let action = interaction.options.getSubcommand()
let mess = interaction.options.getString("message")
let chan = interaction.options.getChannel("chan")
let embed = interaction.options.getBoolean("embed")
- if(!options.includes(action))
- return interaction.reply({content:"please use the autocomplete, (valid values are add, remove, and dump)",ephemeral: true})
+ //if(!options.includes(action))
+ // return interaction.reply({content:"please use the autocomplete, (valid values are add, remove, and dump)",ephemeral: true})
if(action=="add") return this.p_add(client,Discord,interaction,chan.id,mess,embed)
if(action=="remove") return this.p_rem(client,Discord,interaction,chan.id)
if(action=="dump") return this.p_dump(client,Discord,interaction)
diff --git a/commands/mod/ticket.js b/commands/mod/ticket.js
index e499dd8..ba3c99e 100644
--- a/commands/mod/ticket.js
+++ b/commands/mod/ticket.js
@@ -24,7 +24,7 @@ module.exports = {
this.exec(client,{att:matt,action:action,ticket_id:ticket_id,r_message:r_message,message:message})
},
s_options:[{type:"string",name:"ticket",desc:"ticket id",required:true,autocomplete: async function(){ let tik = await db.Tickets.findAll({attributes:['ticket'],where:{status:'open'}}); let out = []; for(let t of tik) out.push(t.ticket); return out; }},
- {type:"string",name:"action",desc:"operation to perform",required:true,autocomplete:["reply","close","dump"]},
+ {type:"string",name:"action",desc:"operation to perform",required:true,autocomplete:false,choices:["reply","close","dump"]},
{type:"string",name:"message",desc:"message to reply with",required:false,autocomplete:false},
{type:"attachment",name:"attachment",desc:"attachment to reply with",required:false,autocomplete:false}],
async s_main(client,Discord,interaction){
diff --git a/commands/util/emote.js b/commands/util/emote.js
index c88f0b4..a6f4430 100644
--- a/commands/util/emote.js
+++ b/commands/util/emote.js
@@ -20,7 +20,7 @@ module.exports = {
{type:"user",name:"user",desc:"user to emote to (may be optional)",required:false,autocomplete:false}],
async s_main (client,Discord,interaction){
let emote = interaction.options.getString("emote");
- if(Object.keys(config.avaliable_multi).includes(emote)||Object.keys(config.avaliable_solo).includes(emote))
+ if(Object.keys(config.avaliable_multi.value).includes(emote)||Object.keys(config.avaliable_solo.value).includes(emote))
this.exec(client,{message:interaction,emote:emote,mentioned:interaction.options.getUser("user")})
else
interaction.reply({content:"invalid emote!", ephemeral: true})
diff --git a/commands/util/help.js b/commands/util/help.js
index b52ee12..a8d5cb4 100644
--- a/commands/util/help.js
+++ b/commands/util/help.js
@@ -30,7 +30,7 @@ module.exports = {
async main (client,Discord,message,args){
this.exec(client,{message:message,specify:args[0]})
},
- s_options:[{type:"string",name:"command",desc:"command to be specified",required:false,autocomplete:command_names}],
+ s_options:[{type:"string",name:"command",desc:"command to be specified",required:false,autocomplete:false,choices:command_names}],
async s_main(client,Discord,interaction){
this.exec(client,{message:interaction,specify:interaction.options.getString("command")})
},
diff --git a/index.js b/index.js
index 787ef52..3b70443 100644
--- a/index.js
+++ b/index.js
@@ -41,6 +41,71 @@ const client = new Client({
client.login(TOKEN);
+function update_options(scom,options){
+ for(let opt of options){
+ let autocomplete = opt.autocomplete!=null&&opt.autocomplete!=false;
+ switch(opt.type){
+ case 'string':
+ scom.addStringOption(option => {
+ option.setName(opt.name)
+ .setDescription(opt.desc)
+ .setRequired(opt.required)
+ .setAutocomplete(autocomplete)
+ if(!autocomplete&&opt.choices!=null&&opt.choices!=false){
+ if(typeof opt.choices[0] === 'string'){
+ for(let i in opt.choices) opt.choices[i] = {name:opt.choices[i],value:opt.choices[i]}
+ }
+ option.setChoices(...opt.choices)
+ }
+ return option;
+ })
+ break;
+ case 'bool': case 'boolean':
+ scom.addBooleanOption(option =>
+ option.setName(opt.name)
+ .setDescription(opt.desc)
+ .setRequired(opt.required))
+ break;
+ case 'channel':
+ scom.addChannelOption(option =>
+ option.setName(opt.name)
+ .setDescription(opt.desc)
+ .setRequired(opt.required))
+ break;
+ case 'user':
+ scom.addUserOption(option =>
+ option.setName(opt.name)
+ .setDescription(opt.desc)
+ .setRequired(opt.required))
+ break;
+ case 'role':
+ scom.addRoleOption(option =>
+ option.setName(opt.name)
+ .setDescription(opt.desc)
+ .setRequired(opt.required))
+ break;
+ case 'attachment':
+ scom.addAttachmentOption(option =>
+ option.setName(opt.name)
+ .setDescription(opt.desc)
+ .setRequired(opt.required))
+ break;
+ case 'sub':
+ scom.addSubcommand(subcommand => {
+ subcommand
+ .setName(opt.name)
+ .setDescription("test")
+ console.log(opt.options)
+ return update_options(subcommand, opt.options)
+ })
+ break;
+ }
+
+ }
+ scom.opt = options
+ return scom;
+}
+
let commands = []
let s_commands = []
fs.readdirSync("./commands/").forEach(folder => {
@@ -57,49 +122,7 @@ fs.readdirSync("./commands/").forEach(folder => {
if(com.mod_only)
scom.setDefaultMemberPermissions(PermissionsBitField.Flags.KickMembers)
if(com.s_options!=null){
- for(let opt of com.s_options){
- switch(opt.type){
- case 'string':
- scom.addStringOption(option =>
- option.setName(opt.name)
- .setDescription(opt.desc)
- .setRequired(opt.required)
- .setAutocomplete(opt.autocomplete!=null&&opt.autocomplete!=false))
- break;
- case 'bool': case 'boolean':
- scom.addBooleanOption(option =>
- option.setName(opt.name)
- .setDescription(opt.desc)
- .setRequired(opt.required))
- break;
- case 'channel':
- scom.addChannelOption(option =>
- option.setName(opt.name)
- .setDescription(opt.desc)
- .setRequired(opt.required))
- break;
- case 'user':
- scom.addUserOption(option =>
- option.setName(opt.name)
- .setDescription(opt.desc)
- .setRequired(opt.required))
- break;
- case 'role':
- scom.addRoleOption(option =>
- option.setName(opt.name)
- .setDescription(opt.desc)
- .setRequired(opt.required))
- break;
- case 'attachment':
- scom.addAttachmentOption(option =>
- option.setName(opt.name)
- .setDescription(opt.desc)
- .setRequired(opt.required))
- break;
- }
-
- }
- scom.opt = com.s_options
+ update_options(scom,com.s_options);
}
scom = scom.toJSON()
scom.command = com