diff --git a/src/client/embed.ts b/src/client/embed.ts index b4bec6ce..593bf1fc 100644 --- a/src/client/embed.ts +++ b/src/client/embed.ts @@ -1,4 +1,5 @@ -import { Colors, EmbedBuilder, EmbedData, APIEmbed } from "discord.js"; +import { EmbedBuilder, EmbedData, APIEmbed } from "discord.js"; +import { colors } from "@utility/colors"; /** * Automatically sets embed color to blurple @@ -9,6 +10,6 @@ export class ExtendedEmbedBuilder extends EmbedBuilder { super(data); if (data) return; // do not override existing data - this.setColor(Colors.Blurple); + this.setColor(colors.blue); } } diff --git a/src/client/interaction.ts b/src/client/interaction.ts index b1a5dfd4..1a36e0da 100644 --- a/src/client/interaction.ts +++ b/src/client/interaction.ts @@ -32,7 +32,7 @@ declare module "discord.js" { * @param type what role to check for * @returns whether the user has permission or not */ - hasPermission(type: PermissionType): boolean; + hasPermission(type: PermissionType, warnUser?: boolean): boolean; /** * Sends an ephemeral message to an already-deferred interaction * @author Evorp @@ -43,7 +43,7 @@ declare module "discord.js" { } } -function hasPermission(type: PermissionType): boolean { +function hasPermission(type: PermissionType, warnUser = true): boolean { const hasManager = this.member.permissions.has(PermissionFlagsBits.Administrator); const hasModerator = this.member.permissions.has(PermissionFlagsBits.ManageMessages); const hasDev = this.client.tokens.developers.includes(this.member.id); @@ -68,7 +68,7 @@ function hasPermission(type: PermissionType): boolean { out = hasModerator; } - if (!out) this.reply({ embeds: [noPermission], ephemeral: true }); + if (!out && warnUser) this.reply({ embeds: [noPermission], ephemeral: true }); return out; } diff --git a/src/commands/bot/poll.ts b/src/commands/bot/poll.ts index 4f35877a..0060eb01 100644 --- a/src/commands/bot/poll.ts +++ b/src/commands/bot/poll.ts @@ -2,7 +2,7 @@ import { SlashCommandBuilder, EmbedField } from "discord.js"; import { SlashCommand } from "@interfaces/commands"; import { Poll } from "@helpers/poll"; import { addSeconds, parseDate } from "@utility/dates"; -import { ids, parseId } from "@utility/emojis"; +import { emojis, parseID } from "@utility/emojis"; import { ChatInputCommandInteraction, EmbedBuilder, Message } from "@client"; export const command: SlashCommand = { @@ -82,7 +82,7 @@ export const command: SlashCommand = { const filter = (m: Message) => m.author.id === interaction.member.user.id; const answersArr: string[] = []; - const yesnoEmojis = [parseId(ids.upvote), parseId(ids.downvote)]; + const yesnoEmojis = [parseID(emojis.upvote), parseID(emojis.downvote)]; const numberEmojis = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣"]; const fields = [{ name: "Answers", value: "None", inline: true }]; do { diff --git a/src/commands/faithful/media.ts b/src/commands/faithful/media.ts index fcb720c1..d870765f 100644 --- a/src/commands/faithful/media.ts +++ b/src/commands/faithful/media.ts @@ -3,22 +3,23 @@ import { SlashCommandBuilder } from "discord.js"; import { media } from "@utility/infoembed"; import { Message, EmbedBuilder, ChatInputCommandInteraction } from "@client"; import axios from "axios"; +import { colors } from "@utility/colors"; export const command: SlashCommand = { data: new SlashCommandBuilder() .setName("media") - .setDescription("Displays all sites for the given resource pack.") + .setDescription("Displays all listings for the given resource pack or generally useful links.") .addStringOption((option) => option .setName("name") - .setDescription("Name of the resource pack you want to see the sites of.") + .setDescription("Name of the resource pack you want to see the listings of.") .addChoices( { name: "Faithful 32x", value: "faithful_32x" }, { name: "Faithful 64x", value: "faithful_64x" }, { name: "Classic Faithful 32x Jappa", value: "classic_faithful_32x" }, { name: "Classic Faithful 32x Programmer Art", value: "classic_faithful_32x_progart" }, { name: "Classic Faithful 64x", value: "classic_faithful_64x" }, - { name: "All", value: "default" }, + { name: "All", value: "all" }, ), ), async execute(interaction: ChatInputCommandInteraction) { @@ -29,19 +30,20 @@ export const command: SlashCommand = { await axios.get(`${interaction.client.tokens.apiUrl}settings/images`) ).data; - if (key === "default") { + if (key === "all") { if (!interaction.hasPermission("manager")) return; interaction .reply({ content: "** **", fetchReply: true }) .then((message: Message) => message.delete()); return await interaction.channel.send({ - embeds: Object.entries(media).map(([key, mediaInfo]) => - new EmbedBuilder() - .setTitle(mediaInfo.title) - .setDescription(mediaInfo.description) - .setColor(mediaInfo.color) - .setThumbnail(images[key]), + embeds: Object.entries(media).map( + ([key, mediaInfo]) => + new EmbedBuilder() + .setTitle(mediaInfo.title) + .setDescription(mediaInfo.description) + .setColor(colors[key] ?? colors.brand) + .setThumbnail(images[key == "default" ? "plain" : key]), // "default" is already used ), }); } @@ -49,8 +51,8 @@ export const command: SlashCommand = { const embed = new EmbedBuilder() .setTitle(media[key].title) .setDescription(media[key].description) - .setColor(media[key].color) - .setThumbnail(images[key]); + .setColor(colors[key] ?? colors.brand) + .setThumbnail(images[key == "default" ? "plain" : key]); interaction .reply({ embeds: [embed], fetchReply: true }) diff --git a/src/helpers/utility/buttons.ts b/src/helpers/utility/buttons.ts index eec3b011..adbac2fe 100644 --- a/src/helpers/utility/buttons.ts +++ b/src/helpers/utility/buttons.ts @@ -1,35 +1,35 @@ import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js"; -import { ids } from "@utility/emojis"; +import { emojis } from "@utility/emojis"; export const compare = new ButtonBuilder() .setStyle(ButtonStyle.Primary) - .setEmoji(ids.compare) + .setEmoji(emojis.compare) .setCustomId("compare"); export const palette = new ButtonBuilder() .setStyle(ButtonStyle.Primary) - .setEmoji(ids.palette) + .setEmoji(emojis.palette) .setCustomId("palette"); export const magnify = new ButtonBuilder() .setStyle(ButtonStyle.Primary) - .setEmoji(ids.magnify) + .setEmoji(emojis.magnify) .setCustomId("magnify"); export const tile = new ButtonBuilder() .setStyle(ButtonStyle.Primary) - .setEmoji(ids.tile) + .setEmoji(emojis.tile) .setCustomId("tile"); export const template = new ButtonBuilder() .setStyle(ButtonStyle.Primary) - .setEmoji(ids.flip) + .setEmoji(emojis.flip) .setCustomId("comparisonTemplate"); export const deleteMessage = new ButtonBuilder() .setStyle(ButtonStyle.Danger) - .setEmoji(ids.delete) + .setEmoji(emojis.delete) .setCustomId("deleteMessage"); export const deleteInteraction = new ButtonBuilder() .setStyle(ButtonStyle.Danger) - .setEmoji(ids.delete) + .setEmoji(emojis.delete) .setCustomId("deleteInteraction"); export const pollVote1 = new ButtonBuilder() @@ -55,16 +55,16 @@ export const pollVote5 = new ButtonBuilder() export const pollUpvote = new ButtonBuilder() .setStyle(ButtonStyle.Success) - .setEmoji(ids.upvote) + .setEmoji(emojis.upvote) .setCustomId("pollVote__upvote"); export const pollDownvote = new ButtonBuilder() .setStyle(ButtonStyle.Danger) - .setEmoji(ids.downvote) + .setEmoji(emojis.downvote) .setCustomId("pollVote__downvote"); export const pollDelete = new ButtonBuilder() .setStyle(ButtonStyle.Danger) - .setEmoji(ids.delete) + .setEmoji(emojis.delete) .setCustomId("pollDelete"); export const pollVotes = [pollVote1, pollVote2, pollVote3, pollVote4, pollVote5]; diff --git a/src/helpers/utility/colors.ts b/src/helpers/utility/colors.ts index 225c29b6..84e27d47 100644 --- a/src/helpers/utility/colors.ts +++ b/src/helpers/utility/colors.ts @@ -15,9 +15,9 @@ export const colors: Record = { coin: "#ffdc16", // branding colors brand: "#76c945", - f32: "#00a2ff", - f64: "#d8158d", - cf32: "#00c756", - cf64: "#9f00cf", - cf32pa: "#a1db12", + faithful_32x: "#00a2ff", + faithful_64x: "#d8158d", + classic_faithful_32x: "#00c756", + classic_faithful_32x_progart: "#a1db12", + classic_faithful_64x: "#9f00cf", }; diff --git a/src/helpers/utility/emojis.ts b/src/helpers/utility/emojis.ts index 6c03515c..ab49ee38 100644 --- a/src/helpers/utility/emojis.ts +++ b/src/helpers/utility/emojis.ts @@ -1,5 +1,5 @@ // note: the key name should be the same as the actual name -export const ids = { +export const emojis = { bug: "959344133145755648", suggestion: "959344133158350869", view_votes: "949830600125194281", @@ -40,8 +40,8 @@ export const ids = { * @param id emoji id * @returns usable string */ -export function parseId(id: string) { - return `<:${Object.keys(ids).find((key) => ids[key] === id)}:${id}>`; +export function parseID(id: string) { + return `<:${Object.keys(emojis).find((key) => emojis[key] === id)}:${id}>`; } -export type emojiTypes = keyof typeof ids; +export type emojiTypes = keyof typeof emojis; diff --git a/src/helpers/utility/infoembed.ts b/src/helpers/utility/infoembed.ts index 73deec7b..845a21c0 100644 --- a/src/helpers/utility/infoembed.ts +++ b/src/helpers/utility/infoembed.ts @@ -1,151 +1,108 @@ -import { ColorResolvable } from "discord.js"; -import { colors } from "@utility/colors"; -import { parseId, ids } from "@utility/emojis"; +import { parseID, emojis } from "@utility/emojis"; export interface MediaI { [name: string]: { - color: ColorResolvable; title: string; description: string; }; } -// sorry for the questionable indentation and formatting -// blame prettier for most of it but also discord sometimes rendering whitespace weirdly +//prettier-ignore export const media: MediaI = { faithful_32x: { - color: colors.f32, title: `Faithful 32x:`, description: ` -[${parseId(ids.faithful_logo)} Website](https://faithfulpack.net/faithful32x/latest) +[${parseID(emojis.faithful_logo)} Website](https://faithfulpack.net/faithful32x/latest) -[${parseId( - ids.curseforge, - )} Java Edition CurseForge](https://curseforge.com/minecraft/texture-packs/faithful-32x) +[${parseID(emojis.curseforge)} Java Edition CurseForge](https://curseforge.com/minecraft/texture-packs/faithful-32x) -[${parseId( - ids.curseforge, - )} Bedrock Edition CurseForge](https://www.curseforge.com/minecraft-bedrock/addons/faithful-32x-bedrock) +[${parseID(emojis.curseforge)} Bedrock Edition CurseForge](https://www.curseforge.com/minecraft-bedrock/addons/faithful-32x-bedrock) -[${parseId(ids.modrinth)} Modrinth](https://modrinth.com/resourcepack/faithful-32x) +[${parseID(emojis.modrinth)} Modrinth](https://modrinth.com/resourcepack/faithful-32x) -[${parseId(ids.pmc)} Planet Minecraft](https://planetminecraft.com/texture-pack/faithful-32x/) +[${parseID(emojis.pmc)} Planet Minecraft](https://planetminecraft.com/texture-pack/faithful-32x/) -[${parseId(ids.mcpedl)} MCPEDL](https://mcpedl.com/faithful-32x/) +[${parseID(emojis.mcpedl)} MCPEDL](https://mcpedl.com/faithful-32x/) -[${parseId( - ids.github, - )} Java Edition GitHub](https://github.com/faithful-resource-pack/faithful-java-32x) +[${parseID(emojis.github)} Java Edition GitHub](https://github.com/faithful-resource-pack/faithful-java-32x) -[${parseId( - ids.github, - )} Bedrock Edition GitHub](https://github.com/faithful-resource-pack/faithful-bedrock-32x)`, +[${parseID(emojis.github)} Bedrock Edition GitHub](https://github.com/faithful-resource-pack/faithful-bedrock-32x)`, }, - faithful_64x: { - color: colors.f64, title: "Faithful 64x:", description: ` -[${parseId(ids.faithful_logo)} Website](https://faithfulpack.net/faithful64x/latest) +[${parseID(emojis.faithful_logo)} Website](https://faithfulpack.net/faithful64x/latest) -[${parseId( - ids.curseforge, - )} Java Edition CurseForge](https://curseforge.com/minecraft/texture-packs/faithful-64x) +[${parseID(emojis.curseforge)} Java Edition CurseForge](https://curseforge.com/minecraft/texture-packs/faithful-64x) -[${parseId( - ids.curseforge, - )} Bedrock Edition CurseForge](https://www.curseforge.com/minecraft-bedrock/addons/faithful-64x-bedrock) +[${parseID(emojis.curseforge)} Bedrock Edition CurseForge](https://www.curseforge.com/minecraft-bedrock/addons/faithful-64x-bedrock) -[${parseId(ids.modrinth)} Modrinth](https://modrinth.com/resourcepack/faithful-64x) +[${parseID(emojis.modrinth)} Modrinth](https://modrinth.com/resourcepack/faithful-64x) -[${parseId(ids.pmc)} Planet Minecraft](https://planetminecraft.com/texture-pack/faithful-64x/) +[${parseID(emojis.pmc)} Planet Minecraft](https://planetminecraft.com/texture-pack/faithful-64x/) -[${parseId(ids.mcpedl)} MCPEDL](https://mcpedl.com/faithful-64x/) +[${parseID(emojis.mcpedl)} MCPEDL](https://mcpedl.com/faithful-64x/) -[${parseId( - ids.github, - )} Java Edition GitHub](https://github.com/faithful-resource-pack/faithful-java-64x) +[${parseID(emojis.github)} Java Edition GitHub](https://github.com/faithful-resource-pack/faithful-java-64x) -[${parseId( - ids.github, - )} Bedrock Edition GitHub](https://github.com/faithful-resource-pack/faithful-bedrock-64x) +[${parseID(emojis.github)} Bedrock Edition GitHub](https://github.com/faithful-resource-pack/faithful-bedrock-64x) `, }, classic_faithful_32x: { - color: colors.cf32, title: "Classic Faithful 32x Jappa:", description: ` -[${parseId(ids.faithful_logo)} Website](https://faithfulpack.net/classicfaithful/32x-jappa) +[${parseID(emojis.faithful_logo)} Website](https://faithfulpack.net/classicfaithful/32x-jappa) + +[${parseID(emojis.curseforge)} CurseForge](https://curseforge.com/minecraft/texture-packs/classic-faithful-32x-jappa) -[${parseId( - ids.curseforge, - )} CurseForge](https://curseforge.com/minecraft/texture-packs/classic-faithful-32x-jappa) +[${parseID(emojis.modrinth)} Modrinth](https://modrinth.com/resourcepack/classic-faithful-32x-jappa) -[${parseId( - ids.pmc, - )} Planet Minecraft](https://planetminecraft.com/texture-pack/classic-faithful-32x) +[${parseID(emojis.pmc)} Planet Minecraft](https://planetminecraft.com/texture-pack/classic-faithful-32x) -[${parseId(ids.github)} Java Edition GitHub](https://github.com/classicfaithful/32x-jappa) +[${parseID(emojis.github)} Java Edition GitHub](https://github.com/classicfaithful/32x-jappa) -[${parseId( - ids.github, - )} Bedrock Edition GitHub](https://github.com/classicfaithful/32x-jappa-bedrock) +[${parseID(emojis.github)} Bedrock Edition GitHub](https://github.com/classicfaithful/32x-jappa-bedrock) -[${parseId(ids.github)} Add-ons GitHub](https://github.com/classicfaithful/32x-jappa-add-ons) +[${parseID(emojis.github)} Add-ons GitHub](https://github.com/classicfaithful/32x-jappa-add-ons) `, }, classic_faithful_32x_progart: { - color: colors.cf32pa, title: "Classic Faithful 32x PA:", description: ` -[${parseId(ids.faithful_logo)} Website](https://faithfulpack.net/classicfaithful/32x-programmer-art) +[${parseID(emojis.faithful_logo)} Website](https://faithfulpack.net/classicfaithful/32x-programmer-art) + +[${parseID(emojis.curseforge)} CurseForge](https://curseforge.com/minecraft/texture-packs/classic-faithful-32x-pa) -[${parseId( - ids.curseforge, - )} CurseForge](https://curseforge.com/minecraft/texture-packs/classic-faithful-32x-pa) +[${parseID(emojis.pmc)} Planet Minecraft](https://planetminecraft.com/texture-pack/classic-faithful-32x-pa) -[${parseId( - ids.pmc, - )} Planet Minecraft](https://planetminecraft.com/texture-pack/classic-faithful-32x-pa) +[${parseID(emojis.modrinth)} Modrinth](https://modrinth.com/resourcepack/classic-faithful-32x-programmer-art) -[${parseId(ids.github)} Java Edition GitHub](https://github.com/classicfaithful/32x-programmer-art) +[${parseID(emojis.github)} Java Edition GitHub](https://github.com/classicfaithful/32x-programmer-art) -[${parseId( - ids.github, - )} Bedrock Edition GitHub](https://github.com/classicfaithful/32x-programmer-art-bedrock) +[${parseID(emojis.github)} Bedrock Edition GitHub](https://github.com/classicfaithful/32x-programmer-art-bedrock) -[${parseId( - ids.github, - )} Add-ons GitHub](https://github.com/classicfaithful/32x-programmer-art-add-ons) +[${parseID(emojis.github)} Add-ons GitHub](https://github.com/classicfaithful/32x-programmer-art-add-ons) `, }, classic_faithful_64x: { - color: colors.cf64, title: "Classic Faithful 64x:", description: ` -[${parseId(ids.faithful_logo)} Website](https://faithfulpack.net/classicfaithful/64x-jappa) +[${parseID(emojis.faithful_logo)} Website](https://faithfulpack.net/classicfaithful/64x-jappa) -[${parseId( - ids.curseforge, - )} CurseForge](https://curseforge.com/minecraft/texture-packs/classic-faithful-64x) +[${parseID(emojis.curseforge)} CurseForge](https://curseforge.com/minecraft/texture-packs/classic-faithful-64x) -[${parseId( - ids.pmc, - )} Planet Minecraft](https://planetminecraft.com/texture-pack/classic-faithful-64x/) +[${parseID(emojis.pmc)} Planet Minecraft](https://planetminecraft.com/texture-pack/classic-faithful-64x/) -[${parseId(ids.github)} Java Edition GitHub](https://github.com/classicfaithful/64x-jappa) +[${parseID(emojis.github)} Java Edition GitHub](https://github.com/classicfaithful/64x-jappa) -[${parseId( - ids.github, - )} Bedrock Edition GitHub](https://github.com/classicfaithful/64x-jappa-bedrock) +[${parseID(emojis.github)} Bedrock Edition GitHub](https://github.com/classicfaithful/64x-jappa-bedrock) `, }, default: { - color: colors.brand, title: "Useful Links:", description: ` ### General: