Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed unused vars #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";


export default [
{files: ["**/*.{js,mjs,cjs,ts}"]},
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
];
1,711 changes: 1,690 additions & 21 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
"format": "prettier . --write"
},
"devDependencies": {
"@eslint/js": "^9.10.0",
"@types/express": "^4.17.21",
"@types/node-steam-openid": "^1.0.3",
"@types/pg": "^8.11.6",
"drizzle-kit": "^0.24.0",
"eslint": "^9.10.0",
"globals": "^15.9.0",
"prettier": "3.3.3",
"tsx": "^4.7.1",
"typescript": "^5.4.3"
"typescript": "^5.4.3",
"typescript-eslint": "^8.6.0"
},
"dependencies": {
"axios": "^1.7.4",
Expand Down
5 changes: 2 additions & 3 deletions src/events/discord/guildMemberCreate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BaseGuildTextChannel, Client, Interaction } from "discord.js";
import { commands } from "../..";
import { Locales, formatLocale, replacement } from "../../locales";
import { BaseGuildTextChannel, Client } from "discord.js";
import { Locales, replacement } from "../../locales";
import { db, getLocale, getUser } from "../../db";
import { tickets as ticketSchema } from "../../schema";
import { eq } from "drizzle-orm";
Expand Down
6 changes: 4 additions & 2 deletions src/events/discord/interactionCreate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Client, Interaction } from "discord.js";
import { commands } from "../..";
import { Locales, formatLocale } from "../../locales";
import { db, getLocale } from "../../db";
import { getLocale } from "../../db";

