Skip to content

Commit

Permalink
goober.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stef-00012 committed Jan 4, 2025
1 parent e903c11 commit a28d83a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,11 @@ export default [
type: ApplicationCommandOptionType.Subcommand,
description: "Get a joke of Gary",
},
{
name: "goober",
type: ApplicationCommandOptionType.Subcommand,
description: "Get an image of Goober",
},
],
},
{
Expand Down
44 changes: 44 additions & 0 deletions src/commands/slash/gary/goober.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type { Client } from "../../../structures/DiscordClient";
import type { ChatInputCommandInteraction } from "discord.js";
import { EmbedBuilder } from "discord.js";
import axios from "axios";

export default async function (
client: Client,
int: ChatInputCommandInteraction,
) {
await int.deferReply();

try {
const res = await axios.get("https://garybot.dev/api/goober");

const url: string = res.data.url;

const embed = new EmbedBuilder().setTitle("Goober").setImage(url);

await int.editReply({
embeds: [embed],
});
} catch (e) {
if (e?.response?.status === 429)
return await int.editReply({
content: "You are being ratelimited",
});

if (e?.response?.status === 500)
return await int.editReply({
content: "The Gary API is currently having issues",
});

if (e?.response?.status)
return await int.editReply({
content: `The Gary API request failed with status ${e.response.status} (${e.response.statusText})`,
});

console.log(e);

await int.editReply({
content: "Something went wrong...",
});
}
}

0 comments on commit a28d83a

Please sign in to comment.