Skip to content

Commit

Permalink
use Record type inline
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Oct 27, 2023
1 parent 1948a98 commit 42154f8
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class ExtendedClient extends Client {
}

const rest = new REST({ version: "10" }).setToken(this.tokens.token);
const allGuilds: { [name: string]: string } = (
const allGuilds: Record<string, string> = (
await axios.get(`${this.tokens.apiUrl}settings/guilds`)
).data;

Expand Down
2 changes: 1 addition & 1 deletion src/commands/faithful/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const command: SlashCommand = {
const key = interaction.options.getString("name", false) ?? "default";

// you can't import images directly in infoembed.ts so you have to do it here (blame TS)
const images: { [name: string]: string } = (
const images: Record<string, string> = (
await axios.get(`${interaction.client.tokens.apiUrl}settings/images`)
).data;

Expand Down
4 changes: 2 additions & 2 deletions src/helpers/images/zipToAttachmentBuilders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const zipToAttachmentBuilders = async (url: string): Promise<AttachmentBu
).data;

// get files inside the zip as an object: { "filename": "Buffer" }
const zipFiles: { [key: string]: Buffer } = await JSZip.loadAsync(arrayBufferToBufferCycle(zip))
const zipFiles: Record<string, Buffer> = await JSZip.loadAsync(arrayBufferToBufferCycle(zip))
.then((zip) => {
const ext = /(.png|.tga)$/;
let promises = Object.keys(zip.files)
Expand All @@ -35,7 +35,7 @@ export const zipToAttachmentBuilders = async (url: string): Promise<AttachmentBu

return Promise.all(promises);
})
.then((res): { [key: string]: Buffer } => {
.then((res): Record<string, Buffer> => {
return res.reduce((acc, val: [key: string, buff: Buffer]) => {
const splitted = val[0].split("/");
const key = splitted.at(-1);
Expand Down
4 changes: 1 addition & 3 deletions src/helpers/timedEmbed.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { TextChannel } from "discord.js";
import { Message } from "@client";

export type Votes = {
[key: string]: string[];
};
export type Votes = Record<string, string[]>;

interface AllVotes {
upvote: number;
Expand Down
7 changes: 1 addition & 6 deletions src/helpers/utility/colors.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { ColorResolvable } from "discord.js";

// discord.js will complain strings can't resolve as colors otherwise
type ColorType = {
[name: string]: ColorResolvable;
};

/**
* Can't fetch from settings.json since djs complains about color resolving
* so we declare them all here
*/
export const colors: ColorType = {
export const colors: Record<string, ColorResolvable> = {
// status/generic colors
red: "#f44336",
yellow: "#ffeb3b",
Expand Down
4 changes: 1 addition & 3 deletions src/interfaces/submission.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// settings.submission.packs
export interface Submissions {
[pack: string]: Pack;
}
export type Submissions = Record<string, Pack>;

// one specific pack instance
export interface Pack {
Expand Down

0 comments on commit 42154f8

Please sign in to comment.