Skip to content

Commit

Permalink
Merge pull request #9 from AnonDev-org/dev
Browse files Browse the repository at this point in the history
v1.0.5
  • Loading branch information
anondev-sudo authored Sep 21, 2021
2 parents 614c772 + c285ce3 commit fa9f4df
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 3 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ name: Mark stale issues and pull requests

on:
schedule:
- cron: '16 5 * * *'
- cron: "16 5 * * *"

jobs:
stale:

runs-on: ubuntu-latest
permissions:
issues: write
Expand All @@ -28,4 +27,4 @@ jobs:
close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.'
days-before-stale: 30
days-before-close: 5
days-before-pr-close: -1
days-before-pr-close: -1
2 changes: 2 additions & 0 deletions commands/images/animal.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = class extends Command {
super(...args, {
name: "animal",
description: "Get random animal",
category: "images",
args: [
{
name: "animal",
Expand All @@ -29,6 +30,7 @@ module.exports = class extends Command {
{ name: "Raccoon", value: "raccoon" },
{ name: "Kangaroo", value: "kangaroo" },
{ name: "Shiba", value: "shiba" },
{ name: "Lizard", value: "lizard" },
],
},
],
Expand Down
1 change: 1 addition & 0 deletions commands/info/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module.exports = class extends Command {
cmd.aliases && cmd.aliases.length > 1 ? `(${cmd.aliases})` : ""
}** - ${cmd.description}\n`;
});
if (!text && text == "") return;
embed.addField(
`__**${client.helpers.capitalize(category)}**__`,
`${text}`
Expand Down
81 changes: 81 additions & 0 deletions commands/others/animalfact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
const {
Command,
MessageActionRow,
MessageButton,
ArgumentType,
} = require("gcommands");
const Discord = require("discord.js");

module.exports = class extends Command {
constructor(...args) {
super(...args, {
name: "animalfact",
description: "Get random animal fact",
category: "others",
args: [
{
name: "animal",
type: ArgumentType.STRING,
description: "Animal to get fact of",
category: "others",
required: true,
choices: [
{ name: "Cat", value: "cat" },
{ name: "Dog", value: "dog" },
{ name: "Fox", value: "fox" },
{ name: "Panda", value: "panda" },
{ name: "Red Panda", value: "red_panda" },
{ name: "Bird", value: "bird" },
{ name: "Koala", value: "koala" },
{ name: "Raccoon", value: "raccoon" },
{ name: "Kangaroo", value: "kangaroo" },
],
},
],
});
}
async run({
client,
interaction,
respond,
guild,
edit,
member,
author,
args,
objectArgs,
message,
}) {
const resp = await client
.request(`/api/others/fact/${objectArgs.animal}`, "GET")
.catch((err) => {
console.log("Error while fetching API endpoint", err);
return respond({
content: `:x: Error while fetching API endpoint \`${err.message}\``,
ephemeral: true,
});
});
let data = await resp.json();
if (!resp.ok) {
console.log(`API returned error ${resp.status} ${resp.statusText}`, data);
return respond({
content: `:x: API returned error \`${resp.status} ${
resp.statusText
}\`\n\n> \`${JSON.stringify(data)}\``,
ephemeral: true,
});
}

const embed = new Discord.MessageEmbed()
.setTitle(`${client.helpers.capitalize(objectArgs.animal)} Fact`)
.setDescription(data.fact)
.setColor("RANDOM")
.setFooter(client.user.username, client.user.avatarURL())
.setTimestamp();

respond({
embeds: [embed],
ephemeral: false,
});
}
};

0 comments on commit fa9f4df

Please sign in to comment.