diff options
Diffstat (limited to 'events/interaction.js')
-rw-r--r-- | events/interaction.js | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/events/interaction.js b/events/interaction.js index 571d8d0..8b61445 100644 --- a/events/interaction.js +++ b/events/interaction.js @@ -19,16 +19,17 @@ module.exports = { return console.log("denied interaction from (guild)"+interaction.guild.id) let date = new Date() interaction.author = interaction.user - if(interaction.isChatInputCommand()){ + if(interaction.isChatInputCommand() || interaction.isUserContextMenuCommand()){ await interaction.guild.members.fetch() interaction.user = interaction.guild.members.cache.get(interaction.user.id) let mod = util.is_mod(interaction.member) let command = global.s_commands.find(o => o.name === interaction.commandName) if(command.command.config.mod_respect_restrict) mod = false + if(!((!command.command.config.restrict||command.command.config.restrict.length==0||command.command.config.restrict.includes(interaction.channel.id))&& (!command.command.config.restricted||command.command.config.restricted.length==0||!command.command.config.restricted.includes(interaction.channel.id))) - &&!(!command.command.config.mod_respect_restrict&&mod)) + &&!(!command.command.config.mod_respect_restrict&&mod)&&!interaction.isUserContextMenuCommand()) return interaction.reply({content:"you cannot send this here! try `sns help` for more info",ephemeral:true}) if(command==null) return; @@ -40,10 +41,10 @@ module.exports = { ((date.getTime()-command.command.last_command[uid].getTime())/1000).toFixed(2)+"/"+command.command.config.cooldown+"s",ephemeral:true}) command.command.last_command[uid] = new Date(); - await command.command.s_main(client,Discord,interaction); + await command.command[interaction.isChatInputCommand()?"s_main":"c_main"](client,Discord,interaction); } else if (interaction.isAutocomplete()){ - console.log(interaction.user.id) + console.log(interaction.user.id + " : autocomplete") const focused = interaction.options.getFocused(true); let command = global.s_commands.find(o => o.name === interaction.commandName) if(interaction.options._subcommand!=null){ @@ -66,6 +67,23 @@ module.exports = { console.log("failed to send autocomplete") } + } else if (interaction.isButton()){ + console.log(global.preserve.interactions.length()) + let sel = await global.preserve.interactions.getItem(interaction.message.id) + if(sel != null){ + console.log("hi") + sel.data = await sel.fn(sel.data, interaction); + global.preserve.interactions.setItem(interaction.message.id, sel) + } + //console.log(interaction) + /* + let cid = interaction.customId.split(":") + if(cid.length > 1){ + interaction.customId = cid[1]; + let sel = global.preserve.interactions[parseInt(cid[0])] + global.preserve.interactions[parseInt(cid[0])].data = await sel.fn(sel.data, interaction) + } + */ } }) |