-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e903c11
commit a28d83a
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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...", | ||
}); | ||
} | ||
} |