Skip to content

Commit 2c22718

Browse files
committed
Feat: Animals Commands Update pt.2
1 parent 8118e48 commit 2c22718

File tree

18 files changed

+815
-186
lines changed

18 files changed

+815
-186
lines changed

src/buttons/animals/duck.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const Button = require("../Button.js");
2+
const axios = require("axios");
3+
const {
4+
MessageEmbed,
5+
MessageActionRow,
6+
MessageButton
7+
} = require("discord.js");
8+
9+
module.exports = class DuckButton extends Button {
10+
constructor(client) {
11+
super(client, {
12+
name: "duck",
13+
});
14+
}
15+
16+
async run(interaction) {
17+
const res = await axios
18+
.get('https://random-d.uk/api/v2/random')
19+
.then((res) => res.data)
20+
.catch((err) => {
21+
interaction.message.client.logger.error(err.stack);
22+
return this.sendErrorMessage(interaction.message, 1, "Please try again in a few seconds", "The API is down");
23+
});
24+
const img = res.url;
25+
const embed = new MessageEmbed()
26+
.setTitle('🦆 Quack! 🦆')
27+
.setImage(img)
28+
.setFooter({
29+
text: interaction.user.username,
30+
iconURL: interaction.user.displayAvatarURL({
31+
dynamic: true
32+
}),
33+
})
34+
.setTimestamp()
35+
.setColor(
36+
interaction.guild ? interaction.guild.me.displayHexColor : "#7289DA"
37+
);
38+
39+
const row = new MessageActionRow().addComponents(
40+
new MessageButton()
41+
.setLabel("Another duck")
42+
.setStyle("PRIMARY")
43+
.setEmoji("🦆")
44+
.setCustomId("duck")
45+
);
46+
47+
interaction.update({
48+
embeds: [embed],
49+
components: [row]
50+
});
51+
}
52+
};

src/buttons/animals/fox-fact.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const Button = require("../Button.js");
2+
const axios = require("axios");
3+
const {
4+
MessageEmbed,
5+
MessageActionRow,
6+
MessageButton
7+
} = require("discord.js");
8+
9+
module.exports = class FoxFactButton extends Button {
10+
constructor(client) {
11+
super(client, {
12+
name: "fox-fact",
13+
});
14+
}
15+
16+
async run(interaction) {
17+
const res = await axios
18+
.get('https://api.any-bot.tech/api/v1/fox')
19+
.then((res) => res.data)
20+
.catch((err) => {
21+
interaction.message.client.logger.error(err.stack);
22+
return this.sendErrorMessage(interaction.message, 1, "Please try again in a few seconds", "The API is down");
23+
});
24+
const fact = res.fact;
25+
const embed = new MessageEmbed()
26+
.setTitle('🦊 Auuu! 🦊 ')
27+
.setDescription(fact)
28+
.setFooter({
29+
text: interaction.user.username,
30+
iconURL: interaction.user.displayAvatarURL({
31+
dynamic: true
32+
}),
33+
})
34+
.setTimestamp()
35+
.setColor(
36+
interaction.guild ? interaction.guild.me.displayHexColor : "#7289DA"
37+
);
38+
39+
const row = new MessageActionRow().addComponents(
40+
new MessageButton()
41+
.setLabel("Another fox fact")
42+
.setStyle("PRIMARY")
43+
.setEmoji("🦊")
44+
.setCustomId("fox-fact")
45+
);
46+
47+
interaction.update({
48+
embeds: [embed],
49+
components: [row]
50+
});
51+
}
52+
};

