aboutsummaryrefslogtreecommitdiff
path: root/events
diff options
context:
space:
mode:
Diffstat (limited to 'events')
-rw-r--r--events/interaction.js26
-rw-r--r--events/ready.js4
2 files changed, 25 insertions, 5 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)
+ }
+ */
}
})
diff --git a/events/ready.js b/events/ready.js
index 889c0b1..02064a8 100644
--- a/events/ready.js
+++ b/events/ready.js
@@ -5,6 +5,7 @@ const { EmbedBuilder } = require("discord.js");
let db = require("../src/db")
let settings = require('../src/settings')
let config_loc = __filename+".json"
+
module.exports = {
name : "ready",
config_loc : config_loc,
@@ -12,6 +13,7 @@ module.exports = {
await db._raw.sync()
let config = JSON.parse(fs.readFileSync(config_loc))
client.once("ready", async () => {
+
//preload
global.channels = {}
for(let guild of Object.keys(settings.preloads)){
@@ -30,7 +32,7 @@ module.exports = {
}
//end
- //register slash commands
+ //register slash/user commands
let passed = 0;
let failed = 0;
client.guilds.cache.forEach((g)=>{