export default async function (client: Client) {
client.on("interactionCreate", async (interaction) => {
Expand All @@ -10,7 +10,9 @@ export default async function (client: Client) {
finder = interaction.customId;
} else {
finder = interaction.commandName;
interaction.isAutocomplete() ? (finder += "-autocomplete") : finder;
if (interaction.isAutocomplete()) {
finder += "-autocomplete";
}
}
const command = commands.get(finder);
if (!command) return;
Expand Down
8 changes: 1 addition & 7 deletions src/events/discord/presenceUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import { ActivityType, BaseGuildTextChannel, Client, Interaction } from "discord.js";
import { commands } from "../..";
import { Locales, formatLocale, replacement } from "../../locales";
import { db, getLocale, getUser } from "../../db";
import { tickets as ticketSchema } from "../../schema";
import { eq } from "drizzle-orm";
import { DiscordFetch } from "../../utils/discord";
import { ActivityType, Client, } from "discord.js";

export default async function (client: Client) {
client.on("presenceUpdate", async (oldPresence, newPresence) => {
Expand Down
9 changes: 2 additions & 7 deletions src/events/discord/ready.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Client, REST, Routes, ActivityType } from "discord.js";
import { commands } from "../..";
import { readdirSync } from "fs";
import path from "path";
import { Command, CommandNoRun } from "../../types/discord";
import { init } from "../../db";
import { load } from "../../locales";
Expand Down Expand Up @@ -29,7 +28,7 @@ export default async function (client: Client) {
if (command.role !== "CHAT_INPUT")
command.type =
command.role === "MESSAGE_CONTEXT_MENU" ? 3 : 2;
const { run, default_member_permissions, ...rest } = command;
const { default_member_permissions, ...rest } = command;
const add: CommandNoRun & {
default_member_permissions?: string;
} = rest;
Expand Down Expand Up @@ -111,8 +110,4 @@ const isDeepEqual = (

const isObject = (object: unknown) => {
return object != null && typeof object === "object";
};

function cwd() {
return __dirname.split("/").slice(0, -2).join("/");
}
};
2 changes: 1 addition & 1 deletion src/interactions/misc/config/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PermissionFlagsBits, CategoryChannel } from "discord.js";
import { PermissionFlagsBits } from "discord.js";
import { Command } from "../../../types/discord";
import { DiscordFetch, embed } from "../../../utils/discord";
import { haveLocale, Locales } from "../../../locales";
Expand Down
10 changes: 1 addition & 9 deletions src/interactions/misc/config/config_autocomplete.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
PermissionsBitField,
PermissionFlagsBits,
} from "discord.js";
import { Command } from "../../../types/discord";
import { embed } from "../../../utils/discord";
import { Locales } from "../../../locales";

export default {
name: "config-autocomplete",
role: "AUTOCOMPLETE",
run: async (interaction, serverLocale, userLocale) => {
run: async (interaction, ) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should cause an error, can't test rn tho

const option = interaction.options.getFocused(true);
switch (option.name) {
case "option": {
Expand Down
5 changes: 1 addition & 4 deletions src/interactions/misc/discord.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
import { Command } from "../../types/discord";
import { getUser } from "../../db";

export default {
name: "discord",
role: "CHAT_INPUT",
description: "Get the Discord server invite link",
run: async (interaction, serverLocale, userLocale) => {
run: async (interaction,) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also

await interaction.reply({
content: "https://discord.gg/uZaTYww7hN",
ephemeral: true,
Expand Down
2 changes: 1 addition & 1 deletion src/interactions/misc/help/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default {
.setLabel(userLocale.get((lang) => lang.help.button.previous))
.setStyle(ButtonStyle.Primary);

let next = new ButtonBuilder()
const next = new ButtonBuilder()
.setCustomId("next")
.setLabel(userLocale.get((lang) => lang.help.button.next))
.setStyle(ButtonStyle.Primary);
Expand Down
2 changes: 1 addition & 1 deletion src/interactions/misc/help/previous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default {
.addFields(fields)
.setFooter({ text: footer });

let previous = new ButtonBuilder()
const previous = new ButtonBuilder()
.setCustomId("previous")
.setLabel(userLocale.get((lang) => lang.help.button.previous))
.setStyle(ButtonStyle.Primary);
Expand Down
3 changes: 1 addition & 2 deletions src/interactions/misc/profile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
import { Command } from "../../types/discord";
import { getUser } from "../../db";
import { DiscordFetch, embed as embed_ } from "../../utils/discord";
Expand Down Expand Up @@ -37,7 +36,7 @@ export default {
.addFields([
{
name: 'Steam',
value: !!steamData ? `[${steamData.personaname}](${steamData.profileurl})` : userLocale.get((lang) => lang.profile.no_steam),
value: steamData ? `[${steamData.personaname}](${steamData.profileurl})` : userLocale.get((lang) => lang.profile.no_steam),
},
{
name: userLocale.get((lang) => lang.profile.other_connections),
Expand Down
3 changes: 1 addition & 2 deletions src/interactions/misc/settings/settings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ButtonStyle, PermissionFlagsBits } from "discord.js";
import { Command } from "../../../types/discord";
import { DiscordFetch, embed } from "../../../utils/discord";
import { embed } from "../../../utils/discord";
import { formatLocale, haveLocale, Locales } from "../../../locales";
import { db, getUser } from "../../../db";
import { servers, users } from "../../../schema";
Expand Down
10 changes: 1 addition & 9 deletions src/interactions/misc/settings/settings_autocomplete.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
PermissionsBitField,
PermissionFlagsBits,
} from "discord.js";
import { Command } from "../../../types/discord";
import { embed } from "../../../utils/discord";
import { Locales } from "../../../locales";

export default {
name: "settings-autocomplete",
role: "AUTOCOMPLETE",
run: async (interaction, serverLocale, userLocale) => {
run: async (interaction) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what it should look like

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But also not at the same time, serverLocale and userLocale need to exist otherwise when the function is called it will throw errors

const option = interaction.options.getFocused(true);
switch (option.name) {
case "option": {
Expand Down
3 changes: 0 additions & 3 deletions src/interactions/misc/setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
PermissionFlagsBits,
} from "discord.js";
import { Command } from "../../types/discord";
Expand Down
1 change: 0 additions & 1 deletion src/interactions/steam/disconnect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
import { Command } from "../../types/discord";
import { setSteamData } from "../../db";

Expand Down
5 changes: 1 addition & 4 deletions src/interactions/tickets/adduser.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
TextChannel,
} from "discord.js";
import { Command } from "../../types/discord";
import { db, getServer } from "../../db";
import { tickets } from "../../schema";
import { eq, sql } from "drizzle-orm";
import { DiscordFetch, embed as embed_ } from "../../utils/discord";
import { embed as embed_ } from "../../utils/discord";
import { replacement } from "../../locales";

export default {
Expand Down
3 changes: 0 additions & 3 deletions src/interactions/tickets/close.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {
ActionRowBuilder,
AttachmentBuilder,
ButtonBuilder,
ButtonStyle,
Message,
TextChannel,
} from "discord.js";
Expand Down
3 changes: 0 additions & 3 deletions src/interactions/tickets/delete.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
TextChannel,
} from "discord.js";
import { Command } from "../../types/discord";
Expand Down
5 changes: 1 addition & 4 deletions src/interactions/tickets/removeuser.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
TextChannel,
} from "discord.js";
import { Command } from "../../types/discord";
import { db, getServer } from "../../db";
import { tickets } from "../../schema";
import { eq, sql } from "drizzle-orm";
import { DiscordFetch, embed as embed_ } from "../../utils/discord";
import { embed as embed_ } from "../../utils/discord";
import { replacement } from "../../locales";

export default {
Expand Down
3 changes: 1 addition & 2 deletions src/routes/auth.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Client } from "discord.js";
import { Express } from "express";
import { initialiseSteam } from "../utils/steam";

export default function (app: Express, client: Client) {
export default function (app: Express) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client needs to be here otherwise the function will break

app.get("/auth", async (req, res) => {
const clientid = req.query.clientid;
if (!clientid) return res.status(400).send("No clientid provided");
Expand Down
6 changes: 2 additions & 4 deletions src/routes/report.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import {
CategoryChannel,
Client,
ChannelType,
OverwriteResolvable, TextChannel, PermissionFlagsBits, PermissionsBitField
OverwriteResolvable, TextChannel,
} from "discord.js";
import { Express } from "express";
import { initialiseSteam } from "../utils/steam";
import { db, getUser, User } from "../db";
import { servers, tickets } from "../schema";
import { eq } from "drizzle-orm";
import { DiscordFetch, embed as embed_ } from "../utils/discord";
import { Locales, replacement } from "../locales";
import { Locales } from "../locales";
import ids from '../../ids.json';

export default function (app: Express, client: Client) {
Expand Down
1 change: 0 additions & 1 deletion src/types/discord.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type {
AnySelectMenuInteraction,
ApplicationCommandOption,
AutocompleteInteraction,
ButtonInteraction,
Expand Down