Skip to content

Commit

Permalink
feat: robust meme command
Browse files Browse the repository at this point in the history
  • Loading branch information
skuzow committed Aug 21, 2023
1 parent 760b33c commit a846d97
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/commands/fun/meme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ export default new client.command({
client: ExtendedClient,
interaction: ChatInputCommandInteraction<CacheType>
) => {
const meme: Meme = await getMeme();
const memeEmbed: EmbedBuilder = generateMemeEmbed(meme);
await interaction.reply({ embeds: [memeEmbed] });
try {
const meme: Meme = await getMeme();
const memeEmbed: EmbedBuilder = generateMemeEmbed(meme);
await interaction.reply({ embeds: [memeEmbed] });
} catch {
await interaction.reply('There was an error getting the meme');
}
}
});

async function getMeme(): Promise<Meme> {
const meme: Meme = await axios('https://meme-api.com/gimme').then(function (
response: AxiosResponse
) {
return response.data;
});
return meme;
return axios('https://meme-api.com/gimme').then(
(response: AxiosResponse) => response.data
);
}

function generateMemeEmbed(meme: Meme): EmbedBuilder {
Expand Down

0 comments on commit a846d97

Please sign in to comment.