🚸 more logical meme command

This commit is contained in:
Axel Olausson Holtenäs 2022-05-28 12:55:23 +02:00
parent 50f070787c
commit 518ec431d8
No known key found for this signature in database
GPG key ID: 7BF6826B76382CBA

View file

@ -11,11 +11,12 @@ export default {
builder: (command: SlashCommandSubcommandBuilder) => { builder: (command: SlashCommandSubcommandBuilder) => {
return command.setName("meme").setDescription("Get a meme from r/memes)"); return command.setName("meme").setDescription("Get a meme from r/memes)");
}, },
execute: async (interaction: CommandInteraction) => { execute: async (interaction: CommandInteraction) => {
if (interaction.guild == null) return; const { guild } = interaction;
const { successColor, footerText, footerIcon } = await getEmbedConfig(
interaction.guild const embedConfig = await getEmbedConfig(guild);
);
await axios await axios
.get("https://www.reddit.com/r/memes/random/.json") .get("https://www.reddit.com/r/memes/random/.json")
.then(async (res) => { .then(async (res) => {
@ -23,14 +24,28 @@ export default {
const content = response[0].data; const content = response[0].data;
const embed = new MessageEmbed() const embed = new MessageEmbed()
.setTitle(content.title) .setAuthor({
name: content.title,
iconURL:
"https://www.redditinc.com/assets/images/site/reddit-logo.png",
url: `https://reddit.com${content.permalink}`,
})
.setTitle("[:sweat_smile:] Meme")
.addFields([
{ name: "Author", value: content.author, inline: true },
{
name: "Votes",
value: `${content.ups}/${content.downs}`,
inline: true,
},
])
.setTimestamp(new Date()) .setTimestamp(new Date())
.setImage(content.url) .setImage(content.url)
.setFooter({ .setFooter({
text: `👍 ${content.ups}︱👎 ${content.downs}\n${footerText}`, text: embedConfig.footerText,
iconURL: footerIcon, iconURL: embedConfig.footerIcon,
}) })
.setColor(successColor); .setColor(embedConfig.successColor);
return interaction.editReply({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
}) })