mirror of
https://github.com/SrIzan10/vinci.git
synced 2026-06-06 01:07:00 +00:00
feat: new command cat
This commit is contained in:
99
commands/fun/animal.ts
Normal file
99
commands/fun/animal.ts
Normal file
@@ -0,0 +1,99 @@
|
||||
import { commandModule, CommandType } from '@sern/handler'
|
||||
import axios from "axios";
|
||||
import { ActionRowBuilder, ApplicationCommandOptionType, ButtonBuilder, ButtonStyle, ComponentType, EmbedBuilder } from "discord.js";
|
||||
import { publish } from "../../src/plugins/publish.js";
|
||||
/*
|
||||
import { publish } from "../../src/plugins/publish.js";
|
||||
import { ownerOnly } from "../../src/plugins/ownerOnly.js"
|
||||
*/
|
||||
|
||||
export default commandModule({
|
||||
name: 'animal',
|
||||
type: CommandType.Slash,
|
||||
plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] })],
|
||||
description: 'Enseña un animal',
|
||||
//alias : [],
|
||||
options: [
|
||||
{
|
||||
name: 'gato',
|
||||
description: 'Enseña un gato',
|
||||
type: ApplicationCommandOptionType.Subcommand
|
||||
},
|
||||
{
|
||||
name: 'capybara',
|
||||
description: 'Enseña un capybara',
|
||||
type: ApplicationCommandOptionType.Subcommand
|
||||
},
|
||||
],
|
||||
execute: async (ctx, options) => {
|
||||
switch (options[1].getSubcommand()) {
|
||||
case 'gato': {
|
||||
const request = await axios.get(`https://api.thecatapi.com/v1/images/search?api_key=${process.env.CATAPI}`).then(res => res.data)
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({name: ctx.user.username, iconURL: ctx.user.displayAvatarURL()})
|
||||
.setColor("Random")
|
||||
.setImage(request[0].url)
|
||||
.setFooter({text: `ID: ${request[0].id}`})
|
||||
.setTitle('Gato')
|
||||
const row = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("cat-upvote")
|
||||
.setEmoji("⬆️")
|
||||
.setStyle(ButtonStyle.Success),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("cat-downvote")
|
||||
.setEmoji("⬇️")
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
)
|
||||
const rowdisabled = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("cat-upvote")
|
||||
.setEmoji("⬆️")
|
||||
.setStyle(ButtonStyle.Success)
|
||||
.setDisabled(true),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("cat-downvote")
|
||||
.setEmoji("⬇️")
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
.setDisabled(true),
|
||||
)
|
||||
const message = await ctx.reply({embeds: [embed], components: [row]})
|
||||
const collector = message.createMessageComponentCollector({time: 30000, componentType: ComponentType.Button})
|
||||
collector.on('collect', async (i) => {
|
||||
await i.deferReply({ephemeral: true})
|
||||
if (i.customId === "cat-upvote") {
|
||||
await axios.post(`https://api.thecatapi.com/v1/votes?api_key=${process.env.CATAPI}`, {
|
||||
"image_id": request[0].id,
|
||||
"sub_id": i.user.id,
|
||||
"value": 1
|
||||
})
|
||||
i.editReply({content: "Has votado positivamente al gato con ID " + "`" + request[0].id + "`"})
|
||||
}
|
||||
if (i.customId === "cat-downvote") {
|
||||
await axios.post(`https://api.thecatapi.com/v1/votes?api_key=${process.env.CATAPI}`, {
|
||||
"image_id": request[0].id,
|
||||
"sub_id": i.user.id,
|
||||
"value": -1
|
||||
})
|
||||
i.editReply({content: "Has votado negativamente al gato con ID " + "`" + request[0].id + "`"})
|
||||
}
|
||||
})
|
||||
collector.on('end', async (i) => {
|
||||
await message.edit({components: [rowdisabled]})
|
||||
})
|
||||
}
|
||||
case 'capybara': {
|
||||
const request = await axios('https://api.capybara-api.xyz/v1/image/random').then(res => res.data)
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({name: ctx.user.username, iconURL: ctx.user.displayAvatarURL()})
|
||||
.setTitle('Capybara')
|
||||
.setColor('Random')
|
||||
.setImage(request.image_urls.medium)
|
||||
.setFooter({text: `ID: ${request.id}`})
|
||||
await ctx.interaction.reply({embeds: [embed], ephemeral: true})
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -1,75 +0,0 @@
|
||||
import { commandModule, CommandType } from '@sern/handler'
|
||||
import { Context } from "@sern/handler";
|
||||
import axios from "axios";
|
||||
import { ActionRowBuilder, APIMessageActionRowComponent, ButtonBuilder, ButtonStyle, ComponentType, EmbedBuilder } from "discord.js";
|
||||
import { publish } from "../../src/plugins/publish.js";
|
||||
/*
|
||||
import { publish } from "../../src/plugins/publish.js";
|
||||
import { ownerOnly } from "../../src/plugins/ownerOnly.js"
|
||||
*/
|
||||
|
||||
export default commandModule({
|
||||
name: 'gato',
|
||||
type: CommandType.Slash,
|
||||
plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] })],
|
||||
description: 'QUIEN HA DICHO GATOS?!?!?!',
|
||||
//alias : [],
|
||||
options: [],
|
||||
execute: async (ctx: Context, options) => {
|
||||
const request = await axios.get(`https://api.thecatapi.com/v1/images/search?api_key=${process.env.CATAPI}`).then(res => res.data)
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({name: ctx.user.username, iconURL: ctx.user.displayAvatarURL()})
|
||||
.setColor("Random")
|
||||
.setImage(request[0].url)
|
||||
.setFooter({text: `ID: ${request[0].id}`})
|
||||
.setTitle('Gato')
|
||||
const row = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("cat-upvote")
|
||||
.setEmoji("⬆️")
|
||||
.setStyle(ButtonStyle.Success),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("cat-downvote")
|
||||
.setEmoji("⬇️")
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
)
|
||||
const rowdisabled = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("cat-upvote")
|
||||
.setEmoji("⬆️")
|
||||
.setStyle(ButtonStyle.Success)
|
||||
.setDisabled(true),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("cat-downvote")
|
||||
.setEmoji("⬇️")
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
.setDisabled(true),
|
||||
)
|
||||
const message = await ctx.reply({embeds: [embed], components: [row]})
|
||||
const collector = message.createMessageComponentCollector({time: 30000, componentType: ComponentType.Button})
|
||||
collector.on('collect', async (i) => {
|
||||
await i.deferReply({ephemeral: true})
|
||||
if (i.customId === "cat-upvote") {
|
||||
await axios.post(`https://api.thecatapi.com/v1/votes?api_key=${process.env.CATAPI}`, {
|
||||
"image_id": request[0].id,
|
||||
"sub_id": i.user.id,
|
||||
"value": 1
|
||||
})
|
||||
i.editReply({content: "Has votado positivamente al gato con ID " + "`" + request[0].id + "`"})
|
||||
}
|
||||
if (i.customId === "cat-downvote") {
|
||||
await axios.post(`https://api.thecatapi.com/v1/votes?api_key=${process.env.CATAPI}`, {
|
||||
"image_id": request[0].id,
|
||||
"sub_id": i.user.id,
|
||||
"value": -1
|
||||
})
|
||||
i.editReply({content: "Has votado negativamente al gato con ID " + "`" + request[0].id + "`"})
|
||||
}
|
||||
})
|
||||
collector.on('end', async (i) => {
|
||||
await message.edit({components: [rowdisabled]})
|
||||
})
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user