Skip to content

Commit

Permalink
reformat the entire helper folder
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Oct 8, 2023
1 parent 35d4dc0 commit 10f5cdf
Show file tree
Hide file tree
Showing 54 changed files with 213 additions and 214 deletions.
2 changes: 1 addition & 1 deletion src/client/automation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Poll } from "@class/poll";
import { Poll } from "@helpers/poll";
import { Client } from "@client";

/**
Expand Down
7 changes: 3 additions & 4 deletions src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ import {
REST,
} from "discord.js";
import { Message, EmittingCollection, Automation } from "@client";
import { Tokens, Component, SlashCommand, AsyncSlashCommandBuilder, Event } from "@interfaces";
import { getData } from "@functions/getDataFromJSON";
import { setData } from "@functions/setDataToJSON";
import { Tokens, Component, SlashCommand, Event } from "@interfaces";
import { setData, getData } from "@utility/handleJSON";
import { errorHandler } from "@functions/errorHandler";
import { err, info, success } from "@helpers/logger";
import { Poll } from "@class/poll";
import { Poll } from "@helpers/poll";

import { join } from "path";
import chalk from "chalk";
Expand Down
2 changes: 1 addition & 1 deletion src/client/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "discord.js";
import { strings, AllStrings } from "@helpers/strings";
import { EmbedBuilder } from "@client";
import { colors } from "@helpers/colors";
import { colors } from "@utility/colors";
import { ExtendedClient } from "./client";

export type PermissionType = "manager" | "dev" | "moderator" | "council";
Expand Down
2 changes: 1 addition & 1 deletion src/client/message.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Message, ActionRowBuilder, ComponentType } from "discord.js";
import { deleteInteraction, deleteMessage } from "@helpers/buttons";
import { deleteInteraction, deleteMessage } from "@utility/buttons";
import { ButtonBuilder } from "discord.js";
import { ExtendedClient } from "./client";
import { strings, AllStrings } from "@helpers/strings";
Expand Down
2 changes: 1 addition & 1 deletion src/commands/bot/embed.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SlashCommand } from "@interfaces";
import { ChatInputCommandInteraction, EmbedBuilder, Message } from "@client";
import { ColorResolvable, PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
import { colors } from "@helpers/colors";
import { colors } from "@utility/colors";

export const command: SlashCommand = {
data: new SlashCommandBuilder()
Expand Down
2 changes: 1 addition & 1 deletion src/commands/bot/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SlashCommand } from "@interfaces";
import { SlashCommandBuilder } from "discord.js";
import { EmbedBuilder, ChatInputCommandInteraction, Message } from "@client";
import { ping } from "@json/quotes.json";
import * as Random from "@helpers/random";
import * as Random from "@utility/random";

export const command: SlashCommand = {
data: new SlashCommandBuilder().setName("ping").setDescription("Check the bot and API latency."),
Expand Down
6 changes: 3 additions & 3 deletions src/commands/bot/poll.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { SlashCommandBuilder, EmbedField } from "discord.js";
import { SlashCommand } from "@interfaces";
import { Poll } from "@class/poll";
import { addSeconds, parseDate } from "@helpers/dates";
import { ids, parseId } from "@helpers/emojis";
import { Poll } from "@helpers/poll";
import { addSeconds, parseDate } from "@utility/dates";
import { ids, parseId } from "@utility/emojis";
import { ChatInputCommandInteraction, EmbedBuilder, Message } from "@client";

export const command: SlashCommand = {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/faithful/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SlashCommand } from "@interfaces";
import { Message, EmbedBuilder, ChatInputCommandInteraction } from "@client";
import { SlashCommandBuilder, AttachmentBuilder } from "discord.js";
import axios from "axios";
import { formatName } from "@helpers/sorter";
import formatName from "@utility/formatName";
import { Contribution, Texture } from "@interfaces";

export const command: SlashCommand = {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/faithful/faq.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SlashCommand } from "@interfaces";
import { SlashCommandBuilder } from "discord.js";
import { ChatInputCommandInteraction, Message, EmbedBuilder } from "@client";
import { colors } from "@helpers/colors";
import { colors } from "@utility/colors";
import faqStrings from "@json/faq.json";
import axios from "axios";

Expand Down
2 changes: 1 addition & 1 deletion src/commands/faithful/guidelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SlashCommand } from "@interfaces";
import { SlashCommandBuilder } from "discord.js";
import { ChatInputCommandInteraction, Message, EmbedBuilder } from "@client";
import guidelineJSON from "@json/guidelines.json";
import { colors } from "@helpers/colors";
import { colors } from "@utility/colors";

export const command: SlashCommand = {
data: new SlashCommandBuilder()
Expand Down
2 changes: 1 addition & 1 deletion src/commands/faithful/media.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SlashCommand } from "@interfaces";
import { SlashCommandBuilder } from "discord.js";
import { media } from "@helpers/infoembed";
import { media } from "@utility/infoembed";
import { Message, EmbedBuilder, ChatInputCommandInteraction } from "@client";
import axios from "axios";

Expand Down
3 changes: 2 additions & 1 deletion src/commands/faithful/missing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
MissingResult,
} from "@functions/missing";
import axios from "axios";
import { formatName, minecraftSorter } from "@helpers/sorter";
import formatName from "@utility/formatName";
import minecraftSorter from "@utility/minecraftSorter";

export const command: SlashCommand = {
async data(client: Client): Promise<SyncSlashCommandBuilder> {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/faithful/rule.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SlashCommand } from "@interfaces";
import { SlashCommandBuilder } from "discord.js";
import { ChatInputCommandInteraction, Message, EmbedBuilder } from "@client";
import { colors } from "@helpers/colors";
import { colors } from "@utility/colors";
import ruleStrings from "@json/rules.json";
import axios from "axios";

Expand Down
2 changes: 1 addition & 1 deletion src/commands/faithful/texture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SlashCommandBuilder } from "discord.js";
import { ChatInputCommandInteraction, EmbedBuilder, Message } from "@client";
import { getTexture } from "@functions/getTexture";
import parseTextureName from "@functions/parseTextureName";
import { colors } from "@helpers/colors";
import { colors } from "@utility/colors";
import { textureChoiceEmbed } from "@helpers/choiceEmbed";

export const command: SlashCommand = {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/fun/coin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SlashCommand } from "@interfaces";
import { SlashCommandBuilder } from "discord.js";
import { ChatInputCommandInteraction, Message, EmbedBuilder } from "@client";
import { colors } from "@helpers/colors";
import { colors } from "@utility/colors";

export const command: SlashCommand = {
data: new SlashCommandBuilder()
Expand Down
2 changes: 1 addition & 1 deletion src/commands/images/animate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { animateToAttachment, MCMETA } from "@helpers/images/animate";
import mcmetaList from "@json/mcmetas.json";
import { loadImage } from "@napi-rs/canvas";
import { magnify } from "@helpers/images/magnify";
import { colors } from "@helpers/colors";
import { colors } from "@utility/colors";

export const command: SlashCommand = {
data: new SlashCommandBuilder()
Expand Down
2 changes: 1 addition & 1 deletion src/commands/images/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SlashCommandBuilder } from "discord.js";
import { Client, ChatInputCommandInteraction, EmbedBuilder, Message } from "@client";
import textureComparison from "@functions/textureComparison";
import parseTextureName from "@functions/parseTextureName";
import { colors } from "@helpers/colors";
import { colors } from "@utility/colors";
import { textureChoiceEmbed } from "@helpers/choiceEmbed";

export const command: SlashCommand = {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/images/magnify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SlashCommandBuilder } from "discord.js";
import { ChatInputCommandInteraction, Message } from "@client";
import { magnifyToAttachment } from "@images/magnify";
import getImage from "@helpers/getImage";
import { imageButtons } from "@helpers/buttons";
import { imageButtons } from "@utility/buttons";

export const command: SlashCommand = {
data: new SlashCommandBuilder()
Expand Down
4 changes: 2 additions & 2 deletions src/commands/images/tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { SlashCommandBuilder } from "discord.js";
import { ChatInputCommandInteraction, EmbedBuilder, Message } from "@client";
import { tileToAttachment, TileShape, TileRandom, tileTooBig } from "@images/tile";
import getImage from "@helpers/getImage";
import { imageButtons } from "@helpers/buttons";
import { colors } from "@helpers/colors";
import { imageButtons } from "@utility/buttons";
import { colors } from "@utility/colors";

export const command: SlashCommand = {
data: new SlashCommandBuilder()
Expand Down
2 changes: 1 addition & 1 deletion src/commands/images/tint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ChatInputCommandInteraction, Message } from "@client";
import { SlashCommandBuilder } from "discord.js";
import { mcColorsOptions, multiplyToAttachment } from "@images/multiply";
import getImage from "@helpers/getImage";
import { imageButtons } from "@helpers/buttons";
import { imageButtons } from "@utility/buttons";
export const command: SlashCommand = {
data: new SlashCommandBuilder()
.setName("tint")
Expand Down
2 changes: 1 addition & 1 deletion src/components/buttons/image/comparisonTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { info } from "@helpers/logger";
import { Client, Message, ButtonInteraction, EmbedBuilder } from "@client";
import { magnifyToAttachment } from "@images/magnify";
import { parseDisplay } from "@functions/textureComparison";
import { formatName } from "@helpers/sorter";
import formatName from "@utility/formatName";
import { loadImage } from "@napi-rs/canvas";
import stitch from "@helpers/images/stitch";

Expand Down
2 changes: 1 addition & 1 deletion src/components/buttons/image/magnify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component } from "@interfaces";
import { info } from "@helpers/logger";
import { Client, Message, ButtonInteraction, EmbedBuilder } from "@client";
import { magnifyToAttachment } from "@images/magnify";
import { imageButtons } from "@helpers/buttons";
import { imageButtons } from "@utility/buttons";
import getImage from "@helpers/getImage";

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/components/buttons/image/tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component } from "@interfaces";
import { info } from "@helpers/logger";
import { Client, Message, ButtonInteraction, EmbedBuilder } from "@client";
import { tileToAttachment, tileTooBig } from "@images/tile";
import { imageButtons } from "@helpers/buttons";
import { imageButtons } from "@utility/buttons";
import getImage from "@helpers/getImage";

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/components/buttons/poll/pollVote.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from "@interfaces";
import { Client, Message, ButtonInteraction } from "@client";
import { Poll } from "@class/poll";
import { Poll } from "@helpers/poll";

export default {
id: "pollVote",
Expand Down
4 changes: 2 additions & 2 deletions src/events/messageCreate.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Event } from "@interfaces";
import { Client, Message, EmbedBuilder } from "@client";
import { Pack } from "@interfaces";
import { colors } from "@helpers/colors";
import { colors } from "@utility/colors";
import axios from "axios";
import * as Random from "@helpers/random";
import * as Random from "@utility/random";
import prefixCommandHandler from "@helpers/prefixCommandHandler";

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/events/slashCommandUsed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Pack, SlashCommandI } from "@interfaces";
import { Collection } from "discord.js";
import { Event } from "@interfaces";
import { Client, ChatInputCommandInteraction, EmbedBuilder } from "@client";
import { colors } from "@helpers/colors";
import { colors } from "@utility/colors";
import axios from "axios";

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/choiceEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
StringSelectMenuBuilder,
} from "discord.js";
import { Texture } from "@interfaces";
import { minecraftSorter } from "@helpers/sorter";
import minecraftSorter from "@utility/minecraftSorter";
import axios from "axios";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/functions/errorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { readFileSync } from "fs";
import { devLogger, err } from "@helpers/logger";
import { Log } from "client/client";
import { join } from "path";
import * as Random from "@helpers/random";
import * as Random from "@utility/random";
import { error as randomSentences } from "@json/quotes.json";

const lastReasons = [];
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/functions/feedback.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ModalSubmitInteraction } from "discord.js";
import { Octokit } from "@octokit/rest";
import { EmbedBuilder } from "@client";
import { colors } from "@helpers/colors";
import { colors } from "@utility/colors";

/**
* Create GitHub issue with specified title and description
Expand Down
32 changes: 0 additions & 32 deletions src/helpers/functions/getDataFromJSON.ts

This file was deleted.

42 changes: 38 additions & 4 deletions src/helpers/functions/getTexture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import TokenJson from "@json/tokens.json";
import { Contributor, Tokens } from "@interfaces";
import axios from "axios";
import getDimensions from "@images/getDimensions";
import { AttachmentBuilder, Guild } from "discord.js";
import { APIEmbedField, AttachmentBuilder, Guild } from "discord.js";
import { magnifyToAttachment } from "@images/magnify";
import { ISizeCalculationResult } from "image-size/dist/types/interface";
import { colors } from "@helpers/colors";
import { colors } from "@utility/colors";
import { Texture, Contribution } from "@interfaces";
import { animateToAttachment } from "@images/animate";
import { formatName, minecraftSorter, addPathsToEmbed } from "@helpers/sorter";
import { textureButtons } from "@helpers/buttons";
import minecraftSorter from "@utility/minecraftSorter";
import formatName from "@utility/formatName";
import { textureButtons } from "@utility/buttons";
import { loadImage } from "@napi-rs/canvas";

/**
Expand Down Expand Up @@ -127,3 +128,36 @@ export const getTexture = async (options: {

return { embeds: [embed], files: files, components: [textureButtons], ephemeral: false };
};


/**
* Generate embed fields for a given texture's paths
* @author Juknum
* @param texture texture to get paths and uses from
* @returns usable embed field data
*/
export const addPathsToEmbed = (texture: Texture): APIEmbedField[] => {
const tmp = {};
texture.uses.forEach((use) => {
texture.paths
.filter((el) => el.use === use.id)
.forEach((p) => {
const versions = p.versions.sort(minecraftSorter);
const versionRange = `\`[${
versions.length > 1 ? `${versions[0]}${versions.at(-1)}` : versions[0]
}]\``;
const formatted = `${versionRange} ${p.name}`;
if (tmp[use.edition]) tmp[use.edition].push(formatted);
else tmp[use.edition] = [formatted];
});
});

return Object.keys(tmp).map((edition) => {
if (tmp[edition].length) {
return {
name: edition.charAt(0).toLocaleUpperCase() + edition.slice(1),
value: tmp[edition].join("\n"),
};
}
});
};
2 changes: 1 addition & 1 deletion src/helpers/functions/missing.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { exec, series } from "@helpers/exec";
import { existsSync, readdirSync, statSync } from "fs";
import { mkdir } from "fs/promises";
import { formatName } from "@helpers/sorter";
import formatName from "@utility/formatName";
import { Client } from "@client";
import { Channel, ChannelType, VoiceChannel } from "discord.js";
import { join, normalize } from "path";
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/functions/parseTextureName.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from "axios";
import { ChatInputCommandInteraction, EmbedBuilder } from "@client";
import { colors } from "@helpers/colors";
import { colors } from "@utility/colors";
import { Texture } from "@interfaces";

/**
Expand Down
Loading

0 comments on commit 10f5cdf

Please sign in to comment.