diff options
Diffstat (limited to 'events')
-rw-r--r-- | events/interaction.js | 11 | ||||
-rw-r--r-- | events/message.js | 12 |
2 files changed, 21 insertions, 2 deletions
diff --git a/events/interaction.js b/events/interaction.js index c65ecb7..b3a5be1 100644 --- a/events/interaction.js +++ b/events/interaction.js @@ -16,6 +16,7 @@ module.exports = { if(!settings["allowed-servers"].includes(interaction.guild.id)) return console.log("denied interaction from (guild)"+interaction.guild.id) let date = new Date() + interaction.author = interaction.user if(interaction.isChatInputCommand()){ await interaction.guild.members.fetch() @@ -27,7 +28,7 @@ module.exports = { return interaction.reply({content:"you cannot send this here! try `sns help` for more info",ephemeral:true}) if(command==null) return; - interaction.author = interaction.user + let uid = interaction.user.id; if(!mod&&command.command.last_command[uid]!=null&&(date.getTime()-command.command.last_command[uid].getTime())/1000<command.command.config.cooldown) @@ -41,8 +42,14 @@ module.exports = { const focused = interaction.options.getFocused(true); let command = global.s_commands.find(o => o.name === interaction.commandName) + if(interaction.options._subcommand!=null){ + //command = command.options.find(o => o.name === interaction.options._subcommand).options.find(o => o.name === focused.name) + command = (command.command.s_options.find(o => o.name === interaction.options._subcommand)) + command.opt = command.options; + } let subcommand = command.opt.find(o => o.name === focused.name) - let autocomplete = (typeof subcommand.autocomplete === 'function' ? await subcommand.autocomplete() : subcommand.autocomplete); + + let autocomplete = (typeof subcommand.autocomplete === 'function' ? await subcommand.autocomplete(interaction) : subcommand.autocomplete); const filtered = autocomplete.filter(choice => choice.startsWith(focused.value)); if(filtered.length>25) filtered.length=25 diff --git a/events/message.js b/events/message.js index 59e79ef..facd708 100644 --- a/events/message.js +++ b/events/message.js @@ -17,6 +17,18 @@ module.exports = { return require("./dm").main(client,Discord,message) if(!settings["allowed-servers"].includes(message.guild.id)||message.author.bot||message.member==null) return; + //track message + let utrack = await db.Track.findAll({where:{user:message.author.id,track:true}}) + if(utrack.length!=0){ + utrack = utrack[0]; + let words = JSON.parse(utrack.words); + for(let w of words){ + if(message.content.includes(w.word)) w.count+=message.content.split(w.word).length-1; + } + db.Track.update({words:JSON.stringify(words)},{where:{user:message.author.id,track:true}}) + } + //done w/ track + //handle sticky messages let stickies = await db.Sticky.findAll(); for(let s of stickies){ |