diff --git a/commands/NSFW/nsfw.js b/commands/NSFW/nsfw.js index 9f77f786..78e2f25d 100644 --- a/commands/NSFW/nsfw.js +++ b/commands/NSFW/nsfw.js @@ -34,60 +34,60 @@ class NSFW extends BaseCommand { async execute(client, interaction) { await interaction.deferReply({ ephemeral: true }); - if (!interaction.channel.nsfw || interaction.channel.type === ChannelType.DM) return interaction.replyT("misc:NSFW_COMMAND", null, { ephemeral: true, edit: true }); - - const tags = ["hentai", "ecchi", "lewdanimegirls", "hentaifemdom", "animefeets", "animebooty", "biganimetiddies", "sideoppai", "ahegao"].map(tag => - JSON.parse(JSON.stringify({ - label: tag, - value: tag - })) - ); - - const row = new ActionRowBuilder() - .addComponents( - new SelectMenuBuilder() - .setCustomId("nsfw_select") - .setPlaceholder(client.translate("common:NOTHING_SELECTED")) - .addOptions(tags) + if (interaction.channel.type === ChannelType.DM || interaction.channel.nsfw) { + const tags = ["hentai", "ecchi", "lewdanimegirls", "hentaifemdom", "animefeets", "animebooty", "biganimetiddies", "sideoppai", "ahegao"].map(tag => + JSON.parse(JSON.stringify({ + label: tag, + value: tag + })) ); - await interaction.editReply({ - content: interaction.translate("common:AVAILABLE_OPTIONS"), - ephemeral: true, - components: [row] - }); + const row = new ActionRowBuilder() + .addComponents( + new SelectMenuBuilder() + .setCustomId("nsfw_select") + .setPlaceholder(client.translate("common:NOTHING_SELECTED")) + .addOptions(tags) + ); - const filter = i => i.user.id === interaction.user.id; - const collector = interaction.channel.createMessageComponentCollector({ filter, idle: (2 * 60 * 1000) }); - - collector.on("collect", async i => { - if (i.isSelectMenu() && i.customId === "nsfw_select") { - i.deferUpdate(); - - const tag = i?.values[0]; - const res = await fetch(`https://meme-api.herokuapp.com/gimme/${tag}`).then(response => response.json()); - - const embed = new EmbedBuilder() - .setColor(client.config.embed.color) - .setFooter({ - text: client.config.embed.footer - }) - .setTitle(res.title) - .setDescription(`${interaction.translate("fun/memes:SUBREDDIT")}: **${res.subreddit}**\n${interaction.translate("common:AUTHOR")}: **${res.author}**\n${interaction.translate("fun/memes:UPS")}: **${res.ups}**`) - .setImage(res.url) - .setTimestamp(); - - await interaction.editReply({ - embeds: [embed] - }); - } - }); - - collector.on("end", () => { - return interaction.editReply({ - components: [] + await interaction.editReply({ + content: interaction.translate("common:AVAILABLE_OPTIONS"), + ephemeral: true, + components: [row] }); - }); + + const filter = i => i.user.id === interaction.user.id; + const collector = interaction.channel.createMessageComponentCollector({ filter, idle: (2 * 60 * 1000) }); + + collector.on("collect", async i => { + if (i.isSelectMenu() && i.customId === "nsfw_select") { + i.deferUpdate(); + + const tag = i?.values[0]; + const res = await fetch(`https://meme-api.herokuapp.com/gimme/${tag}`).then(response => response.json()); + + const embed = new EmbedBuilder() + .setColor(client.config.embed.color) + .setFooter({ + text: client.config.embed.footer + }) + .setTitle(res.title) + .setDescription(`${interaction.translate("fun/memes:SUBREDDIT")}: **${res.subreddit}**\n${interaction.translate("common:AUTHOR")}: **${res.author}**\n${interaction.translate("fun/memes:UPS")}: **${res.ups}**`) + .setImage(res.url) + .setTimestamp(); + + await interaction.editReply({ + embeds: [embed] + }); + } + }); + + collector.on("end", () => { + return interaction.editReply({ + components: [] + }); + }); + } else return interaction.replyT("misc:NSFW_COMMAND", null, { ephemeral: true, edit: true }); } } diff --git a/index.js b/index.js index 048e7340..dfdf3c1e 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,7 @@ const { GatewayIntentBits } = require("discord.js"), JaBa = require("./base/JaBa"); const client = new JaBa({ - intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildBans, GatewayIntentBits.GuildEmojisAndStickers, GatewayIntentBits.GuildIntegrations, GatewayIntentBits.GuildInvites, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildPresences, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessageReactions, GatewayIntentBits.GuildMessageTyping, GatewayIntentBits.MessageContent ], + intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildBans, GatewayIntentBits.GuildEmojisAndStickers, GatewayIntentBits.GuildIntegrations, GatewayIntentBits.GuildInvites, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildPresences, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessageReactions, GatewayIntentBits.GuildMessageTyping, GatewayIntentBits.MessageContent, GatewayIntentBits.DirectMessageTyping, GatewayIntentBits.DirectMessages, GatewayIntentBits.DirectMessageReactions ], allowedMentions: { parse: ["everyone", "roles", "users"] } });