2024-02-06 21:45:53 +05:00
|
|
|
const { SlashCommandBuilder, ActionRowBuilder, StringSelectMenuBuilder } = require("discord.js");
|
2022-07-31 17:08:00 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand"),
|
|
|
|
fetch = require("node-fetch");
|
|
|
|
|
|
|
|
class Memes extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../base/Client")} client
|
2022-07-31 17:08:00 +05:00
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("memes")
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDescription(client.translate("fun/memes:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-07-05 00:58:06 +05:00
|
|
|
uk: client.translate("fun/memes:DESCRIPTION", null, "uk-UA"),
|
|
|
|
ru: client.translate("fun/memes:DESCRIPTION", null, "ru-RU"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(false),
|
2022-07-31 17:08:00 +05:00
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-07-31 17:08:00 +05:00
|
|
|
});
|
|
|
|
}
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-07-31 17:08:00 +05:00
|
|
|
*/
|
2023-10-31 22:24:40 +05:00
|
|
|
async onLoad(client) {
|
|
|
|
client.on("interactionCreate", async interaction => {
|
|
|
|
if (!interaction.isStringSelectMenu()) return;
|
|
|
|
|
|
|
|
if (interaction.customId === "memes_select") {
|
|
|
|
interaction.deferUpdate();
|
|
|
|
|
2024-02-09 23:26:57 +05:00
|
|
|
interaction.guild.data = await client.findOrCreateGuild(interaction.guildId);
|
|
|
|
|
2023-10-31 22:24:40 +05:00
|
|
|
const tag = interaction.values[0];
|
|
|
|
const res = await fetch(`https://meme-api.com/gimme/${tag}`).then(response => response.json());
|
|
|
|
|
2024-02-06 21:45:53 +05:00
|
|
|
const embed = client.embed({
|
|
|
|
title: res.title,
|
|
|
|
description: `${interaction.translate("fun/memes:SUBREDDIT")}: **${res.subreddit}**\n${interaction.translate("common:AUTHOR")}: **${res.author}**\n${interaction.translate("fun/memes:UPS")}: **${res.ups}**`,
|
|
|
|
image: res.url,
|
|
|
|
});
|
2023-10-31 22:24:40 +05:00
|
|
|
|
|
|
|
await interaction.editReply({
|
|
|
|
embeds: [embed],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2022-07-31 17:08:00 +05:00
|
|
|
}
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-01 20:06:09 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-07-31 17:08:00 +05:00
|
|
|
*/
|
|
|
|
async execute(client, interaction) {
|
2023-10-31 22:24:40 +05:00
|
|
|
await interaction.deferReply({ ephemeral: true });
|
2022-08-28 21:53:54 +05:00
|
|
|
|
2023-03-26 18:31:19 +05:00
|
|
|
const tags = ["funny", "memes", "dankmemes", "me_irl", "wholesomememes"].map(tag =>
|
2023-07-05 00:58:06 +05:00
|
|
|
JSON.parse(
|
|
|
|
JSON.stringify({
|
|
|
|
label: tag,
|
|
|
|
value: tag,
|
|
|
|
}),
|
|
|
|
),
|
2022-07-31 17:08:00 +05:00
|
|
|
);
|
|
|
|
|
2023-11-04 16:56:10 +05:00
|
|
|
const row = new ActionRowBuilder().addComponents(new StringSelectMenuBuilder().setCustomId("memes_select").setPlaceholder(interaction.translate("common:NOTHING_SELECTED")).addOptions(tags));
|
2022-07-31 17:08:00 +05:00
|
|
|
|
2023-10-31 22:24:40 +05:00
|
|
|
await interaction.editReply({
|
2022-12-15 21:02:38 +05:00
|
|
|
components: [row],
|
2022-07-31 17:08:00 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = Memes;
|