src/buttons/animals/fox.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const Button = require("../Button.js");
2+
const axios = require("axios");
3+
const {
4+
MessageEmbed,
5+
MessageActionRow,
6+
MessageButton
7+
} = require("discord.js");
8+
9+
module.exports = class FoxButton extends Button {
10+
constructor(client) {
11+
super(client, {
12+
name: "fox",
13+
});
14+
}
15+
16+
async run(interaction) {
17+
const res = await axios
18+
.get('https://api.any-bot.tech/api/v1/fox')
19+
.then((res) => res.data)
20+
.catch((err) => {
21+
interaction.message.client.logger.error(err.stack);
22+
return this.sendErrorMessage(interaction.message, 1, "Please try again in a few seconds", "The API is down");
23+
});
24+
const img = res.image;
25+
const embed = new MessageEmbed()
26+
.setTitle('🦊 Auuu! 🦊 ')
27+
.setImage(img)
28+
.setFooter({
29+
text: interaction.user.username,
30+
iconURL: interaction.user.displayAvatarURL({
31+
dynamic: true
32+
}),
33+
})
34+
.setTimestamp()
35+
.setColor(
36+
interaction.guild ? interaction.guild.me.displayHexColor : "#7289DA"
37+
);
38+
39+
const row = new MessageActionRow().addComponents(
40+
new MessageButton()
41+
.setLabel("Another fox")
42+
.setStyle("PRIMARY")
43+
.setEmoji("🦊")
44+
.setCustomId("fox")
45+
);
46+
47+
interaction.update({
48+
embeds: [embed],
49+
components: [row]
50+
});
51+
}
52+
};

src/buttons/animals/koala-fact.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const Button = require("../Button.js");
2+
const axios = require("axios");
3+
const {
4+
MessageEmbed,
5+
MessageActionRow,
6+
MessageButton
7+
} = require("discord.js");
8+
9+
module.exports = class KoalaFactButton extends Button {
10+
constructor(client) {
11+
super(client, {
12+
name: "koala-fact",
13+
});
14+
}
15+
16+
async run(interaction) {
17+
const res = await axios
18+
.get('https://api.any-bot.tech/api/v1/koala')
19+
.then((res) => res.data)
20+
.catch((err) => {
21+
interaction.message.client.logger.error(err.stack);
22+
return this.sendErrorMessage(interaction.message, 1, "Please try again in a few seconds", "The API is down");
23+
});
24+
const fact = res.fact;
25+
const embed = new MessageEmbed()
26+
.setTitle('🐨 Oooo! 🐨')
27+
.setDescription(fact)
28+
.setFooter({
29+
text: interaction.user.username,
30+
iconURL: interaction.user.displayAvatarURL({
31+
dynamic: true
32+
}),
33+
})
34+
.setTimestamp()
35+
.setColor(
36+
interaction.guild ? interaction.guild.me.displayHexColor : "#7289DA"
37+
);
38+
39+
const row = new MessageActionRow()
40+
.addComponents(
41+
new MessageButton()
42+
.setLabel("Another koala fact")
43+
.setStyle("PRIMARY")
44+
.setEmoji("🐨")
45+
.setCustomId("koala-fact")
46+
)
47+
48+
interaction.update({
49+
embeds: [embed],
50+
components: [row]
51+
});
52+
}
53+
};

src/buttons/animals/koala.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const Button = require("../Button.js");
2+
const axios = require("axios");
3+
const {
4+
MessageEmbed,
5+
MessageActionRow,
6+
MessageButton
7+
} = require("discord.js");
8+
9+
module.exports = class KoalaButton extends Button {
10+
constructor(client) {
11+
super(client, {
12+
name: "koala",
13+
});
14+
}
15+
16+
async run(interaction) {
17+
const res = await axios
18+
.get('https://api.any-bot.tech/api/v1/koala')
19+
.then((res) => res.data)
20+
.catch((err) => {
21+
interaction.message.client.logger.error(err.stack);
22+
return this.sendErrorMessage(interaction.message, 1, "Please try again in a few seconds", "The API is down");
23+
});
24+
const img = res.image;
25+
const embed = new MessageEmbed()
26+
.setTitle('🐨 Oooo! 🐨')
27+
.setImage(img)
28+
.setFooter({
29+
text: interaction.user.username,
30+
iconURL: interaction.user.displayAvatarURL({
31+
dynamic: true
32+
}),
33+
})
34+
.setTimestamp()
35+
.setColor(
36+
interaction.guild ? interaction.guild.me.displayHexColor : "#7289DA"
37+
);
38+
39+
const row = new MessageActionRow()
40+
.addComponents(
41+
new MessageButton()
42+
.setLabel("Another koala")
43+
.setStyle("PRIMARY")
44+
.setEmoji("🐨")
45+
.setCustomId("koala")
46+
)
47+
48+
interaction.update({
49+
embeds: [embed],
50+
components: [row]
51+
});
52+
}
53+
};

