Skip to content

Commit

Permalink
more types
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Dec 3, 2023
1 parent df9bda2 commit 43a64fa
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
12 changes: 5 additions & 7 deletions src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ export class ExtendedClient<Ready extends boolean = boolean> extends Client<Read
relative_path: string,
) {
const obj = getData({ filename, relative_path });
Object.keys(obj).forEach((key: string) => {
collection.set(key, obj[key]);
});
Object.keys(obj).forEach((key: string) => collection.set(key, obj[key]));

collection.events.on("dataSet", (key: string, value: any) =>
this.saveEmittingCollection(collection, filename, relative_path),
Expand Down Expand Up @@ -267,15 +265,15 @@ export class ExtendedClient<Ready extends boolean = boolean> extends Client<Read
el.servers = ["dev"];
});

const guilds = { global: [] };
commandsArr.forEach((cmd) => {
const guilds: Record<string, RESTPostAPIApplicationCommandsJSONBody[]> = { global: [] };
for (const cmd of commandsArr) {
if (!cmd.servers) guilds.global.push(cmd.command);
else
cmd.servers.forEach((server) => {
if (guilds[server] === undefined) guilds[server] = [];
if (!guilds[server]) guilds[server] = [];
guilds[server].push(cmd.command);
});
});
}

for (const [name, id] of Object.entries(allGuilds).filter((obj) => obj[1] != "id")) {
// if the client isn't in the guild, skip it
Expand Down
2 changes: 1 addition & 1 deletion src/commands/faithful/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const command: SlashCommand = {
interaction.guildId == settings.guilds.classic_faithful
? settings.images.cf_plain
: settings.images.plain;
let embedArray = [];
let embedArray: EmbedBuilder[] = [];
let i = 0;

if (choice == "all")
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/choiceEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export async function generalChoiceEmbed(

for (let i = 0; i < emojis.length; ++i)
if (choices[0] !== undefined) {
let t = choices.shift();
t.emoji = emojis[i % emojis.length];
options.push(t);
const choice = choices.shift();
choice.emoji = emojis[i % emojis.length];
options.push(choice);
}

const menu = new StringSelectMenuBuilder()
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/functions/missing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export async function updateVoiceChannel(client: Client, results: MissingData) {
* @returns array of all paths in the directory
*/
export const getAllFilesFromDir = (dir: string, filter: string[] = []): string[] => {
const fileList = [];
const fileList: string[] = [];
readdirSync(dir).forEach((file) => {
file = normalize(join(dir, file));
const stat = statSync(file);
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/poll.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { pollDelete, pollVotes, pollYesNo } from "@utility/buttons";
import { Client, ChatInputCommandInteraction, Message, EmbedBuilder } from "@client";
import { ActionRowBuilder, ButtonBuilder, TextChannel } from "discord.js";
import { AllVotes, TimedEmbed } from "@helpers/timedEmbed";
import { AllVotes, TimedEmbed, Votes } from "@helpers/timedEmbed";

export interface PollOptions {
question: string;
Expand Down Expand Up @@ -160,7 +160,7 @@ export class Poll extends TimedEmbed {
if (options.yesno) {
this.setVotes({ upvote: [], downvote: [] });
} else {
let tmp = {};
let tmp: Votes = {};
for (let i = 0; i < options.answersArr.length; ++i) tmp[i] = [];
this.setVotes(tmp);
}
Expand All @@ -176,7 +176,7 @@ export class Poll extends TimedEmbed {
if (options.yesno) components.push(pollYesNo);
else {
const btns: ButtonBuilder[] = [];
options.answersArr.forEach((el, index) => btns.push(pollVotes[index]));
options.answersArr.forEach((_, index) => btns.push(pollVotes[index]));
components.push(new ActionRowBuilder<ButtonBuilder>().addComponents(btns));
}

Expand Down
4 changes: 1 addition & 3 deletions src/helpers/timedEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ export class TimedEmbed {
public addVote(type: string, id: string) {
if (!this.multipleAnswers) {
// remove user vote for all others categories
Object.keys(this.votes).forEach((key: string) => {
this.removeVote(key, id);
});
Object.keys(this.votes).forEach((key: string) => this.removeVote(key, id));
}

if (this.hasVotedFor(type, id)) this.removeVote(type, id);
Expand Down

0 comments on commit 43a64fa

Please sign in to comment.