Откат

This commit is contained in:
JonnyBro 2022-10-11 15:19:22 +05:00
parent c5343ad76e
commit ba19dd7ca0

View file

@ -1,4 +1,4 @@
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, SelectMenuBuilder, ChannelType } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, SelectMenuBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"), const BaseCommand = require("../../base/BaseCommand"),
fetch = require("node-fetch"); fetch = require("node-fetch");
@ -14,7 +14,7 @@ class NSFW extends BaseCommand {
.setDescription(client.translate("nsfw/nsfw:DESCRIPTION")), .setDescription(client.translate("nsfw/nsfw:DESCRIPTION")),
aliases: [], aliases: [],
dirname: __dirname, dirname: __dirname,
guildOnly: false, guildOnly: true,
ownerOnly: false ownerOnly: false
}); });
} }
@ -34,60 +34,60 @@ class NSFW extends BaseCommand {
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
if (interaction.channel.type === ChannelType.DM || interaction.channel.nsfw) { if (!interaction.channel.nsfw) 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({ const tags = ["hentai", "ecchi", "lewdanimegirls", "hentaifemdom", "animefeets", "animebooty", "biganimetiddies", "sideoppai", "ahegao"].map(tag =>
label: tag, JSON.parse(JSON.stringify({
value: tag label: tag,
})) value: tag
}))
);
const row = new ActionRowBuilder()
.addComponents(
new SelectMenuBuilder()
.setCustomId("nsfw_select")
.setPlaceholder(client.translate("common:NOTHING_SELECTED"))
.addOptions(tags)
); );
const row = new ActionRowBuilder() await interaction.editReply({
.addComponents( content: interaction.translate("common:AVAILABLE_OPTIONS"),
new SelectMenuBuilder() ephemeral: true,
.setCustomId("nsfw_select") components: [row]
.setPlaceholder(client.translate("common:NOTHING_SELECTED")) });
.addOptions(tags)
);
await interaction.editReply({ const filter = i => i.user.id === interaction.user.id;
content: interaction.translate("common:AVAILABLE_OPTIONS"), const collector = interaction.channel.createMessageComponentCollector({ filter, idle: (2 * 60 * 1000) });
ephemeral: true,
components: [row]
});
const filter = i => i.user.id === interaction.user.id; collector.on("collect", async i => {
const collector = interaction.channel.createMessageComponentCollector({ filter, idle: (2 * 60 * 1000) }); if (i.isSelectMenu() && i.customId === "nsfw_select") {
i.deferUpdate();
collector.on("collect", async i => { const tag = i?.values[0];
if (i.isSelectMenu() && i.customId === "nsfw_select") { const res = await fetch(`https://meme-api.herokuapp.com/gimme/${tag}`).then(response => response.json());
i.deferUpdate();
const tag = i?.values[0]; const embed = new EmbedBuilder()
const res = await fetch(`https://meme-api.herokuapp.com/gimme/${tag}`).then(response => response.json()); .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();
const embed = new EmbedBuilder() await interaction.editReply({
.setColor(client.config.embed.color) embeds: [embed]
.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: []
}); });
}
});
collector.on("end", () => {
return interaction.editReply({
components: []
}); });
} else return interaction.replyT("misc:NSFW_COMMAND", null, { ephemeral: true, edit: true }); });
} }
} }