src/buttons/animals/panda-fact.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const Button = require("../Button.js");
2+
const axios = require("axios");
3+
const {
4+
MessageEmbed,
5+
MessageActionRow,
6+
MessageButton
7+
} = require("discord.js");
8+
9+
module.exports = class PandaFactButton extends Button {
10+
constructor(client) {
11+
super(client, {
12+
name: "panda-fact",
13+
});
14+
}
15+
16+
async run(interaction) {
17+
const res = await axios
18+
.get('https://some-random-api.ml/animal/panda')
19+
.then((res) => res.data)
20+
.catch((err) => {
21+
interaction.message.client.logger.error(err.stack);
22+
return this.sendErrorMessage(interaction.message, 1, "Please try again in a few seconds", "The API is down");
23+
});
24+
const fact = res.fact;
25+
const embed = new MessageEmbed()
26+
.setTitle('🐼 Auuu! 🐼')
27+
.setDescription(fact)
28+
.setFooter({
29+
text: interaction.user.username,
30+
iconURL: interaction.user.displayAvatarURL({
31+
dynamic: true
32+
}),
33+
})
34+
.setTimestamp()
35+
.setColor(
36+
interaction.guild ? interaction.guild.me.displayHexColor : "#7289DA"
37+
);
38+
39+
const row = new MessageActionRow()
40+
.addComponents(
41+
new MessageButton()
42+
.setLabel("Another panda fact")
43+
.setStyle("PRIMARY")
44+
.setEmoji("🐼")
45+
.setCustomId("panda-fact")
46+
)
47+
48+
interaction.update({
49+
embeds: [embed],
50+
components: [row]
51+
});
52+
}
53+
};

src/buttons/animals/panda.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const Button = require("../Button.js");
2+
const axios = require("axios");
3+
const {
4+
MessageEmbed,
5+
MessageActionRow,
6+
MessageButton
7+
} = require("discord.js");
8+
9+
module.exports = class PandaButton extends Button {
10+
constructor(client) {
11+
super(client, {
12+
name: "panda",
13+
});
14+
}
15+
16+
async run(interaction) {
17+
const res = await axios
18+
.get('https://some-random-api.ml/animal/panda')
19+
.then((res) => res.data)
20+
.catch((err) => {
21+
interaction.message.client.logger.error(err.stack);
22+
return this.sendErrorMessage(interaction.message, 1, "Please try again in a few seconds", "The API is down");
23+
});
24+
const img = res.image;
25+
const embed = new MessageEmbed()
26+
.setTitle('🐼 Auuu! 🐼')
27+
.setImage(img)
28+
.setFooter({
29+
text: interaction.user.username,
30+
iconURL: interaction.user.displayAvatarURL({
31+
dynamic: true
32+
}),
33+
})
34+
.setTimestamp()
35+
.setColor(
36+
interaction.guild ? interaction.guild.me.displayHexColor : "#7289DA"
37+
);
38+
39+
const row = new MessageActionRow()
40+
.addComponents(
41+
new MessageButton()
42+
.setLabel("Another panda")
43+
.setStyle("PRIMARY")
44+
.setEmoji("🐼")
45+
.setCustomId("panda")
46+
)
47+
48+
interaction.update({
49+
embeds: [embed],
50+
components: [row]
51+
});
52+
}
53+
};

0 commit comments

Comments
 (0)