Skip to content

Commit

Permalink
add modrinth to CF listings
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Nov 2, 2023
1 parent aa10ad4 commit 2bd0a46
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 121 deletions.
5 changes: 3 additions & 2 deletions src/client/embed.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
}
}
6 changes: 3 additions & 3 deletions src/client/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/commands/bot/poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 {
Expand Down
26 changes: 14 additions & 12 deletions src/commands/faithful/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -29,28 +30,29 @@ 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
),
});
}

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 })
Expand Down
22 changes: 11 additions & 11 deletions src/helpers/utility/buttons.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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];
Expand Down
10 changes: 5 additions & 5 deletions src/helpers/utility/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export const colors: Record<string, ColorResolvable> = {
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",
};
8 changes: 4 additions & 4 deletions src/helpers/utility/emojis.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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;
Loading

0 comments on commit 2bd0a46

Please sign in to comment.