Merge branch 'dev' into 'main'
Dev See merge request illegitimate/illegitimate-bot!221
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discord-player/extractor": "^4.4.6",
|
"@discord-player/extractor": "^4.4.6",
|
||||||
"@evan/opus": "^1.0.2",
|
"@evan/opus": "^1.0.2",
|
||||||
|
"anilist": "^0.12.3",
|
||||||
"axios": "^1.6.7",
|
"axios": "^1.6.7",
|
||||||
"chalk": "^4.1.2",
|
"chalk": "^4.1.2",
|
||||||
"cron": "^3.1.6",
|
"cron": "^3.1.6",
|
||||||
@@ -49,5 +50,5 @@
|
|||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@4.0.2"
|
"packageManager": "yarn@4.1.0"
|
||||||
}
|
}
|
||||||
|
|||||||
49
src/commands/anime.ts
Normal file
49
src/commands/anime.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import { PermissionFlagsBits, SlashCommandBuilder } from "discord.js"
|
||||||
|
import { Command } from "interfaces"
|
||||||
|
import search from "./anime/search"
|
||||||
|
import { devMessage, embedColor } from "config/options"
|
||||||
|
|
||||||
|
export = {
|
||||||
|
name: "anime",
|
||||||
|
description: "Anime subcommands",
|
||||||
|
public: true,
|
||||||
|
dev: true,
|
||||||
|
subcommands: true,
|
||||||
|
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName("anime")
|
||||||
|
.setDescription("Anime subcommands")
|
||||||
|
.addSubcommand(subcommand =>
|
||||||
|
subcommand
|
||||||
|
.setName("search")
|
||||||
|
.setDescription("Search for an anime")
|
||||||
|
.addStringOption(option =>
|
||||||
|
option
|
||||||
|
.setName("query")
|
||||||
|
.setDescription("The anime to search for")
|
||||||
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||||
|
.setDMPermission(false),
|
||||||
|
|
||||||
|
async execute(interaction) {
|
||||||
|
const subcommand = interaction.options.getSubcommand()
|
||||||
|
|
||||||
|
if (subcommand === "search") {
|
||||||
|
search(interaction)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await interaction.reply({
|
||||||
|
embeds: [{
|
||||||
|
description: "This command is currently under development",
|
||||||
|
color: embedColor,
|
||||||
|
footer: {
|
||||||
|
text: interaction.guild!.name + " | " + devMessage,
|
||||||
|
icon_url: interaction.guild!.iconURL() || undefined
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} as Command
|
||||||
68
src/commands/anime/search.ts
Normal file
68
src/commands/anime/search.ts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import { ChatInputCommandInteraction } from "discord.js"
|
||||||
|
import { anilist } from "anilist"
|
||||||
|
import { embedColor } from "config/options"
|
||||||
|
import { capitalizeFirstLetter } from "utils/functions/funcs"
|
||||||
|
|
||||||
|
export default async function search(interaction: ChatInputCommandInteraction) {
|
||||||
|
await interaction.deferReply()
|
||||||
|
const query = interaction.options.getString("query")!
|
||||||
|
|
||||||
|
const data = anilist.query.media()
|
||||||
|
.arguments({ search: query, type: "ANIME" })
|
||||||
|
.withTitles("english", "romaji")
|
||||||
|
.withDescription()
|
||||||
|
.withCoverImage("medium")
|
||||||
|
.withDuration()
|
||||||
|
.withGenres()
|
||||||
|
.withAverageScore()
|
||||||
|
.withMeanScore()
|
||||||
|
.withEpisodes()
|
||||||
|
.withId()
|
||||||
|
.withStartDate("year", "month", "day")
|
||||||
|
.withEndDate("year", "month", "day")
|
||||||
|
.withSeason()
|
||||||
|
const anime = await data.fetch()
|
||||||
|
|
||||||
|
if (!anime) {
|
||||||
|
await interaction.editReply({
|
||||||
|
embeds: [{
|
||||||
|
description: "No anime found",
|
||||||
|
color: embedColor
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const romaji = anime.title?.romaji || "Romaji not available"
|
||||||
|
const english = anime.title?.english || "English not available"
|
||||||
|
const animeDescription = anime.description?.replaceAll("<br>", "\n").slice(0, 256) + "..." || "No description available"
|
||||||
|
const animeEpisodesRaw = anime.episodes + " episodes" + " | " + anime.duration + " minute episodes"
|
||||||
|
const animeEpisodes = anime.episodes ? animeEpisodesRaw : "No episodes available"
|
||||||
|
const animeStartDate = [anime.startDate?.day || "??", anime.startDate?.month || "??", anime.startDate?.year || "????"].join(".")
|
||||||
|
const animeEndDate = [anime.endDate?.day || "??", anime.endDate?.month || "??", anime.endDate?.year || "????"].join(".")
|
||||||
|
const animeSeasonRaw = capitalizeFirstLetter(anime.season ?? "null") + " " + anime.startDate?.year
|
||||||
|
const animeSeason = anime.season ? animeSeasonRaw : "No season available"
|
||||||
|
|
||||||
|
await interaction.editReply({
|
||||||
|
embeds: [{
|
||||||
|
title: romaji + " | " + english,
|
||||||
|
description: `
|
||||||
|
**Description:** ${animeDescription}
|
||||||
|
|
||||||
|
**Genres:** ${anime.genres.join(", ")}
|
||||||
|
**Avg. Score:** ${anime.averageScore || "No score available"}
|
||||||
|
**Mean Score:** ${anime.meanScore || "No score available"}
|
||||||
|
**Episodes:** ${animeEpisodes || "No episodes available"}
|
||||||
|
**Season:** ${animeSeason}
|
||||||
|
**Start Date:** ${animeStartDate}
|
||||||
|
**End Date:** ${animeEndDate}
|
||||||
|
`,
|
||||||
|
color: embedColor,
|
||||||
|
thumbnail: {
|
||||||
|
url: anime.coverImage?.medium || ""
|
||||||
|
},
|
||||||
|
footer: {
|
||||||
|
text: "ID: " + anime.id
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
}
|
||||||
3
src/utils/functions/funcs.ts
Normal file
3
src/utils/functions/funcs.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export function capitalizeFirstLetter(str: string): string {
|
||||||
|
return str[0].toUpperCase() + str.slice(1).toLowerCase()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user