Skip to content

Commit

Permalink
feat: package (aur + npm) command
Browse files Browse the repository at this point in the history
  • Loading branch information
espimarisa committed Aug 27, 2024
1 parent b10f7e4 commit 42005b0
Show file tree
Hide file tree
Showing 14 changed files with 455 additions and 57 deletions.
Binary file modified bun.lockb
Binary file not shown.
21 changes: 20 additions & 1 deletion locales/en-US/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"COMMAND_GITHUB_ISSUES": "Watchers",
"COMMAND_GITHUB_FORKS": "Forks",
"COMMAND_GITHUB_TOPICS": "Topics",
"COMMAND_GITHUB_REPOS": "Topics",
"COMMAND_GITHUB_TOPICS_one": "Topics",
"COMMAND_GITHUB_REPOS": "Repositories",
"COMMAND_GITHUB_GISTS": "Gists",
"COMMAND_GITHUB_COMPANY": "Company",

Expand All @@ -91,6 +92,7 @@
"COMMAND_IPINFO_ISP": "ISP",
"COMMAND_IPINFO_ABUSESTATS": "Abuse Stats",
"COMMAND_IPINFO_ABUSESTATS_DATA": "{{ reports }} reports; {{ confidence }}% confidence",
"COMMAND_IPINFO_ABUSESTATS_DATA_one": "{{ reports }} report; {{ confidence }}% confidence",
"COMMAND_IPINFO_TOR": "TOR",
"COMMAND_IPINFO_INFOFOR": "Information for {{ ip }}",

Expand All @@ -100,6 +102,23 @@
"COMMAND_PACKAGE_OPTION_0_DESCRIPTION": "Gets information about a package from the Arch User Repository (AUR).",
"COMMAND_PACKAGE_SUBCOMMAND_0_OPTION_0_NAME": "package",
"COMMAND_PACKAGE_SUBCOMMAND_0_OPTION_0_DESCRIPTION": "The package to return information about.",
"COMMAND_PACKAGE_OPTION_1_NAME": "npm",
"COMMAND_PACKAGE_OPTION_1_DESCRIPTION": "Gets information about a npm package.",
"COMMAND_PACKAGE_SUBCOMMAND_1_OPTION_0_NAME": "package",
"COMMAND_PACKAGE_SUBCOMMAND_1_OPTION_0_DESCRIPTION": "The npm package to return information about.",
"COMMAND_PACKAGE_SUBCOMMAND_1_OPTION_1_NAME": "version",
"COMMAND_PACKAGE_SUBCOMMAND_1_OPTION_1_DESCRIPTION": "A specific version to return information about. Defaults to the latest release.",
"COMMAND_PACKAGE_NOVERSION": "No version coorelating with that package was found.",

"COMMAND_PACKAGE_NOTFOUND": "No package with that name was found.",
"COMMAND_PACKAGE_CONFLICTS": "Conflicts",
"COMMAND_PACKAGE_CONFLICT_one": "Conflict",
"COMMAND_PACKAGE_DEPENDENCIES": "Dependencies",
"COMMAND_PACKAGE_DEPENDENCIES_one": "Dependency",
"COMMAND_PACKAGE_OUTOFDATE": "Outdated",
"COMMAND_PACKAGE_PROVIDES": "Provides",
"COMMAND_PACKAGE_MAINTAINER": "Maintainer",
"COMMAND_PACKAGE_MAINTAINER_other": "Maintainers",

"COMMAND_PING_NAME": "Ping",
"COMMAND_PING_DESCRIPTION": "Checks the current status and latency.",
Expand Down
8 changes: 8 additions & 0 deletions locales/en-US/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"2FA": "2FA",
"ANNOUNCEMENT": "Announcement",
"ARCHIVED": "Archived",
"AUTHOR": "Author",
"BITRATE": "Bitrate",
"BITRATE_DATA": "{{bitrate}} kbps",
"CATEGORY": "Category",
Expand All @@ -14,6 +15,7 @@
"DISABLED": "Disabled",
"DISPLAY_NAME": "Display Name",
"DOWNVOTES": "Downvotes",
"DOWNVOTES_one": "Downvote",
"EMAIL": "Email",
"EMOJIS": "Emojis",
"FOLLOWERS": "Followers",
Expand All @@ -23,6 +25,8 @@
"HOMEPAGE": "Homepage",
"ID": "ID",
"JOINED_ON": "Joined On",
"KEYWORDS": "Keywords",
"KEYWORDS_one": "keyword",
"LANGUAGE": "Language",
"LICENSE": "License",
"LOCATION": "Location",
Expand All @@ -31,6 +35,7 @@
"MEMBERS": "Members",
"MEMBERS_WITH_ROLE": "Members with Role",
"NICKNAME": "Nickname",
"NOTICE": "Notice",
"NSFW": "NSFW",
"OWNER": "Owner",
"PARENT": "Parent",
Expand All @@ -40,15 +45,18 @@
"ROLES": "Roles",
"STAGE": "Stage",
"STICKERS": "Stickers",
"SUBMITTED_ON": "Submitted On",
"TEXT": "Text",
"TIMEZONE": "Timezone",
"THREAD": "Thread",
"THREADS": "Threads",
"UPDATED_ON": "Updated On",
"UPVOTES": "Upvotes",
"UPVOTES_one": "Upvote",
"USERNAME": "Username",
"VANITY_URL": "Vanity URL",
"VERIFIED": "Verified",
"VERSION": "Version",
"VOICE": "VOICE",
"WEBSITE": "Website",
"XTWITTER": "X/Twitter"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@discordjs/rest": "^2.3.0",
"@sentry/bun": "^8.26.0",
"date-fns": "^3.6.0",
"discord-api-types": "^0.37.97",
"discord-api-types": "^0.37.98",
"discord.js": "^14.15.3",
"i18next": "^23.14.0",
"i18next-fs-backend": "^2.3.2",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class AvatarCommand extends HibikiCommand {
fields: fields,
color: member.user.accentColor ?? HibikiColors.GENERAL,
thumbnail: {
url: serverInfo ? member.displayAvatarURL({ size: 2048 }) : member.user.displayAvatarURL({ size: 1024 }),
url: serverInfo ? member.displayAvatarURL({ size: 2048 }) : member.user.displayAvatarURL({ size: 2048 }),
},
image: {
url: member.user.bannerURL({ size: 2048 }) ?? "",
Expand Down
34 changes: 14 additions & 20 deletions src/commands/avatar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { type APIOption, HibikiCommand, type HibikiCommandOptions } from "$classes/Command.ts";
import { HibikiColors } from "$utils/constants.ts";
import { sendErrorReply } from "$utils/error.ts";
import { t } from "$utils/i18n.ts";
import { ApplicationCommandOptionType, type ChatInputCommandInteraction } from "discord.js";

Expand All @@ -24,27 +25,20 @@ export class AvatarCommand extends HibikiCommand {
const idToFetch = memberToFetch?.id ?? interaction.user.id;
const serverAvatar = interaction.options.getBoolean((this.options as APIOption[])[1]!.name);

// Guild error handler
if (!interaction.guild) {
await sendErrorReply("errors:ERROR_ACCOUNT", interaction);
return;
}

// Fetches the member
const member =
interaction.guild!.members.cache.find((m) => m.id === idToFetch) ||
(await interaction.guild!.members.fetch(idToFetch));
interaction.guild.members.cache.find((m) => m.id === idToFetch) ||
(await interaction.guild.members.fetch(idToFetch));

// Error handler
// Member error handler
if (!member) {
await interaction.followUp({
embeds: [
{
title: t("errors:ERROR", { lng: interaction.locale }),
description: t("errors:ERROR_ACCOUNT", { lng: interaction.locale }),
color: HibikiColors.ERROR,
footer: {
text: t("errors:ERROR_FOUND_A_BUG", { lng: interaction.locale }),
icon_url: interaction.client.user.displayAvatarURL(),
},
},
],
});

await sendErrorReply("errors:ERROR_ACCOUNT", interaction);
return;
}

Expand All @@ -58,12 +52,12 @@ export class AvatarCommand extends HibikiCommand {
lng: interaction.locale,
}),
icon_url: serverAvatar
? member.displayAvatarURL({ size: 1024 })
: member.user.displayAvatarURL({ size: 1024 }),
? member.displayAvatarURL({ size: 2048 })
: member.user.displayAvatarURL({ size: 2048 }),
},
color: member.user.accentColor ?? HibikiColors.GENERAL,
image: {
url: serverAvatar ? member.displayAvatarURL({ size: 1024 }) : member.user.displayAvatarURL({ size: 1024 }),
url: serverAvatar ? member.displayAvatarURL({ size: 2048 }) : member.user.displayAvatarURL({ size: 2048 }),
},
},
],
Expand Down
12 changes: 9 additions & 3 deletions src/commands/banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ export class AvatarCommand extends HibikiCommand {
const memberToFetch = await interaction.options.getUser((this.options as APIOption[])[0]!.name)?.fetch();
const idToFetch = memberToFetch?.id ?? interaction.user.id;

// Guild error handler
if (!interaction.guild) {
await sendErrorReply("errors:ERROR_SERVER", interaction);
return;
}

// Fetches the member
const member =
interaction.guild!.members.cache.find((m) => m.id === idToFetch) ||
(await interaction.guild!.members.fetch(idToFetch));
interaction.guild.members.cache.find((m) => m.id === idToFetch) ||
(await interaction.guild.members.fetch(idToFetch));

// Error handler
// Member error handler
if (!member?.user?.bannerURL()) {
await sendErrorReply("errors:ERROR_NO_BANNER", interaction);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class GithubCommand extends HibikiCommand {
// Topics
if (body.topics) {
fields.push({
name: t("commands:COMMAND_GITHUB_TOPICS", { lng: interaction.locale }),
name: t("commands:COMMAND_GITHUB_TOPICS", { lng: interaction.locale, count: body.topics.length }),
value: body.topics.map((m: Record<string, string>) => `\`${m}\``).join(", "),
inline: false,
});
Expand Down
Loading

0 comments on commit 42005b0

Please sign in to comment.